Patchwork dispatch: fix so that --help more reliably shows command help (issue4240)

login
register
mail settings
Submitter Prabhu GS
Date July 10, 2014, 9:17 a.m.
Message ID <CAJJU0hPi+P7UabxXs3yht6nO1U4Lujc3W0M9ccgs6KFExBKi-Q@mail.gmail.com>
Download mbox | patch
Permalink /patch/5138/
State Accepted
Headers show

Comments

Prabhu GS - July 10, 2014, 9:17 a.m.
Hi all,

I tried to see what went wrong. So i just started off by looking at what
failed in test-cat.t test.

When I ran the test-cat.t test, I could see the below snippet,

<partial snippet>


I could not really understand why the rev number of the commit changed ?
The test-cat.t test just makes a commit and tries to cat the file from a
revision where the file itself is non-existent.

I could see that the commit revision number changes just with the
mercurial/cmdutil.py patch.
If I revert the mercurial/cmdutil.py patch and test it, the revision number
is not changed and the test passes.


Please help me with a few pointers...


Cheers,
Prabhu



On Wed, Jul 9, 2014 at 7:53 AM, Augie Fackler <raf@durin42.com> wrote:

> On Tue, Jul 01, 2014 at 10:35:55PM +0530, Prabhu Gnana Sundar wrote:
> > # HG changeset patch
> > # User Prabhu Gnana Sundar <pprabhugs@gmail.com>
> > # Date 1404234214 -19800
> > #      Tue Jul 01 22:33:34 2014 +0530
> > # Node ID 43e4cd31fae70005b4680ccb53b51f46b962e5b6
> > # Parent  99db956b88ab699644c99095fecadbc4c83adbfc
> > dispatch: fix so that --help more reliably shows command help (issue4240)
>
> After running tests, I'm dropping this. Please take a look at the
> output of 'make test-execute-bit.t' (among many other breakages).
>
> >
> > After hg 3.0, "hg showconfig --help" was showing the configuration man
> page
> > instead of the 'hg help -c showconfig' output.
> >
> > This patch fixes the 'hg showconfig --help' regression issue by removing
> an
> > unwanted assignement of aliases[0] to cmd and shows the correct command
> > in the first line of help description.
> > Also, added a test case to test 'hg showconfig --help'.
> >
> > diff -r 99db956b88ab -r 43e4cd31fae7 mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py    Sun Jun 01 16:01:01 2014 -0700
> > +++ b/mercurial/cmdutil.py    Tue Jul 01 22:33:34 2014 +0530
> > @@ -39,11 +39,13 @@
> >          if cmd in aliases:
> >              found = cmd
> >          elif not strict:
> > -            for a in aliases:
> > -                if a.startswith(cmd):
> > -                    found = a
> > +            for alias in aliases:
> > +                if alias.startswith(cmd):
> > +                    found = alias
> >                      break
> >          if found is not None:
> > +            aliases = [alias for alias in aliases if alias != cmd]
> > +            aliases.insert(0, cmd)
> >              if aliases[0].startswith("debug") or
> found.startswith("debug"):
> >                  debugchoice[found] = (aliases, table[e])
> >              else:
> > diff -r 99db956b88ab -r 43e4cd31fae7 mercurial/dispatch.py
> > --- a/mercurial/dispatch.py   Sun Jun 01 16:01:01 2014 -0700
> > +++ b/mercurial/dispatch.py   Tue Jul 01 22:33:34 2014 +0530
> > @@ -494,7 +494,6 @@
> >          cmd, args = args[0], args[1:]
> >          aliases, entry = cmdutil.findcmd(cmd, commands.table,
> >                                           ui.configbool("ui", "strict"))
> > -        cmd = aliases[0]
> >          args = aliasargs(entry[0], args)
> >          defaults = ui.config("defaults", cmd)
> >          if defaults:
> > diff -r 99db956b88ab -r 43e4cd31fae7 tests/test-help.t
> > --- a/tests/test-help.t       Sun Jun 01 16:01:01 2014 -0700
> > +++ b/tests/test-help.t       Tue Jul 01 22:33:34 2014 +0530
> > @@ -2085,3 +2085,41 @@
> >    $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
> >
> >  #endif
> > +
> > +
> > +Test showconfig help
> > +
> > +  $ hg showconfig --help
> > +  hg showconfig [-u] [NAME]...
> > +
> > +  aliases: config, debugconfig
> > +
> > +  show combined config settings from all hgrc files
> > +
> > +      With no arguments, print names and values of all config items.
> > +
> > +      With one argument of the form section.name, print just the value
> of that
> > +      config item.
> > +
> > +      With multiple arguments, print names and values of all config
> items with
> > +      matching section names.
> > +
> > +      With --edit, start an editor on the user-level config file. With
> --global,
> > +      edit the system-wide config file. With --local, edit the
> repository-level
> > +      config file.
> > +
> > +      With --debug, the source (filename and line number) is printed
> for each
> > +      config item.
> > +
> > +      See "hg help config" for more information about config files.
> > +
> > +      Returns 0 on success.
> > +
> > +  options:
> > +
> > +   -u --untrusted show untrusted configuration options
> > +   -e --edit      edit user config
> > +   -l --local     edit repository config
> > +   -g --global    edit global config
> > +
> > +  use "hg -v help showconfig" to show the global options
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
>
Simon King - July 10, 2014, 10:15 a.m.
On Thu, Jul 10, 2014 at 10:17 AM, Prabhu GS <pprabhugs@gmail.com> wrote:
> On Wed, Jul 9, 2014 at 7:53 AM, Augie Fackler <raf@durin42.com> wrote:
>>
>> On Tue, Jul 01, 2014 at 10:35:55PM +0530, Prabhu Gnana Sundar wrote:
>> > # HG changeset patch
>> > # User Prabhu Gnana Sundar <pprabhugs@gmail.com>
>> > # Date 1404234214 -19800
>> > #      Tue Jul 01 22:33:34 2014 +0530
>> > # Node ID 43e4cd31fae70005b4680ccb53b51f46b962e5b6
>> > # Parent  99db956b88ab699644c99095fecadbc4c83adbfc
>> > dispatch: fix so that --help more reliably shows command help
>> > (issue4240)
>>
>> After running tests, I'm dropping this. Please take a look at the
>> output of 'make test-execute-bit.t' (among many other breakages).
>>
>
> Hi all,
>
> I tried to see what went wrong. So i just started off by looking at what
> failed in test-cat.t test.
>
> When I ran the test-cat.t test, I could see the below snippet,
>
> <partial snippet>
>
> --- /home/prabhugs/projects/source/hg/tests/test-cat.t
> +++ /home/prabhugs/projects/source/hg/tests/test-cat.t.err
> @@ -17,7 +17,7 @@
>    $ hg cat -r 0 b
>    0
>    $ hg cat -r 1 a
> -  a: no such file in rev 7040230c159c
> +  a: no such file in rev ecd15c2a36c4
>    [1]
>
> </partial snippet>
>
> I could not really understand why the rev number of the commit changed ? The
> test-cat.t test just makes a commit and tries to cat the file from a
> revision where the file itself is non-existent.
>
> I could see that the commit revision number changes just with the
> mercurial/cmdutil.py patch.
> If I revert the mercurial/cmdutil.py patch and test it, the revision number
> is not changed and the test passes.
>
>
> Please help me with a few pointers...
>

The tests often use a default .hgrc file that adds "-d '0 0'" to
various commands so that checkins always appear to have the same date
(so that the hash will be stable). See:

  http://selenic.com/hg/file/3b97a93dc137/tests/run-tests.py#l645

Is it possible that your change breaks [defaults] operation for
commands that are aliased (eg. ci instead of checkin)?

Simon

Patch

--- /home/prabhugs/projects/source/hg/tests/test-cat.t
+++ /home/prabhugs/projects/source/hg/tests/test-cat.t.err
@@ -17,7 +17,7 @@ 
   $ hg cat -r 0 b
   0
   $ hg cat -r 1 a
-  a: no such file in rev *7040230c159c*
+  a: no such file in rev *ecd15c2a36c4*
   [1]

</partial snippet>