Skip to content

Commit

Permalink
log: give hint when user forgets "-r"
Browse files Browse the repository at this point in the history
Summary: I do this myself a lot. The "cannot follow file not in parent revision" error isn't very clear that you passed a revision instead of a file name. Add a hint that suggests "-r ..." and "-r ... -f".

Reviewed By: sggutier

Differential Revision: D54873788

fbshipit-source-id: 97549118b87b0553a54ed044ea2d9331d04e5294
  • Loading branch information
muirdm authored and facebook-github-bot committed Mar 14, 2024
1 parent 883251e commit a4c337a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
8 changes: 7 additions & 1 deletion eden/scm/sapling/cmdutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions eden/scm/tests/test-log-hint.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#debugruntest-compatible

$ configure modernclient
$ setconfig tweakdefaults.logdefaultfollow=true

$ newclientrepo
$ drawdag <<EOS
> 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

0 comments on commit a4c337a

Please sign in to comment.