diff --git a/eden/scm/sapling/cmdutil.py b/eden/scm/sapling/cmdutil.py index 30d698cabab56..f6d631e109ea2 100644 --- a/eden/scm/sapling/cmdutil.py +++ b/eden/scm/sapling/cmdutil.py @@ -3045,8 +3045,14 @@ def strategy_follow(): if os.path.exists(repo.wjoin(f)): continue else: + hint = None + if len(pats) == 1 and pats[0] in repo: + hint = _( + """did you mean "@prog@ log -r '%s'", or "@prog@ log -r '%s' -f" to follow history?""" + ) % (pats[0], pats[0]) raise error.Abort( - _("cannot follow file not in parent " 'revision: "%s"') % f + _("cannot follow file not in parent " 'revision: "%s"') % f, + hint=hint, ) # follow() revset interprets its file argument as a diff --git a/eden/scm/tests/test-log-hint.t b/eden/scm/tests/test-log-hint.t new file mode 100644 index 0000000000000..c883c9bba6362 --- /dev/null +++ b/eden/scm/tests/test-log-hint.t @@ -0,0 +1,34 @@ +#debugruntest-compatible + + $ configure modernclient + $ setconfig tweakdefaults.logdefaultfollow=true + + $ newclientrepo + $ drawdag < B + > | + > A + > EOS + $ hg go -q $B + + $ hg log tip + abort: cannot follow file not in parent revision: "tip" + (did you mean "hg log -r 'tip'", or "hg log -r 'tip' -f" to follow history?) + [255] + + $ hg log -r 'tip' + commit: 112478962961 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: B + + $ hg log -r 'tip' -f + commit: 112478962961 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: B + + commit: 426bada5c675 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: A