# HG changeset patch # User Patrick Mezard # Date 1309940552 -7200 # Node ID 3b613d32ef11d50c595332f78a0dcd1da9fb1e86 # Parent 86d124a8768ed81a16ebecab3f0be3d604aeae30 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. diff --git a/hgsubversion/svnexternals.py b/hgsubversion/svnexternals.py --- 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