[PATCH stable] branch: strip whitespace before testing known branch name
Augie Fackler
raf at durin42.com
Thu May 9 08:49:09 CDT 2013
On Wed, May 08, 2013 at 07:45:56AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1367938143 -32400
> # Tue May 07 23:49:03 2013 +0900
> # Branch stable
> # Node ID f42a6337cac2c3920fb7587797ada022c1141182
> # Parent 0a12e5f3a979ee302dc10647483200df00a105ab
> branch: strip whitespace before testing known branch name
LGTM, but my paranoia wants either mpm to see this and ack it, or
another crew member to do so before queueing this for stable, since it
is technically a behavior change (even though it strikes me as a bug
fix in light of 3d0a9c8d7184.)
>
> 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 --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -943,6 +943,9 @@ def branch(ui, repo, label=None, **opts)
>
> 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 --git a/tests/test-branches.t b/tests/test-branches.t
> --- a/tests/test-branches.t
> +++ b/tests/test-branches.t
> @@ -68,6 +68,18 @@ invalid characters
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list