view tests/test_fetch_renames.py @ 1234:d3c79072bc6a

editor: correctly import symlink copy+modify with non-empty prefix We alwasy fail editing for symlinks, since we strip the leading 'link ' subversion includes when storing in mercurial, and then let svn attempt to apply deltas against the stripped version. This unsurprisingly fails, and we write the resulting empty-string to the Filestore for the current revision, and add the symlink in question to the missing list to handle stupidly later. Unfortunately, this would break down because editing adds files to the store using their absolute path whereas missing files are added relative to our subdir. the absolut path file appears to win, which results in us getting a symlink whose target is the empty string. This fixes the problem by adding missing files to the fileStore using their absolute path.
author David Schleimer <dschleimer@fb.com>
date Mon, 07 Apr 2014 18:28:35 -0700
parents 0d0132cba155
children 6b15eeb78c1a
line wrap: on
line source

import test_util

import sys
import unittest

class TestFetchRenames(test_util.TestBase):
    stupid_mode_tests = True

    def _debug_print_copies(self, repo):
        w = sys.stderr.write
        for rev in repo:
            ctx = repo[rev]
            w('%d - %s\n' % (ctx.rev(), ctx.branch()))
            for f in ctx:
                fctx = ctx[f]
                w('%s: %r %r\n' % (f, fctx.data(), fctx.renamed()))

    def test_rename(self):
        config = {
            'hgsubversion.filestoresize': '0',
            }
        repo = self._load_fixture_and_fetch('renames.svndump', config=config)
        self._run_assertions(repo)

    def test_rename_with_prefix(self):
        config = {
            'hgsubversion.filestoresize': '0',
            }
        repo = self._load_fixture_and_fetch('renames_with_prefix.svndump',
                                            subdir='prefix',
                                            config=config)
        self._run_assertions(repo)

    def _run_assertions(self, repo):
        # Map revnum to mappings of dest name to (source name, dest content)
        copies = {
            4: {
                'a1': ('a', 'a\n'),
                'linka1': ('linka', 'a'),
                'a2': ('a', 'a\n'),
                'linka2': ('linka', 'a'),
                'b1': ('b', 'b\nc\n'),
                'linkb1': ('linkb', 'bc'),
                'da1/daf': ('da/daf', 'c\n'),
                'da1/dalink': ('da/dalink', 'daf'),
                'da1/db/dbf': ('da/db/dbf', 'd\n'),
                'da1/db/dblink': ('da/db/dblink', '../daf'),
                'da2/daf': ('da/daf', 'c\n'),
                'da2/dalink': ('da/dalink', 'daf'),
                'da2/db/dbf': ('da/db/dbf', 'd\n'),
                'da2/db/dblink': ('da/db/dblink', '../daf'),
                },
            5: {
                'c1': ('c', 'c\nc\n'),
                'linkc1': ('linkc', 'cc'),
                },
            9: {
                'unchanged2': ('unchanged', 'unchanged\n'),
                'unchangedlink2': ('unchangedlink', 'unchanged'),
                'unchangeddir2/f': ('unchangeddir/f', 'unchanged2\n'),
                'unchangeddir2/link': ('unchangeddir/link', 'f'),
                },
            10: {
                'groupdir2/b': ('groupdir/b', 'b\n'),
                'groupdir2/linkb': ('groupdir/linkb', 'b'),
                 },
            }
        for rev in repo:
            ctx = repo[rev]
            copymap = copies.get(rev, {})
            for f in ctx.manifest():
                cp = ctx[f].renamed()
                self.assertEqual(bool(cp), bool(copymap.get(f)),
                                 'copy records differ for %s in %d' % (f, rev))
                if not cp:
                    continue
                self.assertEqual(cp[0], copymap[f][0])
                self.assertEqual(ctx[f].data(), copymap[f][1])

        self.assertEqual(repo['tip']['changed3'].data(), 'changed\nchanged3\n')

    def test_case(self):
        repo = self._load_fixture_and_fetch('filecase.svndump')
        files = {
            0: ['A', 'a', 'e/a', 'b', 'd/a', 'D/a', 'f/a', 'F'],
            1: ['A', 'a', 'E/a', 'B', 'd/A', 'D/a', 'f/a', 'F'],
            }
        for rev in repo:
            self.assertEqual(sorted(files[rev]), sorted(repo[rev].manifest()))