mirror of
https://github.com/facebook/sapling.git
synced 2024-12-28 07:33:10 +03:00
gitnode: try using commit extra first
Summary: There are 3 extensions that can provide the `{gitnode}` template: "gitrevset", "fbscmquery", "hggit". The last can read from commit extras. Fix the first two to also read commit extras. At some point we need to unify the implementations. Reviewed By: farnz Differential Revision: D19198979 fbshipit-source-id: 24a0df0df4ceb7a9af9236a7f70babfd54e9802b
This commit is contained in:
parent
cde36527be
commit
e5de1683e4
@ -90,6 +90,12 @@ templatekeyword = registrar.templatekeyword()
|
||||
@templatekeyword("gitnode")
|
||||
def showgitnode(repo, ctx, templ, **args):
|
||||
"""Return the git revision corresponding to a given hg rev"""
|
||||
# Try reading from commit extra first.
|
||||
extra = ctx.extra()
|
||||
if "hg-git-rename-source" in extra:
|
||||
hexnode = extra.get("convert_revision")
|
||||
if hexnode:
|
||||
return hexnode
|
||||
reponame = repo.ui.config("fbscmquery", "reponame")
|
||||
if not reponame:
|
||||
# We don't know who we are, so we can't ask for a translation
|
||||
|
@ -34,6 +34,12 @@ templatekeyword = registrar.templatekeyword()
|
||||
@templatekeyword("gitnode")
|
||||
def showgitnode(repo, ctx, templ, **args):
|
||||
"""Return the git revision corresponding to a given hg rev"""
|
||||
# Try reading from commit extra first.
|
||||
extra = ctx.extra()
|
||||
if "hg-git-rename-source" in extra:
|
||||
hexnode = extra.get("convert_revision")
|
||||
if hexnode:
|
||||
return hexnode
|
||||
binnode = _lookup_node(repo, ctx.hex(), from_scm_type="hg")
|
||||
# templates are expected to return an empty string when no
|
||||
# data exists
|
||||
|
@ -49,3 +49,11 @@ Remove the mapfile so we can ensure the gitnode is from the extras not the mapfi
|
||||
abort: git-mapfile@7e: ambiguous identifier!
|
||||
[255]
|
||||
$ hg log --template "gitnode_notexists {rev}\n" --rev "gitnode(1234567890ab)"
|
||||
|
||||
Try other extensioins that provide "{gitnode}":
|
||||
$ hg log -r 'tip^' --template "{gitnode}\n"
|
||||
7e2a5465ff4e3b992c429bb87a392620a0ac97b7
|
||||
$ hg log -r 'tip^' --template "{gitnode}\n" --config extensions.fbscmquery=
|
||||
7e2a5465ff4e3b992c429bb87a392620a0ac97b7
|
||||
$ hg log -r 'tip^' --template "{gitnode}\n" --config extensions.gitrevset=
|
||||
7e2a5465ff4e3b992c429bb87a392620a0ac97b7
|
||||
|
Loading…
Reference in New Issue
Block a user