Patchwork [12,of,12] bookmarks: use 'applychanges' for bookmark update

login
register
mail settings
Submitter Boris Feld
Date July 14, 2017, 5:54 p.m.
Message ID <c8af08d67851fae61c1c.1500054850@FB>
Download mbox | patch
Permalink /patch/22371/
State Accepted
Headers show

Comments

Boris Feld - July 14, 2017, 5:54 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499708423 -7200
#      Mon Jul 10 19:40:23 2017 +0200
# Node ID c8af08d67851fae61c1cf459f0f0bf20f61b9298
# Parent  bbebf6b3d2514134fc750903de90ec515cf4c4d3
# EXP-Topic tr.changes.bookmarks
bookmarks: use 'applychanges' for bookmark update

There is still some use of 'deletedivergent' bookmark here. They will be taken
care of later. The 'deletedivergent' code needs some rework before fitting in
the new world.
Augie Fackler - July 14, 2017, 6:20 p.m.
On Fri, Jul 14, 2017 at 07:54:10PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1499708423 -7200
> #      Mon Jul 10 19:40:23 2017 +0200
> # Node ID c8af08d67851fae61c1cf459f0f0bf20f61b9298
> # Parent  bbebf6b3d2514134fc750903de90ec515cf4c4d3
> # EXP-Topic tr.changes.bookmarks
> bookmarks: use 'applychanges' for bookmark update

queued, thanks

Patch

diff -r bbebf6b3d251 -r c8af08d67851 mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Mon Jul 10 17:46:47 2017 +0200
+++ b/mercurial/bookmarks.py	Mon Jul 10 19:40:23 2017 +0200
@@ -350,6 +350,7 @@ 
     if not active:
         return False
 
+    bmchanges = []
     if marks[active] in parents:
         new = repo[node]
         divs = [repo[b] for b in marks
@@ -357,7 +358,7 @@ 
         anc = repo.changelog.ancestors([new.rev()])
         deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
         if validdest(repo, repo[marks[active]], new):
-            marks[active] = new.node()
+            bmchanges.append((active, new.node()))
             update = True
 
     if deletedivergent(repo, deletefrom, active):
@@ -368,7 +369,7 @@ 
         try:
             lock = repo.lock()
             tr = repo.transaction('bookmark')
-            marks.recordchange(tr)
+            marks.applychanges(repo, tr, bmchanges)
             tr.close()
         finally:
             lockmod.release(tr, lock)