@@ 12,6 12,7 @@ from mercurial import (
context,
manifest,
match as matchmod,
+ node,
util,
)
from mercurial.node import bin, hex, nullid
@@ 438,6 439,21 @@ class overlaychangelog(overlayrevlog):
)
+class overlaygithandler(object):
+ # This was added to support the {gitnode} keyword in templates for incoming.
+ # For this, falling back to the underlying repository is not necessary.
+
+ def __init__(self, repo):
+ self.repo = repo
+
+ def map_git_get(self, sha):
+ # Normally, the parameter contains the hg hash. However, for incoming
+ # changesets, it contains the git hash, so we can return it as-is
+ # (after sanity-checking that it is the hash of an incoming commit).
+ assert node.bin(sha) in self.repo.revmap
+ return sha
+
+
class overlayrepo(object):
def __init__(self, handler, commits, refs):
self.handler = handler
@@ 472,6 488,8 @@ class overlayrepo(object):
except (AttributeError, ImportError):
pass
+ self.githandler = overlaygithandler(self)
+
def _constructmanifest(self):
return overlaymanifestrevlog(self,
self.handler.repo._constructmanifest())
@@ 95,12 95,10 @@ Load commonly used test logic
+gamma 2
-incoming with a template that uses gitnode shows no git hash, but does not crash
- $ hg incoming -r master --template 'changeset {rev}:{node|short}\ngitnode {gitnode}\n' | grep -v 'no changes found'
+ $ hg incoming -r master --template 'changeset: {rev}:{node|short}\ngitnode: {gitnode}\n' | grep -v 'no changes found'
comparing with $TESTTMP/gitrepo
- changeset 1:9497a4ee62e1
- gitnode
-
+ changeset: 1:9497a4ee62e1
+ gitnode: 9497a4ee62e16ee641860d7677cdb2589ea15554
incoming -r
$ hg incoming -r master | grep -v 'no changes found'