Commits

Patrick Mézard committed 3b613d3

svnexternals: fix subrepo peg revision handling (7ef125fa9b35)

hg >= 1.9 appends the revision to check out as a peg revision to source URL
before calling svn. This breaks the case where the external definition already
contains a peg revision. Instead, we assume that "-rR1 svnurl@R2" is equivalent
to "svnurl@R1" which should be almost always true in practice.

The import test has been reversed to avoid issues with stray .pyc: if you
install an hg 1.8 over an hg 1.9, scmutil.pyc may remain and be imported, while
util.py exists in both cases.

Comments (0)

Files changed (1)

hgsubversion/svnexternals.py

 except (ImportError, AttributeError), e:
     subrepo = None
 
+passpegrev = True # see svnsubrepo below
 try:
+    from mercurial.util import canonpath
+except (ImportError, AttributeError):
     from mercurial.scmutil import canonpath
-except (ImportError, AttributeError):
-    from mercurial.util import canonpath
+    passpegrev = False
 
 import util
 
                 svnurl = self._ctx._repo.ui.expandpath('default')
                 svnroot = getsvninfo(util.normalize_url(svnurl))[1]
                 source = resolvesource(self._ui, svnroot, source)
-            if pegrev is not None:
+            # hg < 1.9 svnsubrepo calls "svn checkout" with --rev
+            # only, so peg revisions are correctly used. 1.9 and
+            # higher, append the rev as a peg revision to the source
+            # URL, so we cannot add our own. We assume that "-r10
+            # url@2" will be similar to "url@10" most of the time.
+            if pegrev is not None and passpegrev:
                 source = source + '@' + pegrev
             state = (source, state[1])
             # hg-1.7.4-c19b9282d3a7 introduced the overwrite argument