githelp: revspec ending in "~" in git becomes "~1" in mercurial

Summary:
Before this patch: hg githelp -- reset HEAD~ returned hg reset .~ which was
wrong. With this patch it retuns hg reset .~1.

Test Plan: added a test

Reviewers: mitrandir, durham

Subscribers: scottf

Differential Revision: https://phabricator.fb.com/D2166551
This commit is contained in:
Laurent Charignon 2015-06-17 16:11:03 -07:00
parent a2baee7984
commit 9ae26181cd
2 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,8 @@ def convert(s):
return s[7:]
if 'HEAD' in s:
s = s.replace('HEAD', '.')
# HEAD~ in git is .~1 in mercurial
s = re.sub('~$', '~1', s)
return s
@command('^githelp|git', [

View File

@ -126,3 +126,11 @@ githelp for checkout with an argument that's both a file and a revision
githelp for grep with pattern and path
$ hg githelp -- grep shrubbery flib/intern/
hg grep shrubbery flib/intern/
githelp for reset, checking ~ in git becomes ~1 in mercurial
$ hg githelp -- reset HEAD~
hg reset .~1
$ hg githelp -- reset HEAD^
hg reset .^
$ hg githelp -- reset HEAD~3
hg reset .~3