def test_push_without_pushing_children(self):
        '''
        Verify that a push of a nontip node, keeps the tip child
        on top of the pushed commit.
        '''

        oldlen = test_util.repolen(self.repo)
        oldtiphash = revsymbol(self.repo, 'default').node()

        changes = [('gamma', 'gamma', 'sometext')]
        newhash1 = self.commitchanges(changes)

        changes = [('delta', 'delta', 'sometext')]
        newhash2 = self.commitchanges(changes)

        # push only the first commit
        repo = self.repo
        hg.update(repo, newhash1)
        commands.push(repo.ui, repo)
        self.assertEqual(test_util.repolen(self.repo), oldlen + 2)

        # verify that the first commit is pushed, and the second is not
        commit2 = revsymbol(self.repo, 'tip')
        self.assertEqual(commit2.files(), [
            'delta',
        ])
        self.assertEqual(util.getsvnrev(commit2), None)
        commit1 = commit2.parents()[0]
        self.assertEqual(commit1.files(), [
            'gamma',
        ])
        prefix = 'svn:' + self.repo.svnmeta().uuid
        self.assertEqual(util.getsvnrev(commit1),
                         prefix + '/branches/the_branch@5')
    def test_push_two_that_modify_same_file(self):
        '''
        Push performs a rebase if two commits touch the same file.
        This test verifies that code path works.
        '''

        oldlen = test_util.repolen(self.repo)
        oldtiphash = self.repo['default'].node()

        changes = [('gamma', 'gamma', 'sometext')]
        newhash = self.commitchanges(changes)
        changes = [('gamma', 'gamma', 'sometext\n moretext'),
                   ('delta', 'delta', 'sometext\n moretext'),
                  ]
        newhash = self.commitchanges(changes)

        repo = self.repo
        hg.update(repo, newhash)
        commands.push(repo.ui, repo)
        self.assertEqual(test_util.repolen(self.repo), oldlen + 2)

        # verify that both commits are pushed
        commit1 = self.repo['tip']
        self.assertEqual(commit1.files(), ['delta', 'gamma'])

        prefix = 'svn:' + self.repo.svnmeta().uuid
        self.assertEqual(util.getsvnrev(commit1),
                         prefix + '/branches/the_branch@6')
        commit2 = commit1.parents()[0]
        self.assertEqual(commit2.files(), ['gamma'])
        self.assertEqual(util.getsvnrev(commit2),
                         prefix + '/branches/the_branch@5')
    def test_push_two_that_modify_same_file(self):
        '''
        Push performs a rebase if two commits touch the same file.
        This test verifies that code path works.
        '''

        oldlen = test_util.repolen(self.repo)
        oldtiphash = revsymbol(self.repo, 'default').node()

        changes = [('gamma', 'gamma', 'sometext')]
        newhash = self.commitchanges(changes)
        changes = [
            ('gamma', 'gamma', 'sometext\n moretext'),
            ('delta', 'delta', 'sometext\n moretext'),
        ]
        newhash = self.commitchanges(changes)

        repo = self.repo
        hg.update(repo, newhash)
        commands.push(repo.ui, repo)
        self.assertEqual(test_util.repolen(self.repo), oldlen + 2)

        # verify that both commits are pushed
        commit1 = revsymbol(self.repo, 'tip')
        self.assertEqual(commit1.files(), ['delta', 'gamma'])

        prefix = 'svn:' + self.repo.svnmeta().uuid
        self.assertEqual(util.getsvnrev(commit1),
                         prefix + '/branches/the_branch@6')
        commit2 = commit1.parents()[0]
        self.assertEqual(commit2.files(), ['gamma'])
        self.assertEqual(util.getsvnrev(commit2),
                         prefix + '/branches/the_branch@5')
    def test_push_without_pushing_children(self):
        '''
        Verify that a push of a nontip node, keeps the tip child
        on top of the pushed commit.
        '''

        oldlen = test_util.repolen(self.repo)
        oldtiphash = self.repo['default'].node()

        changes = [('gamma', 'gamma', 'sometext')]
        newhash1 = self.commitchanges(changes)

        changes = [('delta', 'delta', 'sometext')]
        newhash2 = self.commitchanges(changes)

        # push only the first commit
        repo = self.repo
        hg.update(repo, newhash1)
        commands.push(repo.ui, repo)
        self.assertEqual(test_util.repolen(self.repo), oldlen + 2)

        # verify that the first commit is pushed, and the second is not
        commit2 = self.repo['tip']
        self.assertEqual(commit2.files(), ['delta', ])
        self.assertEqual(util.getsvnrev(commit2), None)
        commit1 = commit2.parents()[0]
        self.assertEqual(commit1.files(), ['gamma', ])
        prefix = 'svn:' + self.repo.svnmeta().uuid
        self.assertEqual(util.getsvnrev(commit1),
                         prefix + '/branches/the_branch@5')
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    config = {}
    for branch, path in test_util.custom.get(name, {}).iteritems():
        config['hgsubversionbranch.%s' % branch] = path
    repo, svnpath = self.load_and_fetch(name,
                                        subdir=subdir,
                                        layout=layout,
                                        config=config)
    assert test_util.repolen(self.repo) > 0
    for i in repo:
        ctx = repo[i]
        self.assertEqual(
            verify.verify(repo.ui, repo, rev=ctx.node(), stupid=True), 0)
        self.assertEqual(
            verify.verify(repo.ui, repo, rev=ctx.node(), stupid=False), 0)

    # check a startrev clone
    if layout == 'single' and name not in _skipshallow:
        self.wc_path += '_shallow'
        shallowrepo = self.fetch(svnpath,
                                 subdir=subdir,
                                 layout='single',
                                 startrev='HEAD')

        self.assertEqual(
            test_util.repolen(shallowrepo), 1,
            "shallow clone should have just one revision, not %d" %
            test_util.repolen(shallowrepo))

        fulltip = repo['tip']
        shallowtip = shallowrepo['tip']

        repo.ui.pushbuffer()
        self.assertEqual(
            0,
            verify.verify(repo.ui,
                          shallowrepo,
                          rev=shallowtip.node(),
                          stupid=True))
        self.assertEqual(
            0,
            verify.verify(repo.ui,
                          shallowrepo,
                          rev=shallowtip.node(),
                          stupid=False))

        stupidui = test_util.testui(stupid=True)
        self.assertEqual(
            verify.verify(stupidui, repo, rev=ctx.node(), stupid=True), 0)
        self.assertEqual(
            verify.verify(stupidui, repo, rev=ctx.node(), stupid=False), 0)

        # viewing diff's of lists of files is easier on the eyes
        self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip),
                                  repo.ui.popbuffer())

        for f in fulltip:
            self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    config = {}
    for branch, path in test_util.custom.get(name, {}).iteritems():
        config['hgsubversionbranch.%s' % branch] = path
    repo, svnpath = self.load_and_fetch(name,
                                        subdir=subdir,
                                        layout=layout,
                                        config=config)
    assert test_util.repolen(self.repo) > 0
    for i in repo:
        ctx = repo[i]
        self.assertEqual(verify.verify(repo.ui, repo, rev=ctx.node(),
                                       stupid=True), 0)
        self.assertEqual(verify.verify(repo.ui, repo, rev=ctx.node(),
                                       stupid=False), 0)

    # check a startrev clone
    if layout == 'single' and name not in _skipshallow:
        self.wc_path += '_shallow'
        shallowrepo = self.fetch(svnpath, subdir=subdir,
                                 layout='single', startrev='HEAD')

        self.assertEqual(test_util.repolen(shallowrepo), 1,
                         "shallow clone should have just one revision, not %d"
                         % test_util.repolen(shallowrepo))

        fulltip = repo['tip']
        shallowtip = shallowrepo['tip']

        repo.ui.pushbuffer()
        self.assertEqual(0, verify.verify(repo.ui, shallowrepo,
                                          rev=shallowtip.node(),
                                          stupid=True))
        self.assertEqual(0, verify.verify(repo.ui, shallowrepo,
                                          rev=shallowtip.node(),
                                          stupid=False))

        stupidui = ui.ui(repo.ui)
        stupidui.config('hgsubversion', 'stupid', True)
        self.assertEqual(verify.verify(stupidui, repo, rev=ctx.node(),
                                       stupid=True), 0)
        self.assertEqual(verify.verify(stupidui, repo, rev=ctx.node(),
                                       stupid=False), 0)

        # viewing diff's of lists of files is easier on the eyes
        self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip),
                                  repo.ui.popbuffer())

        for f in fulltip:
            self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
    def test_branch(self):
        ''' Test 'clone --branch' '''
        ui = self.ui()
        _dispatch(ui, ['init', self.wc_path])
        repo = self.repo
        repo.ui.setconfig('ui', 'username', 'anonymous')

        fpath = os.path.join(self.wc_path, 'it')
        f = file(fpath, 'w')
        f.write('C1')
        f.flush()
        commands.add(ui, repo)
        commands.branch(ui, repo, label="B1")
        commands.commit(ui, repo, message="C1")
        f.write('C2')
        f.flush()
        commands.branch(ui, repo, label="default")
        commands.commit(ui, repo, message="C2")
        f.write('C3')
        f.flush()
        commands.branch(ui, repo, label="B2")
        commands.commit(ui, repo, message="C3")

        self.assertEqual(test_util.repolen(repo), 3)

        branch = 'B1'
        _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
                                '--branch', branch])

        repo2 = hg.repository(ui, self.wc_path + '2')

        self.assertEqual(repo[branch].hex(), repo2['.'].hex())
    def test_update(self):
        ''' Test 'clone --updaterev' '''
        ui = self.ui()
        _dispatch(ui, ['init', self.wc_path])
        repo = self.repo
        repo.ui.setconfig('ui', 'username', 'anonymous')

        fpath = os.path.join(self.wc_path, 'it')
        f = file(fpath, 'w')
        f.write('C1')
        f.flush()
        commands.add(ui, repo)
        commands.commit(ui, repo, message="C1")
        f.write('C2')
        f.flush()
        commands.commit(ui, repo, message="C2")
        f.write('C3')
        f.flush()
        commands.commit(ui, repo, message="C3")

        self.assertEqual(test_util.repolen(repo), 3)

        updaterev = 1
        _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
                                '--updaterev=%s' % updaterev])

        repo2 = hg.repository(ui, self.wc_path + '2')

        self.assertEqual(str(repo[updaterev]), str(repo2['.']))
    def test_update(self):
        ''' Test 'clone --updaterev' '''
        ui = self.ui()
        _dispatch(ui, ['init', '--quiet', self.wc_path])
        repo = self.repo
        repo.ui.setconfig('ui', 'username', 'anonymous')

        fpath = os.path.join(self.wc_path, 'it')
        f = file(fpath, 'w')
        f.write('C1')
        f.flush()
        commands.add(ui, repo)
        commands.commit(ui, repo, message="C1")
        f.write('C2')
        f.flush()
        commands.commit(ui, repo, message="C2")
        f.write('C3')
        f.flush()
        commands.commit(ui, repo, message="C3")

        self.assertEqual(test_util.repolen(repo), 3)

        updaterev = 1
        _dispatch(ui, [
            'clone', '--quiet', self.wc_path, self.wc_path + '2',
            '--updaterev=%s' % updaterev
        ])

        repo2 = hg.repository(ui, self.wc_path + '2')

        self.assertEqual(str(repo[updaterev]), str(repo2['.']))
    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(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())
Beispiel #11
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())
Beispiel #12
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)
 def test_replace_branch_with_branch(self):
     repo = self._load_fixture_and_fetch('replace_branch_with_branch.svndump')
     self.assertEqual(7, test_util.repolen(repo))
     # tip is former topological branch1 being closed
     ctx = repo['tip']
     self.assertEqual('1', ctx.extra().get('close', '0'))
     self.assertEqual('branch1', ctx.branch())
     # r5 is where the replacement takes place
     ctx = repo[5]
     self.assertEqual(set(['a', 'c', 'dir/e', 'dir2/e', 'f', 'g']), set(ctx))
     self.assertEqual('0', ctx.extra().get('close', '0'))
     self.assertEqual('branch1', ctx.branch())
     self.assertEqual('c\n', ctx['c'].data())
     self.assertEqual('d\n', ctx['a'].data())
     self.assertEqual('e\n', ctx['dir/e'].data())
     self.assertEqual('e\n', ctx['dir2/e'].data())
     self.assertEqual('f\n', ctx['f'].data())
     self.assertEqual('g\n', ctx['g'].data())
     for f in ctx:
         self.assertTrue(not ctx[f].renamed())
Beispiel #14
0
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    single = layout == 'single'
    u = ui.ui()
    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)
 def test_replace_branch_with_branch(self):
     repo = self._load_fixture_and_fetch(
         'replace_branch_with_branch.svndump')
     self.assertEqual(7, test_util.repolen(repo))
     # tip is former topological branch1 being closed
     ctx = revsymbol(repo, 'tip')
     self.assertEqual('1', ctx.extra().get('close', '0'))
     self.assertEqual('branch1', ctx.branch())
     # r5 is where the replacement takes place
     ctx = repo[5]
     self.assertEqual(set(['a', 'c', 'dir/e', 'dir2/e', 'f', 'g']),
                      set(ctx))
     self.assertEqual('0', ctx.extra().get('close', '0'))
     self.assertEqual('branch1', ctx.branch())
     self.assertEqual('c\n', ctx['c'].data())
     self.assertEqual('d\n', ctx['a'].data())
     self.assertEqual('e\n', ctx['dir/e'].data())
     self.assertEqual('e\n', ctx['dir2/e'].data())
     self.assertEqual('f\n', ctx['f'].data())
     self.assertEqual('g\n', ctx['g'].data())
     for f in ctx:
         self.assertTrue(not ctx[f].renamed())
Beispiel #16
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())
    def test_branch(self):
        ''' Test 'clone --branch' '''
        ui = self.ui()
        _dispatch(ui, ['init', '--quiet', self.wc_path])
        repo = self.repo
        repo.ui.setconfig('ui', 'username', 'anonymous')

        fpath = os.path.join(self.wc_path, 'it')
        f = file(fpath, 'w')
        f.write('C1')
        f.flush()
        commands.add(ui, repo)
        commands.branch(ui, repo, label="B1")
        commands.commit(ui, repo, message="C1")
        f.write('C2')
        f.flush()
        commands.branch(ui, repo, label="default")
        commands.commit(ui, repo, message="C2")
        f.write('C3')
        f.flush()
        commands.branch(ui, repo, label="B2")
        commands.commit(ui, repo, message="C3")

        self.assertEqual(test_util.repolen(repo), 3)

        branch = 'B1'
        _dispatch(ui, [
            'clone', '--quiet', self.wc_path, self.wc_path + '2', '--branch',
            branch
        ])

        repo2 = hg.repository(ui, self.wc_path + '2')

        self.assertEqual(
            revsymbol(repo, branch).hex(),
            revsymbol(repo2, '.').hex())
Beispiel #18
0
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    config = {}
    u = test_util.testui()
    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, \
        'Repo had no changes, maybe you need to add a subdir entry in test_util?'
    wc2_path = self.wc_path + '_stupid'
    checkout_path = 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(test_util.testui(), wc2_path)
    self.assertEqual(self.repo.heads(), self.repo2.heads())
 def test_files_copied_from_outside_btt(self):
     repo = self._load_fixture_and_fetch(
         'test_files_copied_from_outside_btt.svndump')
     self.assertEqual(node.hex(repo['tip'].node()),
                      '3c78170e30ddd35f2c32faa0d8646ab75bba4f73')
     self.assertEqual(test_util.repolen(repo.changelog), 2)
Beispiel #20
0
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    single = layout == 'single'
    u = test_util.testui()
    config = {}
    if 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)
    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)

    try:
        svncommands.rebuildmeta(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)

    wc3_path = self.wc_path + '_partial'
    src, dest = test_util.hgclone(u,
                                  self.wc_path,
                                  wc3_path,
                                  update=False,
                                  rev=['0'])
    srcrepo = test_util.getlocalpeer(src)
    dest = test_util.getlocalpeer(dest)

    # insert a wrapper that prevents calling changectx.children()
    extensions.wrapfunction(context.changectx, 'children', failfn)

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

    if hgutil.safehasattr(localrepo.localrepository, 'pull'):
        dest.pull(src)
    else:
        # Mercurial >= 3.2
        from mercurial import exchange
        exchange.pull(dest, src)

    # insert a wrapper that prevents calling changectx.children()
    extensions.wrapfunction(context.changectx, 'children', failfn)
    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, srcrepo, dest, u)
Beispiel #21
0
def _do_case(self, name, layout):
    subdir = test_util.subdir.get(name, '')
    single = layout == 'single'
    u = ui.ui()
    config = {}
    if 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)
    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)

    try:
        svncommands.rebuildmeta(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)

    wc3_path = self.wc_path + '_partial'
    src, dest = test_util.hgclone(u,
                                  self.wc_path,
                                  wc3_path,
                                  update=False,
                                  rev=[0])
    srcrepo = test_util.getlocalpeer(src)
    dest = test_util.getlocalpeer(dest)

    # insert a wrapper that prevents calling changectx.children()
    extensions.wrapfunction(context.changectx, 'children', failfn)

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

    if hgutil.safehasattr(localrepo.localrepository, 'pull'):
        dest.pull(src)
    else:
        # Mercurial >= 3.2
        from mercurial import exchange
        exchange.pull(dest, src)

    # insert a wrapper that prevents calling changectx.children()
    extensions.wrapfunction(context.changectx, 'children', failfn)
    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, srcrepo, dest, u)
Beispiel #22
0
 def test_files_copied_from_outside_btt(self):
     repo = self._load_fixture_and_fetch(
         'test_files_copied_from_outside_btt.svndump')
     self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
                      '3c78170e30ddd35f2c32faa0d8646ab75bba4f73')
     self.assertEqual(test_util.repolen(repo), 2)