Clone should update to 'default' before 'tip'

Create issue
Issue #78 resolved
Martijn Pieters created an issue

When the last revision in a subversion repo is on a branch, the tip (correctly) points to that revision.

However, hg clone svn+... will update to 'tip' regardless, unlike regular hg clone, which will update to 'default' before 'tip'.

I have a fix available in my patchqueue:

http://bitbucket.org/mjpieters/hgsubversion-mq/src/tip/update-to-default-before-tip-on-clone.patch

Comments (6)

  1. Martijn Pieters reporter

    Here is the same change as a diff:

    diff -r 5278817fe8a1 -r 4bae04655a24 tests/test_fetch_branches.py
    --- a/tests/test_fetch_branches.py      Tue Apr 21 18:31:17 2009 -0400
    +++ b/tests/test_fetch_branches.py      Thu Apr 23 14:48:22 2009 +0200
    @@ -6,9 +6,10 @@
     
     
     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 @@
             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 -r 5278817fe8a1 -r 4bae04655a24 tests/test_util.py
    --- a/tests/test_util.py        Tue Apr 21 18:31:17 2009 -0400
    +++ b/tests/test_util.py        Thu Apr 23 14:48:22 2009 +0200
    @@ -45,12 +45,12 @@
         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 -r 5278817fe8a1 -r 4bae04655a24 wrappers.py
    --- a/wrappers.py       Tue Apr 21 18:31:17 2009 -0400
    +++ b/wrappers.py       Thu Apr 23 14:48:22 2009 +0200
    @@ -216,7 +216,13 @@
                 fp.write("default = %(url)s\nsvn = %(url)s\n" % {'url': svnurl.replace('%', '%%')})
                 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
     
    
    
  2. Log in to comment