https://bitbucket.org/durin42/hg-git/commits/ae6b1ba7482963bc9de51f299891e99005794e4e/raw https://bitbucket.org/durin42/hg-git/commits/143b7511eadbea7507d847c805241a6db290ffe7/raw https://bitbucket.org/durin42/hg-git/commits/8d00fde45adbc6c3c0ccab8e362b5f5c36c171e6/raw # HG changeset patch # User Alain Leufroy # Date 1541695757 -3600 # Node ID ae6b1ba7482963bc9de51f299891e99005794e4e # Parent 6ae26ba7b928019e48dd1c73358c18d6dd2d86f3 compat: fix for hg 4.8 089fc0db0954 introduced a new `createopts` parameter. `hggit` does not support repository creation, so we can just ignore it. diff --git a/hggit/gitrepo.py b/hggit/gitrepo.py --- a/hggit/gitrepo.py +++ b/hggit/gitrepo.py @@ -13,7 +13,7 @@ class gitrepo(peerrepository): - def __init__(self, ui, path, create, intents=None): + def __init__(self, ui, path, create, intents=None, **kwargs): if create: # pragma: no cover raise error.Abort('Cannot create a git repository.') self._ui = ui # HG changeset patch # User Kevin Bullock # Date 1543713965 21600 # Node ID 143b7511eadbea7507d847c805241a6db290ffe7 # Parent ae6b1ba7482963bc9de51f299891e99005794e4e compat: glob some verify output that changed in hg 4.8 diff --git a/tests/test-push-r.t b/tests/test-push-r.t --- a/tests/test-push-r.t +++ b/tests/test-push-r.t @@ -64,7 +64,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 1 files, 1 changesets, 1 total revisions + *1 changesets* (glob) pushing to test-1 searching for changes adding changesets @@ -75,7 +75,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 1 files, 2 changesets, 2 total revisions + *2 changesets* (glob) pushing to test-2 searching for changes adding changesets @@ -86,7 +86,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 1 files, 3 changesets, 3 total revisions + *3 changesets* (glob) pushing to test-3 searching for changes adding changesets @@ -97,7 +97,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 1 files, 4 changesets, 4 total revisions + *4 changesets* (glob) pushing to test-4 searching for changes adding changesets @@ -108,7 +108,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 1 files, 2 changesets, 2 total revisions + *2 changesets* (glob) pushing to test-5 searching for changes adding changesets @@ -119,7 +119,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 1 files, 3 changesets, 3 total revisions + *3 changesets* (glob) pushing to test-6 searching for changes adding changesets @@ -130,7 +130,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 2 files, 4 changesets, 5 total revisions + *4 changesets* (glob) pushing to test-7 searching for changes adding changesets @@ -141,7 +141,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 3 files, 5 changesets, 6 total revisions + *5 changesets* (glob) pushing to test-8 searching for changes adding changesets @@ -152,7 +152,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 2 files, 5 changesets, 5 total revisions + *5 changesets* (glob) $ cd test-8 $ hg pull ../test-7 pulling from ../test-7 @@ -168,4 +168,4 @@ checking manifests crosschecking files in changesets and manifests checking files - 4 files, 9 changesets, 7 total revisions + *9 changesets* (glob) # HG changeset patch # User Kevin Bullock # Date 1543713996 21600 # Node ID 8d00fde45adbc6c3c0ccab8e362b5f5c36c171e6 # Parent 143b7511eadbea7507d847c805241a6db290ffe7 compat: update how we register gitnode template keyword diff --git a/hggit/__init__.py b/hggit/__init__.py --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -94,9 +94,11 @@ command = registrar.command(cmdtable) configitem = registrar.configitem(configtable) compat.registerconfigs(configitem) + templatekeyword = registrar.templatekeyword() except (ImportError, AttributeError): command = cmdutil.command(cmdtable) + templatekeyword = compat.templatekeyword() # support for `hg clone git://github.com/defunkt/facebox.git` # also hg clone git+ssh://git@github.com/schacon/simplegit.git @@ -207,7 +209,6 @@ def extsetup(ui): - templatekw.keywords.update({'gitnode': gitnodekw}) revset.symbols.update({ 'fromgit': revset_fromgit, 'gitnode': revset_gitnode }) @@ -455,12 +456,30 @@ raise LookupError(rev, git.map_file, _('ambiguous identifier')) -def gitnodekw(**args): - """:gitnode: String. The Git changeset identification hash, as a 40 hexadecimal -digit string.""" - node = args['ctx'] - repo = args['repo'] +def _gitnodekw(node, repo): gitnode = repo.githandler.map_git_get(node.hex()) if gitnode is None: gitnode = '' return gitnode + + +if (hgutil.safehasattr(templatekw, 'templatekeyword') and + hgutil.safehasattr(templatekw.templatekeyword._table['node'], + '_requires')): + @templatekeyword('gitnode', requires={'ctx', 'repo'}) + def gitnodekw(context, mapping): + """:gitnode: String. The Git changeset identification hash, as a + 40 hexadecimal digit string.""" + node = context.resource(mapping, 'ctx') + repo = context.resource(mapping, 'repo') + return _gitnodekw(node, repo) + +else: + # COMPAT: hg < 4.6 - templatekeyword API changed + @templatekeyword('gitnode') + def gitnodekw(**args): + """:gitnode: String. The Git changeset identification hash, as a + 40 hexadecimal digit string.""" + node = args['ctx'] + repo = args['repo'] + return _gitnodekw(node, repo) diff --git a/hggit/compat.py b/hggit/compat.py --- a/hggit/compat.py +++ b/hggit/compat.py @@ -2,6 +2,7 @@ bookmarks, context, phases, + templatekw, url, util as hgutil, ) @@ -192,3 +193,14 @@ if hasconfigitems: return getconfig(section, item) return getconfig(section, item, CONFIG_DEFAULTS[section][item]) + + +class templatekeyword(object): + def __init__(self): + self._table = {} + + def __call__(self, name): + def decorate(func): + templatekw.keywords.update({name: func}) + return func + return decorate