# HG changeset patch # User Mark Drago # Date 1299591699 18000 # Node ID 0b79cf616e650989cd129304de72b2bd2c22f9e0 # Parent cc27c31ebc282f3fc164e513ee9bbc118034d65d 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. diff -r cc27c31ebc28 -r 0b79cf616e65 mercurial/commands.py --- a/mercurial/commands.py Tue Mar 08 14:55:31 2011 -0600 +++ b/mercurial/commands.py Tue Mar 08 08:41:39 2011 -0500 @@ -4053,7 +4053,7 @@ if rev and node: raise util.Abort(_("please specify just one revision")) - if not rev: + if rev is None or rev == '': rev = node # if we defined a bookmark, we have to remember the original bookmark name diff -r cc27c31ebc28 -r 0b79cf616e65 tests/test-basic.t --- a/tests/test-basic.t Tue Mar 08 14:55:31 2011 -0600 +++ b/tests/test-basic.t Tue Mar 08 08:41:39 2011 -0500 @@ -20,6 +20,22 @@ summary: test +Verify that updating to revision 0 via commands.update() works properly + + $ cat < update_to_rev0.py + > from mercurial import ui, hg, commands + > myui = ui.ui() + > repo = hg.repository(myui, path='.') + > commands.update(myui, repo, rev=0) + > EOF + $ hg up null + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ python ./update_to_rev0.py + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg identify -n + 0 + + Poke around at hashes: $ hg manifest --debug