# HG changeset patch # User Yuya Nishihara # Date 1367938143 -32400 # Node ID 12dbdd348bb0977366200bf96cb6d2afa85faf13 # Parent bcdfb6078b9f5bd34982ef8e2287c3837c033d92 branch: strip whitespace before testing known branch name Because dirstate._branch() strips leading/trailing spaces from .hg/branch, "hg branch ' foo '" should abort if branch "foo" exists in another head. tag command had a similar bug and fixed by 3d0a9c8d7184. diff -r bcdfb6078b9f -r 12dbdd348bb0 mercurial/commands.py --- a/mercurial/commands.py Fri May 10 00:26:39 2013 +0400 +++ b/mercurial/commands.py Tue May 07 23:49:03 2013 +0900 @@ -943,6 +943,9 @@ Returns 0 on success. """ + if label: + label = label.strip() + if not opts.get('clean') and not label: ui.write("%s\n" % repo.dirstate.branch()) return diff -r bcdfb6078b9f -r 12dbdd348bb0 tests/test-branches.t --- a/tests/test-branches.t Fri May 10 00:26:39 2013 +0400 +++ b/tests/test-branches.t Tue May 07 23:49:03 2013 +0900 @@ -68,6 +68,18 @@ abort: '\n' cannot be used in a name [255] +trailing or leading spaces should be stripped before testing duplicates + + $ hg branch 'b ' + abort: a branch of the same name already exists + (use 'hg update' to switch to it) + [255] + + $ hg branch ' b' + abort: a branch of the same name already exists + (use 'hg update' to switch to it) + [255] + verify update will accept invalid legacy branch names $ hg init test-invalid-branch-name