Commit ef9caf1c authored by Javier Merino Cacho's avatar Javier Merino Cacho

Upstream version 1.8.6

parent e625b149
repo: f2636cfed11500fdc47d1e3822d8e4a2bd636bf7
node: bd979667611d9df733c61251e7668899f3e77a8f
node: 49d324e11856f5d65bd7f83f7ffb3a2f07bf82c1
branch: stable
tag: 1.8.5
tag: 1.8.6
......@@ -19,3 +19,4 @@ dde1ade36a49d3d0e1b4b8bd384a6797665b5081 1.8.1
38be7a6b6def3298fe9ffff141eb58e1370a53cc 1.8.2
759cafce6becef077fb1a152b554a05ff66b04cd 1.8.3
89997a5fc18163c5f65b83272b4521cdbf29984e 1.8.4
bd979667611d9df733c61251e7668899f3e77a8f 1.8.5
......@@ -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
......@@ -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
......@@ -490,6 +490,9 @@ def svn(ui, repo, subcommand, *args, **opts):
else:
raise
svn.optionalrepo=True
svn.norepo = False
table = {
'genignore': genignore,
'info': info,
......
......@@ -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'):
......
......@@ -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.
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment