Exemplo n.º 1
0
    def test_branchmap_rebuildmeta(self):
        '''test rebuildmeta on a branchmapped clone'''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname = dit\n")
        branchmap.write("feature = dah\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui,
                       test_util.fileurl(repo_path),
                       self.wc_path,
                       branchmap=self.branchmap)
        originfo = self.repo.svnmeta().branches

        # clone & rebuild
        ui = self.ui()
        src, dest = test_util.hgclone(ui,
                                      self.wc_path,
                                      self.wc_path + '_clone',
                                      update=False)
        src = test_util.getlocalpeer(src)
        dest = test_util.getlocalpeer(dest)
        svncommands.rebuildmeta(ui, dest, args=[test_util.fileurl(repo_path)])

        # just check the keys; assume the contents are unaffected by the branch
        # map and thus properly tested by other tests
        self.assertEquals(sorted(src.svnmeta().branches),
                          sorted(dest.svnmeta().branches))
Exemplo n.º 2
0
    def test_branchmap_rebuildmeta(self):
        '''test rebuildmeta on a branchmapped clone'''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname = dit\n")
        branchmap.write("feature = dah\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui, test_util.fileurl(repo_path),
                       self.wc_path, branchmap=self.branchmap)
        originfo = self.repo.svnmeta().branches

        # clone & rebuild
        ui = self.ui()
        src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone',
                                      update=False)
        src = test_util.getlocalpeer(src)
        dest = test_util.getlocalpeer(dest)
        svncommands.rebuildmeta(ui, dest,
                                args=[test_util.fileurl(repo_path)])

        # just check the keys; assume the contents are unaffected by the branch
        # map and thus properly tested by other tests
        self.assertEquals(sorted(src.svnmeta().branches),
                          sorted(dest.svnmeta().branches))
Exemplo n.º 3
0
 def test_list_authors_map(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     author_path = os.path.join(repo_path, 'authors')
     svncommands.listauthors(self.ui(),
                             args=[test_util.fileurl(repo_path)],
                             authors=author_path)
     self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n')
Exemplo n.º 4
0
    def test_corruption(self):
        SUCCESS = 0
        FAILURE = 1

        repo, repo_path = self.load_and_fetch('correct.svndump', layout='single',
                                              subdir='')

        ui = self.ui()

        self.assertEqual(SUCCESS, verify.verify(ui, self.repo, rev='tip'))

        corrupt_source = test_util.fileurl(self.load_svndump('corrupt.svndump'))

        repo.ui.setconfig('paths', 'default', corrupt_source)

        ui.pushbuffer()
        code = verify.verify(ui, repo, rev='tip')
        actual = ui.popbuffer()

        actual = actual.replace(corrupt_source, '$REPO')
        actual = set(actual.splitlines())

        expected = set([
            'verifying 78e965230a13 against $REPO@1',
            'missing file: missing-file',
            'wrong flags for: executable-file',
            'wrong flags for: symlink',
            'wrong flags for: regular-file',
            'difference in: another-regular-file',
            'difference in: regular-file',
            'unexpected file: empty-file',
        ])

        self.assertEqual((FAILURE, expected), (code, actual))
Exemplo n.º 5
0
 def test_author_map_mapauthorscmd(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     ui = self.ui()
     ui.setconfig('hgsubversion', 'mapauthorscmd', 'echo "svn: %s"')
     commands.clone(ui, test_util.fileurl(repo_path), self.wc_path)
     self.assertEqual(self.repo[0].user(), 'svn: Augie')
     self.assertEqual(revsymbol(self.repo, 'tip').user(), 'svn: evil')
Exemplo n.º 6
0
 def test_list_authors_map(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     author_path = os.path.join(repo_path, 'authors')
     svncommands.listauthors(self.ui(),
                             args=[test_util.fileurl(repo_path)],
                             authors=author_path)
     self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n')
Exemplo n.º 7
0
    def test_push_single_dir_renamed_branch(self):
        # Tests pulling and pushing with a renamed branch
        # Based on test_push_single_dir
        repo_path = self.load_svndump('branch_from_tag.svndump')
        cmd = ['clone', '--quiet', '--layout=single', '--branch=flaf']
        if self.stupid:
            cmd.append('--stupid')
        cmd += [test_util.fileurl(repo_path), self.wc_path]
        test_util.dispatch(cmd)

        def file_callback(repo, memctx, path):
            if path == 'adding_file':
                return compathacks.makememfilectx(repo,
                                                  memctx=memctx,
                                                  path=path,
                                                  data='foo',
                                                  islink=False,
                                                  isexec=False,
                                                  copied=False)
            raise IOError(errno.EINVAL, 'Invalid operation: ' + path)

        lr = self.repo
        ctx = context.memctx(lr, (lr['tip'].node(), node.nullid),
                             'automated test', ['adding_file'], file_callback,
                             'an_author', '2009-10-19 18:49:30 -0500', {
                                 'branch': 'default',
                             })
        lr.commitctx(ctx)
        hg.update(self.repo, self.repo['tip'].node())
        self.pushrevisions()
        self.assertTrue('adding_file' in test_util.svnls(repo_path, ''))

        self.assertEquals(set(['flaf']),
                          set(self.repo[i].branch() for i in self.repo))
Exemplo n.º 8
0
    def test_push_single_dir_renamed_branch(self, stupid=False):
        # Tests pulling and pushing with a renamed branch
        # Based on test_push_single_dir
        test_util.load_svndump_fixture(self.repo_path,
                                       'branch_from_tag.svndump')
        cmd = ['clone', '--layout=single', '--branch=flaf']
        if stupid:
            cmd.append('--stupid')
        cmd += [test_util.fileurl(self.repo_path), self.wc_path]
        dispatch.dispatch(cmd)

        def file_callback(repo, memctx, path):
            if path == 'adding_file':
                return context.memfilectx(path=path,
                                          data='foo',
                                          islink=False,
                                          isexec=False,
                                          copied=False)
            raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
        ctx = context.memctx(self.repo,
                             (self.repo['tip'].node(), node.nullid),
                             'automated test',
                             ['adding_file'],
                             file_callback,
                             'an_author',
                             '2009-10-19 18:49:30 -0500',
                             {'branch': 'default',})
        self.repo.commitctx(ctx)
        hg.update(self.repo, self.repo['tip'].node())
        self.pushrevisions()
        self.assertTrue('adding_file' in self.svnls(''))

        self.assertEquals(set(['flaf']),
                          set(self.repo[i].branch() for i in self.repo))
Exemplo n.º 9
0
    def test_push_to_non_tip(self):
        self.test_push_to_branch(push=False)
        wc2path = self.wc_path + '_clone'
        u = self.repo.ui
        hg.clone(self.repo.ui, self.wc_path, wc2path, update=False)
        res = self.pushrevisions()
        self.assertEqual(0, res)
        oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc'))
        hgrc = oldf.read()
        oldf.close()
        shutil.rmtree(self.wc_path)
        hg.clone(u, wc2path, self.wc_path, update=False)
        oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc'), 'w')
        oldf.write(hgrc)
        oldf.close()

        # do a commit here
        self.commitchanges([('foobaz', 'foobaz', 'This file is added on default.', ),
                            ],
                           parent='default',
                           message='commit to default')
        from hgsubversion import svncommands
        svncommands.rebuildmeta(u,
                                self.repo,
                                args=[test_util.fileurl(self.repo_path)])


        hg.update(self.repo, self.repo['tip'].node())
        oldnode = self.repo['tip'].hex()
        self.pushrevisions(expected_extra_back=1)
        self.assertNotEqual(oldnode, self.repo['tip'].hex(), 'Revision was not pushed.')
Exemplo n.º 10
0
 def test_list_authors(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     u = self.ui()
     u.pushbuffer()
     svncommands.listauthors(u,
                             args=[test_util.fileurl(repo_path)],
                             authors=None)
     actual = u.popbuffer()
     self.assertMultiLineEqual(actual, 'Augie\nevil\n')
Exemplo n.º 11
0
 def test_list_authors(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     u = self.ui()
     u.pushbuffer()
     svncommands.listauthors(u,
                                  args=[test_util.fileurl(repo_path)],
                                  authors=None)
     actual = u.popbuffer()
     self.assertMultiLineEqual(actual, 'Augie\nevil\n')
Exemplo n.º 12
0
def _do_case(self, name, stupid, single):
    subdir = test_util.subdir.get(name, '')
    layout = 'auto'
    if single:
        layout = 'single'
    self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout)
    assert len(self.repo) > 0
    wc2_path = self.wc_path + '_clone'
    u = ui.ui()
    src, dest = hg.clone(u, self.wc_path, wc2_path, update=False)

    # insert a wrapper that prevents calling changectx.children()
    def failfn(orig, ctx):
        self.fail('calling %s is forbidden; it can cause massive slowdowns '
                  'when rebuilding large repositories' % orig)

    origchildren = getattr(context.changectx, 'children')
    extensions.wrapfunction(context.changectx, 'children', failfn)

    try:
        svncommands.rebuildmeta(u, dest,
                                args=[test_util.fileurl(self.repo_path +
                                                        subdir), ])
    finally:
        # remove the wrapper
        context.changectx.children = origchildren

    self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
                    'no .hg/svn directory in the source!')
    self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
                    'no .hg/svn directory in the destination!')
    dest = hg.repository(u, os.path.dirname(dest.path))
    for tf in ('rev_map', 'uuid', 'tagmap', 'layout', 'subdir', ):
        stf = os.path.join(src.path, 'svn', tf)
        self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf)
        dtf = os.path.join(dest.path, 'svn', tf)
        self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf)
        old, new = open(stf).read(), open(dtf).read()
        self.assertMultiLineEqual(old, new)
        self.assertEqual(src.branchtags(), dest.branchtags())
    srcbi = pickle.load(open(os.path.join(src.path, 'svn', 'branch_info')))
    destbi = pickle.load(open(os.path.join(dest.path, 'svn', 'branch_info')))
    self.assertEqual(sorted(srcbi.keys()), sorted(destbi.keys()))
    revkeys = svnmeta.SVNMeta(dest).revmap.keys()
    for branch in destbi:
        srcinfo = srcbi[branch]
        destinfo = destbi[branch]
        if srcinfo[:2] == (None, 0) or destinfo[:2] == (None, 0):
            self.assertTrue(srcinfo[2] <= destinfo[2],
                            'Latest revision for %s decreased from %d to %d!'
                            % (branch or 'default', srcinfo[2], destinfo[2]))
            self.assertEqual(srcinfo[0], destinfo[0])
        else:
            pr = sorted(filter(lambda x: x[1] == srcinfo[0] and x[0] <= srcinfo[1],
                        revkeys), reverse=True)[0][0]
            self.assertEqual(pr, destinfo[1])
            self.assertEqual(srcinfo[2], destinfo[2])
Exemplo n.º 13
0
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp('svnwrap_test')
        self.repo_path = '%s/testrepo' % self.tmpdir

        with open(
                os.path.join(test_util.FIXTURES,
                             'project_root_at_repo_root.svndump')) as fp:
            svnwrap.create_and_load(self.repo_path, fp)

        self.repo = svnwrap.SubversionRepo(test_util.fileurl(self.repo_path))
Exemplo n.º 14
0
    def test_quoting(self):
        ui = self.ui()
        repo_path = self.load_svndump('non_ascii_path_1.svndump')

        repo_url = test_util.fileurl(repo_path)
        subdir = '/b\xC3\xB8b'
        quoted_subdir = urllib.quote(subdir)

        repo1 = svnrepo.svnremoterepo(ui, repo_url + subdir)
        repo2 = svnrepo.svnremoterepo(ui, repo_url + quoted_subdir)
        self.assertEqual(repo1.svnurl, repo2.svnurl)
Exemplo n.º 15
0
 def test_file_map(self, stupid=False):
     test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
     filemap = open(self.filemap, 'w')
     filemap.write("include alpha\n")
     filemap.close()
     ui = self.ui(stupid)
     ui.setconfig('hgsubversion', 'filemap', self.filemap)
     commands.clone(ui, test_util.fileurl(self.repo_path),
                    self.wc_path, filemap=self.filemap)
     self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
     self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155')
Exemplo n.º 16
0
 def test_file_map_exclude(self, stupid=False):
     test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
     filemap = open(self.filemap, 'w')
     filemap.write("exclude alpha\n")
     filemap.close()
     ui = self.ui(stupid)
     ui.setconfig('hgsubversion', 'filemap', self.filemap)
     commands.clone(ui, test_util.fileurl(self.repo_path),
                    self.wc_path, filemap=self.filemap)
     self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
     self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
Exemplo n.º 17
0
    def test_quoting(self):
        ui = self.ui()
        repo_path = self.load_svndump('non_ascii_path_1.svndump')

        repo_url = test_util.fileurl(repo_path)
        subdir = '/b\xC3\xB8b'
        quoted_subdir = urllib.quote(subdir)

        repo1 = svnrepo.svnremoterepo(ui, repo_url + subdir)
        repo2 = svnrepo.svnremoterepo(ui, repo_url + quoted_subdir)
        self.assertEqual(repo1.svnurl, repo2.svnurl)
Exemplo n.º 18
0
    def test_empty_log_message(self):
        repo, repo_path = self.load_and_fetch('empty-log-message.svndump')

        self.assertEqual(revsymbol(repo, 'tip').description(), '')

        test_util.rmtree(self.wc_path)

        ui = self.ui()
        ui.setconfig('hgsubversion', 'defaultmessage', 'blyf')
        commands.clone(ui, test_util.fileurl(repo_path), self.wc_path)

        self.assertEqual(revsymbol(self.repo, 'tip').description(), 'blyf')
Exemplo n.º 19
0
 def test_branchmap_tagging(self):
     '''test tagging a renamed branch, which used to raise an exception'''
     repo_path = self.load_svndump('commit-to-tag.svndump')
     branchmap = open(self.branchmap, 'w')
     branchmap.write("magic = art\n")
     branchmap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
     commands.clone(ui, test_util.fileurl(repo_path),
                    self.wc_path, branchmap=self.branchmap)
     branches = set(self.repo[i].branch() for i in self.repo)
     self.assertEquals(sorted(branches), ['art', 'closeme'])
Exemplo n.º 20
0
 def test_branchmap_empty_commit(self):
     '''test mapping an empty commit on a renamed branch'''
     repo_path = self.load_svndump('propset-branch.svndump')
     branchmap = open(self.branchmap, 'w')
     branchmap.write("the-branch = bob\n")
     branchmap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
     commands.clone(ui, test_util.fileurl(repo_path),
                    self.wc_path, branchmap=self.branchmap)
     branches = set(self.repo[i].branch() for i in self.repo)
     self.assertEquals(sorted(branches), ['bob', 'default'])
Exemplo n.º 21
0
    def test_empty_log_message(self):
        repo, repo_path = self.load_and_fetch('empty-log-message.svndump')

        self.assertEqual(repo['tip'].description(), '')

        test_util.rmtree(self.wc_path)

        ui = self.ui()
        ui.setconfig('hgsubversion', 'defaultmessage', 'blyf')
        commands.clone(ui, test_util.fileurl(repo_path), self.wc_path)

        self.assertEqual(self.repo['tip'].description(), 'blyf')
Exemplo n.º 22
0
 def setUp(self):
     self.tmpdir = tempfile.mkdtemp('svnwrap_test')
     self.repo_path = '%s/testrepo' % self.tmpdir
     subprocess.call(['svnadmin', 'create', self.repo_path, ])
     inp = open(os.path.join(os.path.dirname(__file__), 'fixtures',
                             'project_root_at_repo_root.svndump'))
     proc = subprocess.call(['svnadmin', 'load', self.repo_path, ],
                             stdin=inp,
                             close_fds=test_util.canCloseFds,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT)
     assert proc == 0
     self.repo = svnwrap.SubversionRepo(test_util.fileurl(self.repo_path))
Exemplo n.º 23
0
 def test_svnrebuildmeta(self):
     otherpath = self.load_svndump('binaryfiles-broken.svndump')
     otherurl = test_util.fileurl(otherpath)
     self.load_and_fetch('replace_trunk_with_branch.svndump')
     # rebuildmeta with original repo
     svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[])
     # rebuildmeta with unrelated repo
     self.assertRaises(hgutil.Abort,
                       svncommands.rebuildmeta,
                       self.ui(), repo=self.repo, args=[otherurl])
     # rebuildmeta --unsafe-skip-uuid-check with unrelated repo
     svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[otherurl],
                             unsafe_skip_uuid_check=True)
Exemplo n.º 24
0
 def _loadwithfilemap(self, svndump, filemapcontent,
         failonmissing=True):
     repo_path = self.load_svndump(svndump)
     filemap = open(self.filemap, 'w')
     filemap.write(filemapcontent)
     filemap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'filemap', self.filemap)
     ui.setconfig('hgsubversion', 'failoninvalidreplayfile', 'true')
     ui.setconfig('hgsubversion', 'failonmissing', failonmissing)
     commands.clone(ui, test_util.fileurl(repo_path),
                    self.wc_path, filemap=self.filemap)
     return self.repo
Exemplo n.º 25
0
    def test_tagren_changed(self):
        repo_path = self.load_svndump('commit-to-tag.svndump')
        tagmap = open(self.tagmap, 'w')
        tagmap.write("edit-at-create = edit-past\n")
        tagmap.write("also-edit = \n")
        tagmap.write("will-edit = edit-future\n")
        tagmap.close()

        ui = self.ui()
        ui.setconfig('hgsubversion', 'tagmap', self.tagmap)
        commands.clone(ui, test_util.fileurl(repo_path),
                       self.wc_path, tagmap=self.tagmap)
        tags = self.repo.tags()
Exemplo n.º 26
0
 def test_author_map_closing_author(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     authormap = open(self.authors, 'w')
     authormap.write("evil=Testy <test@test>")
     authormap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'authormap', self.authors)
     commands.clone(ui, test_util.fileurl(repo_path),
                    self.wc_path, authors=self.authors)
     self.assertEqual(self.repo[0].user(),
                      'Augie@5b65bade-98f3-4993-a01f-b7a6710da339')
     self.assertEqual(self.repo['tip'].user(),
                     'Testy <test@test>')
Exemplo n.º 27
0
 def test_author_map(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     authormap = open(self.authors, 'w')
     authormap.write('Augie=Augie Fackler <*****@*****.**> # stuffy\n')
     authormap.write("Augie Fackler <*****@*****.**>\n")
     authormap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'authormap', self.authors)
     commands.clone(ui, test_util.fileurl(repo_path),
                    self.wc_path, authors=self.authors)
     self.assertEqual(self.repo[0].user(),
                      'Augie Fackler <*****@*****.**>')
     self.assertEqual(self.repo['tip'].user(),
                     'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
Exemplo n.º 28
0
 def test_branchmap_empty_commit(self):
     '''test mapping an empty commit on a renamed branch'''
     repo_path = self.load_svndump('propset-branch.svndump')
     branchmap = open(self.branchmap, 'w')
     branchmap.write("the-branch = bob\n")
     branchmap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
     commands.clone(ui,
                    test_util.fileurl(repo_path),
                    self.wc_path,
                    branchmap=self.branchmap)
     branches = set(self.repo[i].branch() for i in self.repo)
     self.assertEquals(sorted(branches), ['bob', 'default'])
Exemplo n.º 29
0
 def test_branchmap_tagging(self):
     '''test tagging a renamed branch, which used to raise an exception'''
     repo_path = self.load_svndump('commit-to-tag.svndump')
     branchmap = open(self.branchmap, 'w')
     branchmap.write("magic = art\n")
     branchmap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
     commands.clone(ui,
                    test_util.fileurl(repo_path),
                    self.wc_path,
                    branchmap=self.branchmap)
     branches = set(self.repo[i].branch() for i in self.repo)
     self.assertEquals(sorted(branches), ['art', 'closeme'])
Exemplo n.º 30
0
 def _loadwithfilemap(self, svndump, filemapcontent, failonmissing=True):
     repo_path = self.load_svndump(svndump)
     filemap = open(self.filemap, 'w')
     filemap.write(filemapcontent)
     filemap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'filemap', self.filemap)
     ui.setconfig('hgsubversion', 'failoninvalidreplayfile', 'true')
     ui.setconfig('hgsubversion', 'failonmissing', failonmissing)
     commands.clone(ui,
                    test_util.fileurl(repo_path),
                    self.wc_path,
                    filemap=self.filemap)
     return self.repo
Exemplo n.º 31
0
 def test_branchmap(self):
     repo_path = self.load_svndump('branchmap.svndump')
     branchmap = open(self.branchmap, 'w')
     branchmap.write("badname = good-name # stuffy\n")
     branchmap.write("feature = default\n")
     branchmap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
     commands.clone(ui, test_util.fileurl(repo_path),
                    self.wc_path, branchmap=self.branchmap)
     branches = set(self.repo[i].branch() for i in self.repo)
     self.assert_('badname' not in branches)
     self.assert_('good-name' in branches)
     self.assertEquals(self.repo[2].branch(), 'default')
Exemplo n.º 32
0
    def test_branchmap_verify(self):
        '''test verify on a branchmapped clone'''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname = dit\n")
        branchmap.write("feature = dah\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui, test_util.fileurl(repo_path),
                       self.wc_path, branchmap=self.branchmap)
        repo = self.repo

        for r in repo:
            self.assertEquals(verify.verify(ui, repo, rev=r), 0)
Exemplo n.º 33
0
    def test_tagren_changed(self):
        repo_path = self.load_svndump('commit-to-tag.svndump')
        tagmap = open(self.tagmap, 'w')
        tagmap.write("edit-at-create = edit-past\n")
        tagmap.write("also-edit = \n")
        tagmap.write("will-edit = edit-future\n")
        tagmap.close()

        ui = self.ui()
        ui.setconfig('hgsubversion', 'tagmap', self.tagmap)
        commands.clone(ui,
                       test_util.fileurl(repo_path),
                       self.wc_path,
                       tagmap=self.tagmap)
        tags = self.repo.tags()
Exemplo n.º 34
0
 def test_author_map_closing_author(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     authormap = open(self.authors, 'w')
     authormap.write("evil=Testy <test@test>")
     authormap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'authormap', self.authors)
     commands.clone(ui,
                    test_util.fileurl(repo_path),
                    self.wc_path,
                    authors=self.authors)
     self.assertEqual(self.repo[0].user(),
                      'Augie@5b65bade-98f3-4993-a01f-b7a6710da339')
     self.assertEqual(
         revsymbol(self.repo, 'tip').user(), 'Testy <test@test>')
Exemplo n.º 35
0
    def test_tagmap(self):
        repo_path = self.load_svndump('basic_tag_tests.svndump')
        tagmap = open(self.tagmap, 'w')
        tagmap.write("tag_r3 = 3.x # stuffy\n")
        tagmap.write("copied_tag = \n")
        tagmap.close()

        ui = self.ui()
        ui.setconfig('hgsubversion', 'tagmap', self.tagmap)
        commands.clone(ui, test_util.fileurl(repo_path),
                       self.wc_path, tagmap=self.tagmap)
        tags = self.repo.tags()
        assert 'tag_r3' not in tags
        assert '3.x' in tags
        assert 'copied_tag' not in tags
Exemplo n.º 36
0
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    self._load_fixture_and_fetch(name, subdir=subdir, stupid=False, layout=layout)
    assert len(self.repo) > 0, 'Repo had no changes, maybe you need to add a subdir entry in test_util?'
    wc2_path = self.wc_path + '_stupid'
    u = ui.ui()
    checkout_path = self.repo_path
    if subdir:
        checkout_path += '/' + subdir
    u.setconfig('hgsubversion', 'stupid', '1')
    u.setconfig('hgsubversion', 'layout', layout)
    test_util.hgclone(u, test_util.fileurl(checkout_path), wc2_path, update=False)
    if layout == 'single':
        self.assertEqual(len(self.repo.heads()), 1)
    self.repo2 = hg.repository(ui.ui(), wc2_path)
    self.assertEqual(self.repo.heads(), self.repo2.heads())
Exemplo n.º 37
0
 def test_branchmap(self):
     repo_path = self.load_svndump('branchmap.svndump')
     branchmap = open(self.branchmap, 'w')
     branchmap.write("badname = good-name # stuffy\n")
     branchmap.write("feature = default\n")
     branchmap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
     commands.clone(ui,
                    test_util.fileurl(repo_path),
                    self.wc_path,
                    branchmap=self.branchmap)
     branches = set(self.repo[i].branch() for i in self.repo)
     self.assert_('badname' not in branches)
     self.assert_('good-name' in branches)
     self.assertEquals(self.repo[2].branch(), 'default')
Exemplo n.º 38
0
    def test_branchmap_verify(self):
        '''test verify on a branchmapped clone'''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname = dit\n")
        branchmap.write("feature = dah\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui,
                       test_util.fileurl(repo_path),
                       self.wc_path,
                       branchmap=self.branchmap)
        repo = self.repo

        for r in repo:
            self.assertEquals(verify.verify(ui, repo, rev=r), 0)
Exemplo n.º 39
0
 def test_most_recent_is_edited(self, stupid=False):
     repo = self._load_fixture_and_fetch('most-recent-is-edit-tag.svndump',
                                         stupid=stupid)
     self.repo.ui.status(
         "Note: this test failing may be because of a rebuildmeta failure.\n"
         "You should check that before assuming issues with this test.\n")
     wc2_path = self.wc_path + '2'
     src, dest = hg.clone(repo.ui, self.wc_path, wc2_path, update=False)
     svncommands.rebuildmeta(repo.ui,
                            dest,
                            args=[test_util.fileurl(self.repo_path), ])
     commands.pull(self.repo.ui, self.repo, stupid=stupid)
     dtags, srctags = dest.tags(), self.repo.tags()
     dtags.pop('tip')
     srctags.pop('tip')
     self.assertEqual(dtags, srctags)
     self.assertEqual(dest.heads(), self.repo.heads())
Exemplo n.º 40
0
    def test_tagmap(self):
        repo_path = self.load_svndump('basic_tag_tests.svndump')
        tagmap = open(self.tagmap, 'w')
        tagmap.write("tag_r3 = 3.x # stuffy\n")
        tagmap.write("copied_tag = \n")
        tagmap.close()

        ui = self.ui()
        ui.setconfig('hgsubversion', 'tagmap', self.tagmap)
        commands.clone(ui,
                       test_util.fileurl(repo_path),
                       self.wc_path,
                       tagmap=self.tagmap)
        tags = self.repo.tags()
        assert 'tag_r3' not in tags
        assert '3.x' in tags
        assert 'copied_tag' not in tags
Exemplo n.º 41
0
 def test_author_map(self):
     repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
     authormap = open(self.authors, 'w')
     authormap.write('Augie=Augie Fackler <*****@*****.**> # stuffy\n')
     authormap.write("Augie Fackler <*****@*****.**>\n")
     authormap.close()
     ui = self.ui()
     ui.setconfig('hgsubversion', 'authormap', self.authors)
     commands.clone(ui,
                    test_util.fileurl(repo_path),
                    self.wc_path,
                    authors=self.authors)
     self.assertEqual(self.repo[0].user(),
                      'Augie Fackler <*****@*****.**>')
     self.assertEqual(
         revsymbol(self.repo, 'tip').user(),
         'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
Exemplo n.º 42
0
    def test_author_map_no_author(self):
        repo, repo_path = self.load_and_fetch('no-author.svndump')
        users = set(self.repo[r].user() for r in self.repo)
        expected_users = ['(no author)@%s' % self.repo.svnmeta().uuid]
        self.assertEqual(sorted(users), expected_users)
        test_util.rmtree(self.wc_path)

        authormap = open(self.authors, 'w')
        authormap.write("(no author)=Testy <*****@*****.**>")
        authormap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'authormap', self.authors)
        commands.clone(ui, test_util.fileurl(repo_path),
                       self.wc_path, authors=self.authors)
        users = set(self.repo[r].user() for r in self.repo)
        expected_users = ['Testy <*****@*****.**>']
        self.assertEqual(sorted(users), expected_users)
Exemplo n.º 43
0
 def test_svnrebuildmeta(self):
     otherpath = self.load_svndump('binaryfiles-broken.svndump')
     otherurl = test_util.fileurl(otherpath)
     self.load_and_fetch('replace_trunk_with_branch.svndump')
     # rebuildmeta with original repo
     svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[])
     # rebuildmeta with unrelated repo
     self.assertRaises(hgerror.Abort,
                       svncommands.rebuildmeta,
                       self.ui(),
                       repo=self.repo,
                       args=[otherurl])
     # rebuildmeta --unsafe-skip-uuid-check with unrelated repo
     svncommands.rebuildmeta(self.ui(),
                             repo=self.repo,
                             args=[otherurl],
                             unsafe_skip_uuid_check=True)
Exemplo n.º 44
0
 def test_file_map_rule_order(self):
     test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
     filemap = open(self.filemap, 'w')
     filemap.write("exclude alpha\n")
     filemap.write("include .\n")
     filemap.write("exclude gamma\n")
     filemap.close()
     ui = self.ui(False)
     ui.setconfig('hgsubversion', 'filemap', self.filemap)
     commands.clone(ui, test_util.fileurl(self.repo_path),
                    self.wc_path, filemap=self.filemap)
     # The exclusion of alpha is overridden by the later rule to
     # include all of '.', whereas gamma should remain excluded
     # because it's excluded after the root directory.
     self.assertEqual(self.repo[0].manifest().keys(),
                      ['alpha', 'beta'])
     self.assertEqual(self.repo['default'].manifest().keys(),
                      ['alpha', 'beta'])
Exemplo n.º 45
0
    def test_branchmap_no_replacement(self):
        '''test that empty mappings are accepted

        Empty mappings are lines like 'this ='. We check that such branches are
        not converted.
        '''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname =\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui,
                       test_util.fileurl(repo_path),
                       self.wc_path,
                       branchmap=self.branchmap)
        branches = set(self.repo[i].branch() for i in self.repo)
        self.assertEquals(sorted(branches), ['default', 'feature'])
Exemplo n.º 46
0
def _do_case(self, name, stupid, single):
    subdir = test_util.subdir.get(name, '')
    layout = 'auto'
    if single:
        layout = 'single'
    self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout)
    assert len(self.repo) > 0
    wc2_path = self.wc_path + '_clone'
    u = ui.ui()
    src, dest = hg.clone(u, self.wc_path, wc2_path, update=False)
    svncommands.rebuildmeta(u,
                            dest,
                            args=[test_util.fileurl(self.repo_path +
                                                    subdir), ])
    self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
                    'no .hg/svn directory in the source!')
    self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
                    'no .hg/svn directory in the destination!')
    dest = hg.repository(u, os.path.dirname(dest.path))
    for tf in ('rev_map', 'uuid', 'tagmap', 'layout', ):
        stf = os.path.join(src.path, 'svn', tf)
        self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf)
        dtf = os.path.join(dest.path, 'svn', tf)
        self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf)
        old, new = open(stf).read(), open(dtf).read()
        # uncomment next line for easy-ish debugging.
        # os.system('diff -u %s %s' % (stf, dtf))
        self.assertEqual(old, new)
        self.assertEqual(src.branchtags(), dest.branchtags())
    srcbi = pickle.load(open(os.path.join(src.path, 'svn', 'branch_info')))
    destbi = pickle.load(open(os.path.join(dest.path, 'svn', 'branch_info')))
    self.assertEqual(sorted(srcbi.keys()), sorted(destbi.keys()))
    revkeys = svnmeta.SVNMeta(dest).revmap.keys()
    for branch in destbi:
        srcinfo = srcbi[branch]
        destinfo = destbi[branch]
        if srcinfo[:2] == (None, 0) or destinfo[:2] == (None, 0):
            self.assert_(srcinfo[2] <= destinfo[2])
            self.assertEqual(srcinfo[0], destinfo[0])
        else:
            pr = sorted(filter(lambda x: x[1] == srcinfo[0] and x[0] <= srcinfo[1],
                        revkeys), reverse=True)[0][0]
            self.assertEqual(pr, destinfo[1])
            self.assertEqual(srcinfo[2], destinfo[2])
Exemplo n.º 47
0
    def test_svnverify(self):
        repo, repo_path = self.load_and_fetch('binaryfiles.svndump',
                                              noupdate=False)
        ret = verify.verify(self.ui(), repo, [], rev=1)
        self.assertEqual(0, ret)
        repo_path = self.load_svndump('binaryfiles-broken.svndump')
        u = self.ui()
        u.pushbuffer()
        ret = verify.verify(u, repo, [test_util.fileurl(repo_path)], rev=1)
        output = u.popbuffer()
        self.assertEqual(1, ret)
        output = re.sub(r'file://\S+', 'file://', output)
        self.assertMultiLineEqual(
            """\
verifying d51f46a715a1 against file://
difference in: binary2
unexpected file: binary1
missing file: binary3
""", output)
Exemplo n.º 48
0
    def test_author_map_no_author(self):
        repo, repo_path = self.load_and_fetch('no-author.svndump')
        users = set(self.repo[r].user() for r in self.repo)
        expected_users = ['(no author)@%s' % self.repo.svnmeta().uuid]
        self.assertEqual(sorted(users), expected_users)
        test_util.rmtree(self.wc_path)

        authormap = open(self.authors, 'w')
        authormap.write("(no author)=Testy <*****@*****.**>")
        authormap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'authormap', self.authors)
        commands.clone(ui,
                       test_util.fileurl(repo_path),
                       self.wc_path,
                       authors=self.authors)
        users = set(self.repo[r].user() for r in self.repo)
        expected_users = ['Testy <*****@*****.**>']
        self.assertEqual(sorted(users), expected_users)
Exemplo n.º 49
0
    def test_svnverify(self):
        repo, repo_path = self.load_and_fetch('binaryfiles.svndump',
                                              noupdate=False)
        ret = verify.verify(self.ui(), repo, [], rev=1)
        self.assertEqual(0, ret)
        repo_path = self.load_svndump('binaryfiles-broken.svndump')
        u = self.ui()
        u.pushbuffer()
        ret = verify.verify(u, repo, [test_util.fileurl(repo_path)],
                            rev=1)
        output = u.popbuffer()
        self.assertEqual(1, ret)
        output = re.sub(r'file://\S+', 'file://', output)
        self.assertMultiLineEqual("""\
verifying d51f46a715a1 against file://
difference in: binary2
unexpected file: binary1
missing file: binary3
""", output)
Exemplo n.º 50
0
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    single = layout == 'single'
    u = test_util.testui()
    config = {}
    if layout == 'custom':
        config['hgsubversion.layout'] = 'custom'
        u.setconfig('hgsubversion', 'layout', 'custom')
        for branch, path in test_util.custom.get(name, {}).iteritems():
            config['hgsubversionbranch.%s' % branch] = path
            u.setconfig('hgsubversionbranch', branch, path)

    repo, repo_path = self.load_and_fetch(name,
                                          subdir=subdir,
                                          layout=layout,
                                          config=config)
    assert test_util.repolen(self.repo) > 0
    wc2_path = self.wc_path + '_clone'
    src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False)
    src = test_util.getlocalpeer(src)
    dest = test_util.getlocalpeer(dest)

    # insert a wrapper that prevents calling changectx.children()
    def failfn(orig, ctx):
        self.fail('calling %s is forbidden; it can cause massive slowdowns '
                  'when rebuilding large repositories' % orig)

    origchildren = getattr(context.changectx, 'children')
    extensions.wrapfunction(context.changectx, 'children', failfn)

    # test updatemeta on an empty repo
    try:
        svncommands.updatemeta(u,
                               dest,
                               args=[
                                   test_util.fileurl(repo_path + subdir),
                               ])
    finally:
        # remove the wrapper
        context.changectx.children = origchildren

    self._run_assertions(name, single, src, dest, u)
Exemplo n.º 51
0
    def test_truncated_history(self, stupid=False):
        # Test repository does not follow the usual layout
        test_util.load_svndump_fixture(self.repo_path, 'truncatedhistory.svndump')
        svn_url = test_util.fileurl(self.repo_path + '/project2')
        commands.clone(self.ui(stupid), svn_url, self.wc_path, noupdate=True)
        repo = hg.repository(self.ui(stupid), self.wc_path)

        # We are converting /project2/trunk coming from:
        #
        # Changed paths:
        #     D /project1
        #     A /project2/trunk (from /project1:2)
        #
        # Here a full fetch should be performed since we are starting
        # the conversion on an already filled branch.
        tip = repo['tip']
        files = tip.manifest().keys()
        files.sort()
        self.assertEqual(files, ['a', 'b'])
        self.assertEqual(repo['tip']['a'].data(), 'a\n')
Exemplo n.º 52
0
    def test_truncated_history(self):
        # Test repository does not follow the usual layout
        repo_path = self.load_svndump('truncatedhistory.svndump')
        svn_url = test_util.fileurl(repo_path + '/project2')
        commands.clone(self.ui(), svn_url, self.wc_path, noupdate=True)
        repo = hg.repository(self.ui(), self.wc_path)

        # We are converting /project2/trunk coming from:
        #
        # Changed paths:
        #     D /project1
        #     A /project2/trunk (from /project1:2)
        #
        # Here a full fetch should be performed since we are starting
        # the conversion on an already filled branch.
        tip = repo['tip']
        files = tip.manifest().keys()
        files.sort()
        self.assertEqual(files, ['a', 'b'])
        self.assertEqual(repo['tip']['a'].data(), 'a\n')
Exemplo n.º 53
0
    def test_branchmap_combine(self):
        '''test combining two branches, but retaining heads'''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname = default\n")
        branchmap.write("feature = default\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui, test_util.fileurl(repo_path),
                       self.wc_path, branchmap=self.branchmap)
        branches = set(self.repo[i].branch() for i in self.repo)
        self.assertEquals(sorted(branches), ['default'])
        self.assertEquals(len(self.repo.heads()), 2)
        self.assertEquals(len(self.repo.branchheads('default')), 2)

        # test that the mapping does not affect branch info
        branches = self.repo.svnmeta().branches
        self.assertEquals(sorted(branches.keys()),
                          [None, 'badname', 'feature'])
Exemplo n.º 54
0
    def test_branchmap_combine(self):
        '''test combining two branches, but retaining heads'''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname = default\n")
        branchmap.write("feature = default\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui,
                       test_util.fileurl(repo_path),
                       self.wc_path,
                       branchmap=self.branchmap)
        branches = set(self.repo[i].branch() for i in self.repo)
        self.assertEquals(sorted(branches), ['default'])
        self.assertEquals(len(self.repo.heads()), 2)
        self.assertEquals(len(self.repo.branchheads('default')), 2)

        # test that the mapping does not affect branch info
        branches = self.repo.svnmeta().branches
        self.assertEquals(sorted(branches.keys()),
                          [None, 'badname', 'feature'])
Exemplo n.º 55
0
 def test_most_recent_is_edited(self):
     repo, repo_path = self.load_and_fetch(
         'most-recent-is-edit-tag.svndump')
     self.repo.ui.status(
         "Note: this test failing may be because of a rebuildmeta failure.\n"
         "You should check that before assuming issues with this test.\n")
     wc2_path = self.wc_path + '2'
     src, dest = test_util.hgclone(repo.ui,
                                   self.wc_path,
                                   wc2_path,
                                   update=False)
     dest = test_util.getlocalpeer(dest)
     svncommands.rebuildmeta(repo.ui,
                             dest,
                             args=[
                                 test_util.fileurl(repo_path),
                             ])
     commands.pull(self.repo.ui, self.repo)
     dtags, srctags = dest.tags(), self.repo.tags()
     dtags.pop('tip')
     srctags.pop('tip')
     self.assertEqual(dtags, srctags)
     self.assertEqual(dest.heads(), self.repo.heads())
Exemplo n.º 56
0
    def test_path_quoting(self):
        repo_path = self.load_svndump('non_ascii_path_1.svndump')
        subdir = '/b\xC3\xB8b'
        quoted_subdir = urllib.quote(subdir)

        repo_url = test_util.fileurl(repo_path)
        wc_path = self.wc_path
        wc2_path = wc_path + '-2'

        ui = self.ui()

        commands.clone(ui, repo_url + subdir, wc_path)
        commands.clone(ui, repo_url + quoted_subdir, wc2_path)
        repo = hg.repository(ui, wc_path)
        repo2 = hg.repository(ui, wc2_path)

        self.assertEqual(
            revsymbol(repo, 'tip').extra()['convert_revision'],
            repo2['tip'].extra()['convert_revision'])
        self.assertEqual(test_util.repolen(repo), test_util.repolen(repo2))

        for r in repo:
            self.assertEqual(repo[r].hex(), repo2[r].hex())
Exemplo n.º 57
0
 def setUp(self):
     self.tmpdir = tempfile.mkdtemp('svnwrap_test')
     self.repo_path = '%s/testrepo' % self.tmpdir
     subprocess.call([
         'svnadmin',
         'create',
         self.repo_path,
     ])
     inp = open(
         os.path.join(os.path.dirname(__file__), 'fixtures',
                      'project_root_not_repo_root.svndump'))
     ret = subprocess.call([
         'svnadmin',
         'load',
         self.repo_path,
     ],
                           stdin=inp,
                           close_fds=test_util.canCloseFds,
                           stdout=subprocess.PIPE,
                           stderr=subprocess.STDOUT)
     assert ret == 0
     self.repo = svnwrap.SubversionRepo(
         test_util.fileurl(self.repo_path + '/dummyproj'))
Exemplo n.º 58
0
    def test_push_to_non_tip(self):
        self.test_push_to_branch(push=False)
        wc2path = self.wc_path + '_clone'
        u = self.repo.ui
        test_util.hgclone(self.repo.ui, self.wc_path, wc2path, update=False)
        res = self.pushrevisions()
        self.assertEqual(0, res)
        oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc'))
        hgrc = oldf.read()
        oldf.close()
        shutil.rmtree(self.wc_path)
        test_util.hgclone(u, wc2path, self.wc_path, update=False)
        oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc'), 'w')
        oldf.write(hgrc)
        oldf.close()

        # do a commit here
        self.commitchanges([
            (
                'foobaz',
                'foobaz',
                'This file is added on default.',
            ),
        ],
                           parent='default',
                           message='commit to default')
        from hgsubversion import svncommands
        svncommands.rebuildmeta(u,
                                self.repo,
                                args=[test_util.fileurl(self.repo_path)])

        hg.update(self.repo, revsymbol(self.repo, 'tip').node())
        oldnode = revsymbol(self.repo, 'tip').hex()
        self.pushrevisions(expected_extra_back=1)
        self.assertNotEqual(oldnode,
                            revsymbol(self.repo, 'tip').hex(),
                            'Revision was not pushed.')
Exemplo n.º 59
0
def _do_case(self, name, stupid):
    subdir = test_util.subdir.get(name, '')
    config = {
        'hgsubversion.stupid': stupid and '1' or '0',
        }
    repo, repo_path = self.load_and_fetch(name,
                                          subdir=subdir,
                                          layout='auto',
                                          config=config)
    assert test_util.repolen(self.repo) > 0, \
        'Repo had no changes, maybe you need to add a subdir entry in test_util?'
    wc2_path = self.wc_path + '_custom'
    checkout_path = repo_path
    if subdir:
        checkout_path += '/' + subdir
    u = test_util.testui(stupid=stupid, layout='custom')
    for branch, path in test_util.custom.get(name, {}).iteritems():
        u.setconfig('hgsubversionbranch', branch, path)
    test_util.hgclone(u,
                      test_util.fileurl(checkout_path),
                      wc2_path,
                      update=False)
    self.repo2 = hg.repository(test_util.testui(), wc2_path)
    self.assertEqual(self.repo.heads(), self.repo2.heads())
Exemplo n.º 60
0
    def test_corruption(self):
        SUCCESS = 0
        FAILURE = 1

        repo, repo_path = self.load_and_fetch('correct.svndump',
                                              layout='single',
                                              subdir='')

        ui = self.ui()

        self.assertEqual(SUCCESS, verify.verify(ui, self.repo, rev='tip'))

        corrupt_source = test_util.fileurl(
            self.load_svndump('corrupt.svndump'))

        repo.ui.setconfig('paths', 'default', corrupt_source)

        ui.pushbuffer()
        code = verify.verify(ui, repo, rev='tip')
        actual = ui.popbuffer()

        actual = actual.replace(corrupt_source, '$REPO')
        actual = set(actual.splitlines())

        expected = set([
            'verifying 78e965230a13 against $REPO@1',
            'missing file: missing-file',
            'wrong flags for: executable-file',
            'wrong flags for: symlink',
            'wrong flags for: regular-file',
            'difference in: another-regular-file',
            'difference in: regular-file',
            'unexpected file: empty-file',
        ])

        self.assertEqual((FAILURE, expected), (code, actual))