mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
hg debugcrdump should also use globalrev
Summary: This command uses svnrev directly. However once we migrate to www-hg, this fields will go and we can only use globalrev instead. Let's add that and put it behind a config. More context: https://fb.workplace.com/groups/248282915800791/permalink/372855146676900/ Differential Revision: D16560447 fbshipit-source-id: de3100ed1e6cc39eaaeff2fe11af04d2f1e2c41a
This commit is contained in:
parent
bfc5ee0878
commit
01394c9202
@ -150,13 +150,18 @@ def crdump(ui, repo, *revs, **opts):
|
||||
if pbctx:
|
||||
rdata["public_base"] = {"node": hex(pbctx.node())}
|
||||
try:
|
||||
hgsubversion = extensions.find("hgsubversion")
|
||||
svnrev = hgsubversion.util.getsvnrev(pbctx)
|
||||
# There are no abstractions in hgsubversion for doing
|
||||
# it see hgsubversion/svncommands.py:267
|
||||
rdata["public_base"]["svnrev"] = (
|
||||
svnrev.split("@")[1] if svnrev else None
|
||||
)
|
||||
if ui.configbool("hgsubversion", "useglobalrevindebugcrdump"):
|
||||
globalrevs = extensions.find("globalrevs")
|
||||
globalrev = globalrevs.getglobalrev(ui, pbctx)
|
||||
rdata["public_base"]["svnrev"] = globalrev
|
||||
else:
|
||||
hgsubversion = extensions.find("hgsubversion")
|
||||
svnrev = hgsubversion.util.getsvnrev(pbctx)
|
||||
# There are no abstractions in hgsubversion for doing
|
||||
# it see hgsubversion/svncommands.py:267
|
||||
rdata["public_base"]["svnrev"] = (
|
||||
svnrev.split("@")[1] if svnrev else None
|
||||
)
|
||||
except KeyError:
|
||||
pass
|
||||
rdata["patch_file"] = dumppatch(ui, repo, ctx, outdir, contextlines)
|
||||
|
@ -407,6 +407,14 @@ def _revsetglobalrev(repo, subset, x):
|
||||
return subset & smartset.baseset(_lookupglobalrev(repo, globalrev))
|
||||
|
||||
|
||||
def getglobalrev(ui, ctx, defval=None):
|
||||
"""Wrapper around _getglobalrev. See _getglobalrev for more detail."""
|
||||
grev = _getglobalrev(ui, ctx.extra())
|
||||
if grev:
|
||||
return grev
|
||||
return defval
|
||||
|
||||
|
||||
def _getglobalrev(ui, commitextra):
|
||||
grev = commitextra.get(EXTRASGLOBALREVKEY)
|
||||
|
||||
|
@ -25,6 +25,9 @@ Config::
|
||||
# Skip the post-push pull and rebase. This only works in single-writer
|
||||
# scenario and should only be used in HG -> SVN reverse sync.
|
||||
skippostpushpulls = False
|
||||
# In `hg debugcrdump`, it uses svn revision number by default. When enabled,
|
||||
# the command will give globalrev instead.
|
||||
useglobalrevindebugcrdump = False
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
@ -439,6 +442,7 @@ configitem("hgsubversion", "skippostpushpulls", default=False)
|
||||
# If this configuration is true, the `svnrev` template keyword would be
|
||||
# effectively disabled and querying for it would return nothing.
|
||||
configitem("hgsubversion", "disablesvnrevkeyword ", default=False)
|
||||
configitem("hgsubversion", "useglobalrevindebugcrdump ", default=False)
|
||||
|
||||
|
||||
@templatekeyword("svnrev")
|
||||
|
@ -309,6 +309,9 @@ Test basic dump of two commits
|
||||
######## old
|
||||
62000a
|
||||
|
||||
|
||||
|
||||
|
||||
#if jq
|
||||
Test crdump not dumping binaries
|
||||
|
||||
@ -476,3 +479,17 @@ Test non-ASCII characters
|
||||
],
|
||||
"output_directory": "*" (glob)
|
||||
}
|
||||
|
||||
#if jq
|
||||
Test use globalrev instead of svnrev
|
||||
|
||||
$ echo y > Y
|
||||
$ hg commit --config "extensions.commitextras=" -Aqm "commit with globalrev and svnrev" --extra convert_revision="svn:2c7ba8d8-a2f7-0310-a573-de162e16dcc7/tfb/trunk/www@1234567" --extra global_rev="100098765"
|
||||
$ hg phase -pfr '.'
|
||||
$ echo z > Z
|
||||
$ hg commit -Aqm "local commit"
|
||||
$ hg debugcrdump --config 'extensions.hgsubversion=' --config 'extensions.globalrevs=' -r . | jq '.commits[].public_base.svnrev'
|
||||
"1234567"
|
||||
$ hg debugcrdump --config 'extensions.hgsubversion=' --config 'extensions.globalrevs=' --config "hgsubversion.useglobalrevindebugcrdump=True" -r . | jq '.commits[].public_base.svnrev'
|
||||
"100098765"
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user