commands: pass date-based rev as a hex hash

Summary:
When using the `--date` parameter to `hg update` or `hg revert`,
`cmdutil.finddate` returns the binary node for the target commit.  Passing this
to `scmutil.revsingle` sometimes works, however it's unreliable, as if the
binary node happens to look vaguely like a revset, we will attempt to parse it,
and perhaps fail.

Resolve the ambiguity by converting the binary node to hex.

Reviewed By: quark-zju

Differential Revision: D19902595

fbshipit-source-id: 5eb7b9b029e292a02ccc00f5a465ab7807cd56d5
This commit is contained in:
Mark Thomas 2020-02-14 09:38:02 -08:00 committed by Facebook Github Bot
parent 28564b228d
commit 7f71cd1cda

View File

@ -5405,7 +5405,7 @@ def revert(ui, repo, *pats, **opts):
if opts.get("date"):
if opts.get("rev"):
raise error.Abort(_("you can't specify a revision and a date"))
opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
opts["rev"] = hex(cmdutil.finddate(ui, repo, opts["date"]))
parent, p2 = repo.dirstate.parents()
if not opts.get("rev") and p2 != nullid:
@ -6368,7 +6368,7 @@ def update(
cmdutil.clearunfinished(repo)
if date:
rev = cmdutil.finddate(ui, repo, date)
rev = hex(cmdutil.finddate(ui, repo, date))
if inactive:
brev = None