Submitter | timeless@mozdev.org |
---|---|
Date | Oct. 16, 2015, 7:28 p.m. |
Message ID | <dbd326c55e98a081253a.1445023707@waste.org> |
Download | mbox | patch |
Permalink | /patch/11150/ |
State | Deferred |
Headers | show |
Comments
On Fri, 16 Oct 2015 14:28:27 -0500, timeless wrote: > # HG changeset patch > # User timeless <timeless@mozdev.org> > # Date 1445023325 14400 > # Fri Oct 16 15:22:05 2015 -0400 > # Node ID dbd326c55e98a081253ad6e6d2d8e453c06115fe > # Parent e8f1b728591786143174515ea18089db0df4af90 > help: treat hg help pattern like hg help patterns > > diff --git a/mercurial/help.py b/mercurial/help.py > --- a/mercurial/help.py > +++ b/mercurial/help.py > @@ -513,12 +513,19 @@ > queries += [helpcmd] > if not queries: > queries = (helptopic, helpcmd, helpext, helpextcmd) > - for f in queries: > - try: > - rst = f(name) > + def findtopic(name, queries): > + rst = None > + for f in queries: > + try: > + rst = f(name) > + break > + except error.UnknownCommand: > + pass > + return rst > + for topic in [name, name + 's', name + 'es']: Why not add "pattern" to helptable? I don't think "hg help templat" is valid as long as it doesn't do prefix matching.
There are a dozen cases where this happens. I don't want to add all of the cases manually. I'm not as attached to the +es form (it handles "remotebranch"), but I don't think there's any particular harm in allowing "hg help templat" to work, we're unlikely to create a command called "templat", and if we create a command "template", I don't think it matters if people get help for "templates" instead when they ask for "hg help templat". On Oct 18, 2015 3:54 AM, "Yuya Nishihara" <yuya@tcha.org> wrote: > On Fri, 16 Oct 2015 14:28:27 -0500, timeless wrote: > > # HG changeset patch > > # User timeless <timeless@mozdev.org> > > # Date 1445023325 14400 > > # Fri Oct 16 15:22:05 2015 -0400 > > # Node ID dbd326c55e98a081253ad6e6d2d8e453c06115fe > > # Parent e8f1b728591786143174515ea18089db0df4af90 > > help: treat hg help pattern like hg help patterns > > > > diff --git a/mercurial/help.py b/mercurial/help.py > > --- a/mercurial/help.py > > +++ b/mercurial/help.py > > @@ -513,12 +513,19 @@ > > queries += [helpcmd] > > if not queries: > > queries = (helptopic, helpcmd, helpext, helpextcmd) > > - for f in queries: > > - try: > > - rst = f(name) > > + def findtopic(name, queries): > > + rst = None > > + for f in queries: > > + try: > > + rst = f(name) > > + break > > + except error.UnknownCommand: > > + pass > > + return rst > > + for topic in [name, name + 's', name + 'es']: > > Why not add "pattern" to helptable? I don't think "hg help templat" is > valid > as long as it doesn't do prefix matching. > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel >
On Sun, 2015-10-18 at 10:35 -0400, timeless wrote: > There are a dozen cases where this happens. I don't want to add all > of the > cases manually. I think we should wire in the "did you mean?" functionality instead of special-casing plurals. $ hg commits hg: unknown command 'commits' (did you mean one of commit, uncommit?) Let's look at this for 3.6.
Patch
diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -513,12 +513,19 @@ queries += [helpcmd] if not queries: queries = (helptopic, helpcmd, helpext, helpextcmd) - for f in queries: - try: - rst = f(name) + def findtopic(name, queries): + rst = None + for f in queries: + try: + rst = f(name) + break + except error.UnknownCommand: + pass + return rst + for topic in [name, name + 's', name + 'es']: + rst = findtopic(topic, queries) + if rst: break - except error.UnknownCommand: - pass else: if unknowncmd: raise error.UnknownCommand(name) diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -450,6 +450,11 @@ (use "hg help -v ad" to show built-in aliases and global options) +Test singular help + $ hg help pattern |grep '^[^ ]' + File Name Patterns + """""""""""""""""" + Test command without options $ hg help verify