Commit 2be33603 authored by Manuel Jacob's avatar Manuel Jacob

overlay: support {gitnode} keyword in templates for incoming changes

Fixes #239.
parent 9e47dd1088ef
Pipeline #13017 passed with stages
in 3 minutes and 21 seconds
......@@ -12,6 +12,7 @@ from mercurial import (
match as matchmod,
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):
self.githandler = overlaygithandler(self)
def _constructmanifest(self):
return overlaymanifestrevlog(self,
......@@ -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
changeset: 1:9497a4ee62e1
gitnode: 9497a4ee62e16ee641860d7677cdb2589ea15554
incoming -r
$ hg incoming -r master | grep -v 'no changes found'
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