mercurial/bookmarks.py
changeset 24354 194e1e3ebc29
parent 24353 3f6bf9f29e7b
child 24355 ca4b89683078
--- a/mercurial/bookmarks.py	Tue Mar 17 18:20:24 2015 +0900
+++ b/mercurial/bookmarks.py	Tue Mar 17 18:20:24 2015 +0900
@@ -370,13 +370,6 @@
     '''
     if b == '@':
         b = ''
-    # find a unique @ suffix
-    for x in range(1, 100):
-        n = '%s@%d' % (b, x)
-        if n not in localmarks:
-            break
-    else:
-        n = None
     # try to use an @pathalias suffix
     # if an @pathalias already exists, we overwrite (update) it
     if path.startswith("file:"):
@@ -385,8 +378,15 @@
         if u.startswith("file:"):
             u = util.url(u).path
         if path == u:
-            n = '%s@%s' % (b, p)
-    return n
+            return '%s@%s' % (b, p)
+
+    # assign a unique "@number" suffix newly
+    for x in range(1, 100):
+        n = '%s@%d' % (b, x)
+        if n not in localmarks:
+            return n
+
+    return None
 
 def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
     ui.debug("checking for updated bookmarks\n")