From 9ae26181cdf370ef114848c9419e551a96cfe470 Mon Sep 17 00:00:00 2001 From: Laurent Charignon Date: Wed, 17 Jun 2015 16:11:03 -0700 Subject: [PATCH] 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 --- githelp.py | 2 ++ tests/test-githelp.t | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/githelp.py b/githelp.py index de71735602..1e49ba1c9e 100644 --- a/githelp.py +++ b/githelp.py @@ -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', [ diff --git a/tests/test-githelp.t b/tests/test-githelp.t index 3d8b474384..0f27ec5e91 100644 --- a/tests/test-githelp.t +++ b/tests/test-githelp.t @@ -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