Patchwork [3,of,4] commands.bookmarks: move cur initialization to inside names block

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 19, 2013, 8:45 p.m.
Message ID <5efde1fac081f2271fc2.1384893944@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/3070/
State Superseded, archived
Headers show

Comments

Siddharth Agarwal - Nov. 19, 2013, 8:45 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1384893737 28800
#      Tue Nov 19 12:42:17 2013 -0800
# Node ID 5efde1fac081f2271fc2d97189506aa61cd908be
# Parent  d018c7466c66d710dccc2ede1b10e79b02de01c1
commands.bookmarks: move cur initialization to inside names block

Not only is cur not used outside this block, this is also more correct because
we now fetch the current node while the wlock is held.
David Soria Parra - Nov. 21, 2013, 10:08 p.m.
On 11/19/13, 12:45 PM, "Siddharth Agarwal" <sid0@fb.com> wrote:

># HG changeset patch
># User Siddharth Agarwal <sid0@fb.com>
># Date 1384893737 28800
>#      Tue Nov 19 12:42:17 2013 -0800
># Node ID 5efde1fac081f2271fc2d97189506aa61cd908be
># Parent  d018c7466c66d710dccc2ede1b10e79b02de01c1
>commands.bookmarks: move cur initialization to inside names block
>
>Not only is cur not used outside this block, this is also more correct
>because
>we now fetch the current node while the wlock is held.
>
>diff --git a/mercurial/commands.py b/mercurial/commands.py
>--- a/mercurial/commands.py
>+++ b/mercurial/commands.py
>@@ -808,7 +808,6 @@
>     inactive = opts.get('inactive')
> 
>     hexfn = ui.debugflag and hex or short
>-    cur   = repo.changectx('.').node()
> 
>     def checkformat(mark):
>         mark = mark.strip()
>@@ -889,6 +888,7 @@
>                 marks.write()
> 
>             elif names:
>+                cur = repo.changectx('.').node()

Before that patch it was obvious that cur is always initialized when
checkconflict() (which uses cur) is called but now it¹s not anymore.
Can we pass cur into checkconflict().

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -808,7 +808,6 @@ 
     inactive = opts.get('inactive')
 
     hexfn = ui.debugflag and hex or short
-    cur   = repo.changectx('.').node()
 
     def checkformat(mark):
         mark = mark.strip()
@@ -889,6 +888,7 @@ 
                 marks.write()
 
             elif names:
+                cur = repo.changectx('.').node()
                 newact = None
                 for mark in names:
                     mark = checkformat(mark)