Mercurial > hgsubversion
changeset 278:60acc38eac96
clone: prefer tip of default to overall tip when updating
author | Martijn Pieters <mj@zopatista.com> |
---|---|
date | Fri, 24 Apr 2009 20:36:38 -0500 |
parents | 3848a7f9b983 |
children | 376ba9399ce6 |
files | tests/test_fetch_branches.py tests/test_util.py wrappers.py |
diffstat | 3 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_fetch_branches.py +++ b/tests/test_fetch_branches.py @@ -6,9 +6,10 @@ import test_util class TestFetchBranches(test_util.TestBase): - def _load_fixture_and_fetch(self, fixture_name, stupid): + def _load_fixture_and_fetch(self, fixture_name, stupid, noupdate=True): return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, - self.wc_path, stupid=stupid) + self.wc_path, stupid=stupid, + noupdate=noupdate) def test_unrelatedbranch(self, stupid=False): repo = self._load_fixture_and_fetch('unrelatedbranch.svndump', stupid) @@ -59,6 +60,15 @@ class TestFetchBranches(test_util.TestBa self.assertEqual(repo['tip'].manifest().keys(), ['alpha', 'beta', 'iota', 'gamma', ]) + def test_branch_tip_update_to_default(self, stupid=False): + repo = self._load_fixture_and_fetch('unorderedbranch.svndump', + stupid, noupdate=False) + self.assertEqual(repo[None].branch(), 'default') + self.assertTrue('tip' not in repo[None].tags()) + + def test_branch_tip_update_to_default_stupid(self): + self.test_branch_tip_update_to_default(True) + def suite(): all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchBranches), ]
--- a/tests/test_util.py +++ b/tests/test_util.py @@ -45,12 +45,12 @@ def load_svndump_fixture(path, fixture_n proc.stdin.flush() proc.communicate() -def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir=''): +def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='', noupdate=True): load_svndump_fixture(repo_path, fixture_name) if subdir: repo_path += '/' + subdir wrappers.clone(None, ui.ui(), source=fileurl(repo_path), - dest=wc_path, stupid=stupid, noupdate=True) + dest=wc_path, stupid=stupid, noupdate=noupdate) repo = hg.repository(ui.ui(), wc_path) return repo
--- a/wrappers.py +++ b/wrappers.py @@ -216,7 +216,13 @@ def clone(orig, ui, source, dest=None, * fp.write("default = %(url)s\nsvn = %(url)s\n" % {'url': svnurl}) fp.close() if (res is None or res == 0) and not opts.get('noupdate', False): - commands.update(ui, repo, repo['tip'].node()) + for test in ('default', 'tip'): + try: + uprev = repo.lookup(test) + break + except: + continue + commands.update(ui, repo, uprev) return res