# HG changeset patch # User FUJIWARA Katsunori # Date 1426584024 -32400 # Node ID 194e1e3ebc29b1ee8e06c680f975b3a939f78f7e # Parent 3f6bf9f29e7b861f28f39d6c65315984d573a8f8 bookmarks: check @pathalias suffix before available @number for efficiency Before this patch, available "@number" suffix is searched before "@pathalias" suffix, even though the latter has higher priority than the former if the latter exits. This patch checks "@pathalias" suffix before available "@number" for efficiency. When an URL has multiple path definitions, the first one is used for "pathalias" after this patch, even though the last one is used before this patch, because: - this choice can terminate loop immediately for efficiency - such case seems to be rare diff -r 3f6bf9f29e7b -r 194e1e3ebc29 mercurial/bookmarks.py --- 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")