# HG changeset patch # User Martijn Pieters # Date 1240623398 18000 # Node ID 60acc38eac9648dfcc2af8ce1eff828267a2e294 # Parent 3848a7f9b9837107bad047c55f41f53a83a8c2c1 clone: prefer tip of default to overall tip when updating diff --git a/tests/test_fetch_branches.py b/tests/test_fetch_branches.py --- 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), ] diff --git a/tests/test_util.py b/tests/test_util.py --- 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 diff --git a/wrappers.py b/wrappers.py --- 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