There will be about 1h of downtime on 2020-03-02 at 13:00 UTC+1 (change of servers and upgrade to Heptapod 0.20.0 final)

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 ( ...@@ -12,6 +12,7 @@ from mercurial import (
context, context,
manifest, manifest,
match as matchmod, match as matchmod,
util, util,
) )
from mercurial.node import bin, hex, nullid from mercurial.node import bin, hex, nullid
...@@ -438,6 +439,21 @@ class overlaychangelog(overlayrevlog): ...@@ -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): class overlayrepo(object):
def __init__(self, handler, commits, refs): def __init__(self, handler, commits, refs):
self.handler = handler self.handler = handler
...@@ -472,6 +488,8 @@ class overlayrepo(object): ...@@ -472,6 +488,8 @@ class overlayrepo(object):
except (AttributeError, ImportError): except (AttributeError, ImportError):
pass pass
self.githandler = overlaygithandler(self)
def _constructmanifest(self): def _constructmanifest(self):
return overlaymanifestrevlog(self, return overlaymanifestrevlog(self,
self.handler.repo._constructmanifest()) self.handler.repo._constructmanifest())
...@@ -95,12 +95,10 @@ Load commonly used test logic ...@@ -95,12 +95,10 @@ Load commonly used test logic
+gamma 2 +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 comparing with $TESTTMP/gitrepo
changeset 1:9497a4ee62e1 changeset: 1:9497a4ee62e1
gitnode gitnode: 9497a4ee62e16ee641860d7677cdb2589ea15554
incoming -r incoming -r
$ hg incoming -r master | grep -v 'no changes found' $ 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