# HG changeset patch # User Durham Goode # Date 1360110173 28800 # Node ID 341868ef0cf6bb3fc9fc4f5b4f34047ba57b5a77 # Parent ba5e71770db261c164e1ac93b4546da98a272e67 bookmark: don't allow integers as bookmark/branch/tag names Bookmarks/branches/tags shouldn't be allowed to be integers because that overlaps with revision numbers. Right now if a user created one they can't use it anyway because the revision numbers take precedence. The check only happens when creating a new bookmark/etc from a command so it shouldn't affect existing bookmarks/branches/tags or importing branches from git. This fix was prompted by us having a user create a bookmark named "404" then accidentally checkout a very old version of our repository. diff -r ba5e71770db2 -r 341868ef0cf6 mercurial/scmutil.py --- a/mercurial/scmutil.py Wed Oct 24 23:09:31 2012 +0200 +++ b/mercurial/scmutil.py Tue Feb 05 16:22:53 2013 -0800 @@ -34,6 +34,11 @@ for c in (':', '\0', '\n', '\r'): if c in lbl: raise util.Abort(_("%r cannot be used in a name") % c) + try: + int(lbl) + raise util.Abort(_("a %s cannot have an integer as its name") % kind) + except ValueError: + pass def checkfilename(f): '''Check that the filename f is an acceptable filename for a tracked file''' diff -r ba5e71770db2 -r 341868ef0cf6 tests/test-bookmarks.t --- a/tests/test-bookmarks.t Wed Oct 24 23:09:31 2012 +0200 +++ b/tests/test-bookmarks.t Tue Feb 05 16:22:53 2013 -0800 @@ -257,6 +257,12 @@ abort: a bookmark cannot have the name of an existing branch [255] +bookmark with integer name + + $ hg bookmark 10 + abort: a bookmark cannot have an integer as its name + [255] + incompatible options $ hg bookmark -m Y -d Z diff -r ba5e71770db2 -r 341868ef0cf6 tests/test-rebase-collapse.t --- a/tests/test-rebase-collapse.t Wed Oct 24 23:09:31 2012 +0200 +++ b/tests/test-rebase-collapse.t Tue Feb 05 16:22:53 2013 -0800 @@ -496,15 +496,15 @@ $ hg ci -Am 'A' adding a - $ hg branch '1' - marked working directory as branch 1 + $ hg branch 'one' + marked working directory as branch one (branches are permanent and global, did you want a bookmark?) $ echo 'b' > b $ hg ci -Am 'B' adding b - $ hg branch '2' - marked working directory as branch 2 + $ hg branch 'two' + marked working directory as branch two (branches are permanent and global, did you want a bookmark?) $ echo 'c' > c $ hg ci -Am 'C' @@ -518,9 +518,9 @@ $ hg tglog @ 3: 'D' | - | o 2: 'C' 2 + | o 2: 'C' two | | - | o 1: 'B' 1 + | o 1: 'B' one |/ o 0: 'A' @@ -546,9 +546,9 @@ |/ o 3: 'D' | - | o 2: 'C' 2 + | o 2: 'C' two | | - | o 1: 'B' 1 + | o 1: 'B' one |/ o 0: 'A' @@ -559,9 +559,9 @@ | o 3: 'D' | - | o 2: 'C' 2 + | o 2: 'C' two | | - | o 1: 'B' 1 + | o 1: 'B' one |/ o 0: 'A'