Patchwork [3,of,5] bookmark: consistently checknewlabel after checkconflict

login
register
mail settings
Submitter timeless@mozdev.org
Date Jan. 10, 2016, 6:57 p.m.
Message ID <1fb445a08991a9bce47a.1452452270@waste.org>
Download mbox | patch
Permalink /patch/12633/
State Accepted
Headers show

Comments

timeless@mozdev.org - Jan. 10, 2016, 6:57 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1451198555 0
#      Sun Dec 27 06:42:35 2015 +0000
# Node ID 1fb445a08991a9bce47a19b02aa3752df3d3cb5e
# Parent  b15de606bd509eba76554071d9e4e40b1a9bb879
bookmark: consistently checknewlabel after checkconflict
Yuya Nishihara - Jan. 13, 2016, 3:11 p.m.
On Sun, 10 Jan 2016 12:57:50 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1451198555 0
> #      Sun Dec 27 06:42:35 2015 +0000
> # Node ID 1fb445a08991a9bce47a19b02aa3752df3d3cb5e
> # Parent  b15de606bd509eba76554071d9e4e40b1a9bb879
> bookmark: consistently checknewlabel after checkconflict
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1112,8 +1112,6 @@
>                  newact = None
>                  for mark in names:
>                      mark = checkformat(mark)
> -                    if not mark in repo._bookmarks:
> -                        scmutil.checknewlabel(repo, mark, 'bookmark')
>                      if newact is None:
>                          newact = mark
>                      if inactive and mark == repo._activebookmark:
> @@ -1123,6 +1121,8 @@
>                      if rev:
>                          tgt = scmutil.revsingle(repo, rev).node()
>                      checkconflict(repo, mark, cur, force, tgt)
> +                    if not mark in repo._bookmarks:
> +                        scmutil.checknewlabel(repo, mark, 'bookmark')

I would rather do checknewlabel() _before_ checkconflict() because
checknewlabel() is more basic validation. But it would be just a personal
preference.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1112,8 +1112,6 @@ 
                 newact = None
                 for mark in names:
                     mark = checkformat(mark)
-                    if not mark in repo._bookmarks:
-                        scmutil.checknewlabel(repo, mark, 'bookmark')
                     if newact is None:
                         newact = mark
                     if inactive and mark == repo._activebookmark:
@@ -1123,6 +1121,8 @@ 
                     if rev:
                         tgt = scmutil.revsingle(repo, rev).node()
                     checkconflict(repo, mark, cur, force, tgt)
+                    if not mark in repo._bookmarks:
+                        scmutil.checknewlabel(repo, mark, 'bookmark')
                     marks[mark] = tgt
                 if not inactive and cur == marks[newact] and not rev:
                     bookmarks.activate(repo, newact)