changeset 817:3b613d32ef11

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.
author Patrick Mezard <pmezard@gmail.com>
date Wed, 06 Jul 2011 10:22:32 +0200
parents 86d124a8768e
children 9aed3bfc92d6
files hgsubversion/svnexternals.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnexternals.py
+++ b/hgsubversion/svnexternals.py
@@ -12,10 +12,12 @@ try:
 except (ImportError, AttributeError), e:
     subrepo = None
 
+passpegrev = True # see svnsubrepo below
 try:
-    from mercurial.scmutil import canonpath
-except (ImportError, AttributeError):
     from mercurial.util import canonpath
+except (ImportError, AttributeError):
+    from mercurial.scmutil import canonpath
+    passpegrev = False
 
 import util
 
@@ -410,7 +412,12 @@ if subrepo:
                 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