Patchwork [03,of,10] bookmark: use 'divergent2delete' in 'scmutil.cleanupnode'

login
register
mail settings
Submitter Boris Feld
Date July 15, 2017, 11:42 a.m.
Message ID <2cb988ee601bd857ed1f.1500118971@FB>
Download mbox | patch
Permalink /patch/22396/
State Accepted
Headers show

Comments

Boris Feld - July 15, 2017, 11:42 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499706613 -7200
#      Mon Jul 10 19:10:13 2017 +0200
# Node ID 2cb988ee601bd857ed1fe29d1cc36acf1617ac5f
# Parent  95035db0c9c8e55bf75165d098e38286784e4a6c
# EXP-Topic tr.changes.bookmarks
bookmark: use 'divergent2delete' in 'scmutil.cleanupnode'

Patch

diff -r 95035db0c9c8 -r 2cb988ee601b mercurial/scmutil.py
--- a/mercurial/scmutil.py	Mon Jul 10 19:08:17 2017 +0200
+++ b/mercurial/scmutil.py	Mon Jul 10 19:10:13 2017 +0200
@@ -592,14 +592,13 @@ 
     with repo.transaction('cleanup') as tr:
         # Move bookmarks
         bmarks = repo._bookmarks
-        bmarkchanged = False
+        bmarkchanges = []
         allnewnodes = [n for ns in mapping.values() for n in ns]
         for oldnode, newnodes in mapping.items():
             oldbmarks = repo.nodebookmarks(oldnode)
             if not oldbmarks:
                 continue
             from . import bookmarks # avoid import cycle
-            bmarkchanged = True
             if len(newnodes) > 1:
                 # usually a split, take the one with biggest rev number
                 newnode = next(repo.set('max(%ln)', newnodes)).node()
@@ -620,10 +619,12 @@ 
                                    allnewnodes, newnode, oldnode)
             deletenodes = _containsnode(repo, deleterevs)
             for name in oldbmarks:
-                bmarks[name] = newnode
-                bookmarks.deletedivergent(repo, deletenodes, name)
-        if bmarkchanged:
-            bmarks.recordchange(tr)
+                bmarkchanges.append((name, newnode))
+                for b in bookmarks.divergent2delete(repo, deletenodes, name):
+                    bmarkchanges.append((b, None))
+
+        if bmarkchanges:
+            bmarks.applychanges(repo, tr, bmarkchanges)
 
         # Obsolete or strip nodes
         if obsolete.isenabled(repo, obsolete.createmarkersopt):