[PATCH] commands.update() now works properly with a revision of 0

Matt Mackall mpm at selenic.com
Mon Mar 7 16:28:49 CST 2011


On Mon, 2011-03-07 at 17:17 -0500, Mark Drago wrote:
> On Mon, Mar 7, 2011 at 16:33, Matt Mackall <mpm at selenic.com> wrote:
> > On Mon, 2011-03-07 at 08:36 -0500, Mark Drago wrote:
> >> # HG changeset patch
> >> # User Mark Drago <markdrago at gmail.com>
> >> # Date 1299504374 18000
> >> # Node ID c3fc4daab4287029efc67f2a9b7b67c20847f027
> >> # Parent  fac040b7e82277b765dfeb46561e130f8c63ed3e
> >> commands.update() now works properly with a revision of 0
> >>
> >> Without this change commands.update() treats an integer 0 as if no revision
> >> was passed and updates to the branch head.  This fix allows an integer 0 to
> >> be detected as a revision number so the working directory is correctly
> >> changed to revision 0 rather than the branch head.
> >
> > This looks fine except for the old-style test. See here for how to write
> > a modern 'unified' test:
> >
> > http://mercurial.selenic.com/wiki/WritingTests#Writing_a_shell_script_test
> 
> I wasn't really confident that I had the unit test correct.  I can't
> write this unit test in bash as the bug only occurs when calling
> commands.update() directly.

It's ugly, but a unified test can build a python script with a "here
document". This can be quite short, as you only need to test the
update(0) step in Python.

>   I could write a test similar to the
> example here: http://mercurial.selenic.com/wiki/WritingTests#Writing_a_Python_unit_test
> .  However, the example there isn't very clear as to how to indicate
> success vs. failure.

Those tests work the same as 'old' tests. If the .out file doesn't match
the output, it's an error. If you arrange that your test is silent on
success, you can omit the .out file.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list