summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavi Merino <vicho@debian.org>2016-05-27 12:02:43 +0200
committerJavi Merino <vicho@debian.org>2016-05-27 12:02:43 +0200
commitef9caf1c5d12cf3a5886c1eb3ff5bb956fdf482f (patch)
tree6260ad2bfe45fcde58dab62e57a86f6b3aac1faa
parente625b14939acf9e8f1c208056e12ec1d1ce7e02c (diff)
Upstream version 1.8.6
-rw-r--r--.hg_archival.txt4
-rw-r--r--.hgtags1
-rw-r--r--hgsubversion/__init__.py80
-rw-r--r--hgsubversion/compathacks.py82
-rw-r--r--hgsubversion/svncommands.py3
-rw-r--r--hgsubversion/svnexternals.py11
-rw-r--r--hgsubversion/util.py40
-rw-r--r--hgsubversion/wrappers.py10
8 files changed, 178 insertions, 53 deletions
diff --git a/.hg_archival.txt b/.hg_archival.txt
index 55aba85..bf70e8c 100644
--- a/.hg_archival.txt
+++ b/.hg_archival.txt
@@ -1,4 +1,4 @@
repo: f2636cfed11500fdc47d1e3822d8e4a2bd636bf7
-node: bd979667611d9df733c61251e7668899f3e77a8f
+node: 49d324e11856f5d65bd7f83f7ffb3a2f07bf82c1
branch: stable
-tag: 1.8.5
+tag: 1.8.6
diff --git a/.hgtags b/.hgtags
index 5eaba6e..bc59dc3 100644
--- a/.hgtags
+++ b/.hgtags
@@ -19,3 +19,4 @@ dde1ade36a49d3d0e1b4b8bd384a6797665b5081 1.8.1
38be7a6b6def3298fe9ffff141eb58e1370a53cc 1.8.2
759cafce6becef077fb1a152b554a05ff66b04cd 1.8.3
89997a5fc18163c5f65b83272b4521cdbf29984e 1.8.4
+bd979667611d9df733c61251e7668899f3e77a8f 1.8.5
diff --git a/hgsubversion/__init__.py b/hgsubversion/__init__.py
index 473e4cb..024c1d4 100644
--- a/hgsubversion/__init__.py
+++ b/hgsubversion/__init__.py
@@ -15,7 +15,7 @@ details.
For more information and instructions, see :hg:`help subversion`.
'''
-testedwith = '2.8.2 3.0.1 3.1 3.2.2 3.3 3.4 3.5 3.6 3.7'
+testedwith = '2.8.2 3.0.1 3.1 3.2.2 3.3 3.4 3.5 3.6 3.7 3.8'
import os
import sys
@@ -42,7 +42,6 @@ demandimport.ignore.extend([
'svn.ra',
])
-from mercurial import templatekw
from mercurial import revset
from mercurial import subrepo
@@ -51,6 +50,7 @@ import util
import svnrepo
import wrappers
import svnexternals
+import compathacks
svnopts = [
('', 'stupid', None,
@@ -165,8 +165,6 @@ def extsetup(ui):
help.helptable.extend(entries)
- templatekw.keywords.update(util.templatekeywords)
-
revset.symbols.update(util.revsets)
subrepo.types['hgsubversion'] = svnexternals.svnsubrepo
@@ -195,7 +193,8 @@ hg.schemes.update({ 'file': _lookup, 'http': svnrepo, 'https': svnrepo,
'svn': svnrepo, 'svn+ssh': svnrepo, 'svn+http': svnrepo,
'svn+https': svnrepo})
-commands.optionalrepo += ' svn'
+if hgutil.safehasattr(commands, 'optionalrepo'):
+ commands.optionalrepo += ' svn'
cmdtable = {
"svn":
@@ -218,3 +217,74 @@ cmdtable = {
# only these methods are public
__all__ = ('cmdtable', 'reposetup', 'uisetup')
+
+# set up templatekeywords (written this way to maintain backwards compatibility
+# until we drop support for 3.7)
+try:
+ from mercurial import registrar
+ templatekeyword = registrar.templatekeyword()
+ loadkeyword = lambda registrarobj: None # no-op
+except (ImportError, AttributeError):
+ # registrar.templatekeyword isn't available = loading by old hg
+
+ templatekeyword = compathacks._funcregistrarbase()
+ templatekeyword._docformat = ":%s: %s"
+
+ # minimum copy from templatekw.loadkeyword
+ def loadkeyword(registrarobj):
+ from mercurial import templatekw
+ for name, func in registrarobj._table.iteritems():
+ templatekw.keywords[name] = func
+
+def _templatehelper(ctx, kw):
+ '''
+ Helper function for displaying information about converted changesets.
+ '''
+ convertinfo = util.getsvnrev(ctx, '')
+
+ if not convertinfo or not convertinfo.startswith('svn:'):
+ return ''
+
+ if kw == 'svnuuid':
+ return convertinfo[4:40]
+ elif kw == 'svnpath':
+ return convertinfo[40:].rsplit('@', 1)[0]
+ elif kw == 'svnrev':
+ return convertinfo[40:].rsplit('@', 1)[-1]
+ else:
+ raise hgutil.Abort('unrecognized hgsubversion keyword %s' % kw)
+
+@templatekeyword('svnrev')
+def svnrevkw(**args):
+ """:svnrev: String. Converted subversion revision number."""
+ return _templatehelper(args['ctx'], 'svnrev')
+
+@templatekeyword('svnpath')
+def svnpathkw(**args):
+ """:svnpath: String. Converted subversion revision project path."""
+ return _templatehelper(args['ctx'], 'svnpath')
+
+@templatekeyword('svnuuid')
+def svnuuidkw(**args):
+ """:svnuuid: String. Converted subversion revision repository identifier."""
+ return _templatehelper(args['ctx'], 'svnuuid')
+
+def listsvnkeys(repo):
+ keys = {}
+ repo = repo.local()
+ metadir = os.path.join(repo.path, 'svn')
+
+ if util.subversionmetaexists(repo.path):
+ w = repo.wlock()
+ try:
+ for key in util.pushkeyfiles:
+ fullpath = os.path.join(metadir, key)
+ if os.path.isfile(fullpath):
+ data = open(fullpath).read()
+
+ # Some of the files could be large, but also quite compressible
+ keys[key] = base85.b85encode(zlib.compress(data))
+ finally:
+ w.release()
+
+ return keys
diff --git a/hgsubversion/compathacks.py b/hgsubversion/compathacks.py
index 9e31bf6..f697def 100644
--- a/hgsubversion/compathacks.py
+++ b/hgsubversion/compathacks.py
@@ -3,6 +3,8 @@
import errno
import sys
+from mercurial import util
+
def branchset(repo):
"""Return the set of branches present in a repo.
@@ -67,3 +69,83 @@ def filectxfn_deleted_reraise(memctx):
return None
# preserve traceback info
raise exc_info[0], exc_info[1], exc_info[2]
+
+# copied from hg 3.8
+class _funcregistrarbase(object):
+ """Base of decorator to register a fuction for specific purpose
+
+ This decorator stores decorated functions into own dict 'table'.
+
+ The least derived class can be defined by overriding 'formatdoc',
+ for example::
+
+ class keyword(_funcregistrarbase):
+ _docformat = ":%s: %s"
+
+ This should be used as below:
+
+ keyword = registrar.keyword()
+
+ @keyword('bar')
+ def barfunc(*args, **kwargs):
+ '''Explanation of bar keyword ....
+ '''
+ pass
+
+ In this case:
+
+ - 'barfunc' is stored as 'bar' in '_table' of an instance 'keyword' above
+ - 'barfunc.__doc__' becomes ":bar: Explanation of bar keyword"
+ """
+ def __init__(self, table=None):
+ if table is None:
+ self._table = {}
+ else:
+ self._table = table
+
+ def __call__(self, decl, *args, **kwargs):
+ return lambda func: self._doregister(func, decl, *args, **kwargs)
+
+ def _doregister(self, func, decl, *args, **kwargs):
+ name = self._getname(decl)
+
+ if func.__doc__ and not util.safehasattr(func, '_origdoc'):
+ doc = func.__doc__.strip()
+ func._origdoc = doc
+ func.__doc__ = self._formatdoc(decl, doc)
+
+ self._table[name] = func
+ self._extrasetup(name, func, *args, **kwargs)
+
+ return func
+
+ def _parsefuncdecl(self, decl):
+ """Parse function declaration and return the name of function in it
+ """
+ i = decl.find('(')
+ if i >= 0:
+ return decl[:i]
+ else:
+ return decl
+
+ def _getname(self, decl):
+ """Return the name of the registered function from decl
+
+ Derived class should override this, if it allows more
+ descriptive 'decl' string than just a name.
+ """
+ return decl
+
+ _docformat = None
+
+ def _formatdoc(self, decl, doc):
+ """Return formatted document of the registered function for help
+
+ 'doc' is '__doc__.strip()' of the registered function.
+ """
+ return self._docformat % (decl, doc)
+
+ def _extrasetup(self, name, func):
+ """Execute exra setup for registered function, if needed
+ """
+ pass
diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py
index 01eb11f..abd93c7 100644
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -490,6 +490,9 @@ def svn(ui, repo, subcommand, *args, **opts):
else:
raise
+svn.optionalrepo=True
+svn.norepo = False
+
table = {
'genignore': genignore,
'info': info,
diff --git a/hgsubversion/svnexternals.py b/hgsubversion/svnexternals.py
index 0297f43..f738aa2 100644
--- a/hgsubversion/svnexternals.py
+++ b/hgsubversion/svnexternals.py
@@ -386,10 +386,17 @@ def parse(ui, ctx):
raise hgutil.Abort(_('unknown externals modes: %s') % mode)
return external
+_notset = object()
+
class svnsubrepo(subrepo.svnsubrepo):
- def __init__(self, ctx, path, state):
+ def __init__(self, ctx, path, state, allowcreate=_notset):
state = (state[0].split(':', 1)[1], state[1])
- super(svnsubrepo, self).__init__(ctx, path, state)
+ if allowcreate is _notset:
+ # Mercurial 3.7 and earlier
+ super(svnsubrepo, self).__init__(ctx, path, state)
+ else:
+ # Mercurial 3.8 and later
+ super(svnsubrepo, self).__init__(ctx, path, state, allowcreate)
# Mercurial 3.3+ set 'ui' rather than '_ui' -- set that and use 'ui'
# everywhere to maintain compatibility across versions
if not hgutil.safehasattr(self, 'ui'):
diff --git a/hgsubversion/util.py b/hgsubversion/util.py
index b833662..0a157c2 100644
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -72,7 +72,7 @@ def gcdisable(orig):
def parentrev(ui, repo, meta, hashes):
"""Find the svn parent revision of the repo's dirstate.
"""
- workingctx = repo.parents()[0]
+ workingctx = repo[None].parents()[0]
outrev = outgoing_revisions(repo, hashes, workingctx.node())
if outrev:
workingctx = repo[outrev[-1]].parents()[0]
@@ -307,48 +307,10 @@ def issamefile(parentctx, childctx, f):
# parentctx is not an ancestor of childctx, files are unrelated
return False
-
def getsvnrev(ctx, defval=None):
'''Extract SVN revision from commit metadata'''
return ctx.extra().get('convert_revision', defval)
-
-def _templatehelper(ctx, kw):
- '''
- Helper function for displaying information about converted changesets.
- '''
- convertinfo = getsvnrev(ctx, '')
-
- if not convertinfo or not convertinfo.startswith('svn:'):
- return ''
-
- if kw == 'svnuuid':
- return convertinfo[4:40]
- elif kw == 'svnpath':
- return convertinfo[40:].rsplit('@', 1)[0]
- elif kw == 'svnrev':
- return convertinfo[40:].rsplit('@', 1)[-1]
- else:
- raise hgutil.Abort('unrecognized hgsubversion keyword %s' % kw)
-
-def svnrevkw(**args):
- """:svnrev: String. Converted subversion revision number."""
- return _templatehelper(args['ctx'], 'svnrev')
-
-def svnpathkw(**args):
- """:svnpath: String. Converted subversion revision project path."""
- return _templatehelper(args['ctx'], 'svnpath')
-
-def svnuuidkw(**args):
- """:svnuuid: String. Converted subversion revision repository identifier."""
- return _templatehelper(args['ctx'], 'svnuuid')
-
-templatekeywords = {
- 'svnrev': svnrevkw,
- 'svnpath': svnpathkw,
- 'svnuuid': svnuuidkw,
-}
-
def revset_fromsvn(repo, subset, x):
'''``fromsvn()``
Select changesets that originate from Subversion.
diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py
index f46c7bc..8a74ed7 100644
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -128,7 +128,7 @@ def findcommonoutgoing(repo, other, onlyheads=None, force=False,
# split off #rev; TODO implement --revision/#rev support
svn = other.svn
meta = repo.svnmeta(svn.uuid, svn.subdir)
- parent = repo.parents()[0].node()
+ parent = repo[None].parents()[0].node()
hashes = meta.revmap.hashes()
common, heads = util.outgoing_common_and_heads(repo, hashes, parent)
outobj = getattr(discovery, 'outgoing', None)
@@ -147,7 +147,7 @@ def findoutgoing(repo, dest=None, heads=None, force=False):
# svnurl, revs, checkout = util.parseurl(dest.svnurl, heads)
svn = dest.svn
meta = repo.svnmeta(svn.uuid, svn.subdir)
- parent = repo.parents()[0].node()
+ parent = repo[None].parents()[0].node()
hashes = meta.revmap.hashes()
return util.outgoing_revisions(repo, hashes, parent)
@@ -160,7 +160,7 @@ def diff(orig, ui, repo, *args, **opts):
meta = repo.svnmeta()
hashes = meta.revmap.hashes()
if not opts.get('rev', None):
- parent = repo.parents()[0]
+ parent = repo[None].parents()[0]
o_r = util.outgoing_revisions(repo, hashes, parent.node())
if o_r:
parent = repo[o_r[-1]].parents()[0]
@@ -212,7 +212,7 @@ def push(repo, dest, force, revs):
# Strategy:
# 1. Find all outgoing commits from this head
- if len(repo.parents()) != 1:
+ if len(repo[None].parents()) != 1:
ui.status('Cowardly refusing to push branch merge\n')
return 0 # results in nonzero exit status, see hg's commands.py
workingrev = repo[None].parents()[0]
@@ -557,7 +557,7 @@ def rebase(orig, ui, repo, **opts):
"""
extra['branch'] = ctx.branch()
extrafn = opts.get('svnextrafn', extrafn2)
- sourcerev = opts.get('svnsourcerev', repo.parents()[0].node())
+ sourcerev = opts.get('svnsourcerev', repo[None].parents()[0].node())
meta = repo.svnmeta()
hashes = meta.revmap.hashes()
o_r = util.outgoing_revisions(repo, hashes, sourcerev=sourcerev)