Patchwork D1729: githelp: don't reference 3rd party commands for `git show`

login
register
mail settings
Submitter phabricator
Date Dec. 19, 2017, 5:36 a.m.
Message ID <differential-rev-PHID-DREV-qkg24ta3d6x56nakljgh-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26355/
State Superseded
Headers show

Comments

phabricator - Dec. 19, 2017, 5:36 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `hg show` is a Facebook-ism. Reference functionality in core.
  
  The logic here isn't terrific. But it is better than nothing.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1729

AFFECTED FILES
  hgext/githelp.py
  tests/test-githelp.t

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 28, 2017, 8:55 p.m.
pulkit accepted this revision.
pulkit added a comment.


  I really like the extension added by the series. It will be nice one to have to help people who wanted to consider hg.
  
  Added some inline comments which can be follow-ups if sounds good. There is also some inconsistency in output format which needs to be fixed.
  
  How about having something like `hg githelp concepts` which can describe the basic difference between git and hg?

INLINE COMMENTS

> githelp.py:46
>          s = s.replace('HEAD', '.')
>      # HEAD~ in git is .~1 in mercurial
>      s = re.sub('~$', '~1', s)

Maybe HEAD~ => .^ will be better.

> githelp.py:163
>      else:
>          cmd = Command("add")
>  

We should add about how `hg add` is different from `git add`.

> githelp.py:194
>  def bisect(ui, repo, *args, **kwargs):
>      ui.status(_("See 'hg help bisect' for how to use bisect.\n\n"))
>  

We should align this with other messages.

> githelp.py:351
>      elif opts.get('abort'):
>          ui.status(_("note: hg graft does not have --abort.\n\n"))
>          return

Maybe we should tell about `hg update -C` trick?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1729

To: indygreg, #hg-reviewers, durin42, pulkit
Cc: pulkit, mercurial-devel
phabricator - Dec. 29, 2017, 6:45 p.m.
indygreg added a comment.


  In https://phab.mercurial-scm.org/D1729#30292, @pulkit wrote:
  
  > I really like the extension added by the series. It will be nice one to have to help people who wanted to consider hg.
  >
  > Added some inline comments which can be follow-ups if sounds good. There is also some inconsistency in output format which needs to be fixed.
  >
  > How about having something like `hg githelp concepts` which can describe the basic difference between git and hg?
  
  
  I agree with these points! My immediate goal was getting the extension upstreamed near its current form. It still needs a bit of love.
  
  With regards to the help section, I think `hg help git` should exist and should be a "Mercurial for Git Users" guide or something. It can inform users about the "githelp" extension.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1729

To: indygreg, #hg-reviewers, durin42, pulkit
Cc: pulkit, mercurial-devel
phabricator - Jan. 5, 2018, 3:10 a.m.
krbullock requested changes to this revision.
krbullock added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> githelp.py:883
> +            cmd = Command('status')
>              cmd['--change'] = 'tip'
>          else:

I don't think `tip` is correct here, shouldn't this be `.`?

> githelp.py:887
>              cmd.append('--style status')
>              cmd.append('-r tip')
>      elif len(args) > 0:

Same here, shouldn't use `tip` in newly-added docs or help if we can avoid it.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1729

To: indygreg, #hg-reviewers, durin42, pulkit, krbullock
Cc: krbullock, pulkit, mercurial-devel

Patch

diff --git a/tests/test-githelp.t b/tests/test-githelp.t
--- a/tests/test-githelp.t
+++ b/tests/test-githelp.t
@@ -181,35 +181,35 @@ 
 
 githelp for git show --pretty=format: --name-status
   $ hg githelp -- git show --pretty=format: --name-status
-  hg stat --change tip
+  hg status --change tip
 
 githelp for show with no arguments
   $ hg githelp -- show
-  hg show
+  hg export
 
 githelp for show with a path
   $ hg githelp -- show test_file
-  hg show . test_file
+  hg cat test_file
 
 githelp for show with not a path:
   $ hg githelp -- show rev
-  hg show rev
+  hg export rev
 
 githelp for show with many arguments
   $ hg githelp -- show argone argtwo
-  hg show argone argtwo
+  hg export argone argtwo
   $ hg githelp -- show test_file argone argtwo
-  hg show . test_file argone argtwo
+  hg cat test_file argone argtwo
 
 githelp for show with --unified options
   $ hg githelp -- show --unified=10
-  hg show --config diff.unified=10
+  hg export --config diff.unified=10
   $ hg githelp -- show -U100
-  hg show --config diff.unified=100
+  hg export --config diff.unified=100
 
 githelp for show with a path and --unified
   $ hg githelp -- show -U20 test_file
-  hg show . test_file --config diff.unified=20
+  hg cat test_file --config diff.unified=20
 
 githelp for stash drop without name
   $ hg githelp -- git stash drop
diff --git a/hgext/githelp.py b/hgext/githelp.py
--- a/hgext/githelp.py
+++ b/hgext/githelp.py
@@ -870,23 +870,27 @@ 
     ]
     args, opts = parseoptions(ui, cmdoptions, args)
 
-    cmd = Command('show')
     if opts.get('name_status'):
         if opts.get('pretty') == 'format:':
-            cmd = Command('stat')
+            cmd = Command('status')
             cmd['--change'] = 'tip'
         else:
             cmd = Command('log')
             cmd.append('--style status')
             cmd.append('-r tip')
     elif len(args) > 0:
         if ispath(repo, args[0]):
-            cmd.append('.')
+            cmd = Command('cat')
+        else:
+            cmd = Command('export')
         cmd.extend(args)
         if opts.get('unified'):
             cmd.append('--config diff.unified=%d' % (opts['unified'],))
     elif opts.get('unified'):
+        cmd = Command('export')
         cmd.append('--config diff.unified=%d' % (opts['unified'],))
+    else:
+        cmd = Command('export')
 
     ui.status((str(cmd)), "\n")