Patchwork [8,of,9,(38,total)] push: move bookmarks exchange in the exchange module

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 2, 2014, 1:33 a.m.
Message ID <bfddf50093a9713b679d.1391304784@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3433/
State Accepted
Commit 58300f61b1399fed6e5297bdcd68dfb532563d55
Headers show

Comments

Pierre-Yves David - Feb. 2, 2014, 1:33 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1391132811 28800
#      Thu Jan 30 17:46:51 2014 -0800
# Node ID bfddf50093a9713b679db4e45f79469ec8cd9c72
# Parent  abf49396b6c4627caef52183d44464a33e4625cb
push: move bookmarks exchange in the exchange module

The bookmark exchange code was already extracted during a previous cycle. This
changesets moves the extracted function in this module. This function will read
and write data in the `pushoperation` object and It  is preferable to have all
core function collaborating through this object in the same place.

This changeset is pure code movement only. Code change for direct consumption of
the `pushoperation` object will come later.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -361,26 +361,10 @@  def updatefromremote(ui, repo, remotemar
         for b, node, writer, msg in sorted(changed):
             localmarks[b] = node
             writer(msg)
         localmarks.write()
 
-def updateremote(ui, repo, remote, revs):
-    ui.debug("checking for updated bookmarks\n")
-    revnums = map(repo.changelog.rev, revs or [])
-    ancestors = [a for a in repo.changelog.ancestors(revnums, inclusive=True)]
-    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
-     ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
-                 srchex=hex)
-
-    for b, scid, dcid in advsrc:
-        if ancestors and repo[scid].rev() not in ancestors:
-            continue
-        if remote.pushkey('bookmarks', b, dcid, scid):
-            ui.status(_("updating bookmark %s\n") % b)
-        else:
-            ui.warn(_('updating bookmark %s failed!\n') % b)
-
 def pushtoremote(ui, repo, remote, targets):
     (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
      ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
                  srchex=hex, targets=targets)
     if invalid:
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -252,7 +252,24 @@  def push(repo, remote, force=False, revs
                 lock.release()
     finally:
         if locallock is not None:
             locallock.release()
 
-    bookmarks.updateremote(pushop.ui, unfi, pushop.remote, pushop.revs)
+    _pushbookmark(pushop.ui, unfi, pushop.remote, pushop.revs)
     return ret
+
+def _pushbookmark(ui, repo, remote, revs):
+    """Update bookmark position on remote"""
+    ui.debug("checking for updated bookmarks\n")
+    revnums = map(repo.changelog.rev, revs or [])
+    ancestors = [a for a in repo.changelog.ancestors(revnums, inclusive=True)]
+    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
+     ) = bookmarks.compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
+                           srchex=hex)
+
+    for b, scid, dcid in advsrc:
+        if ancestors and repo[scid].rev() not in ancestors:
+            continue
+        if remote.pushkey('bookmarks', b, dcid, scid):
+            ui.status(_("updating bookmark %s\n") % b)
+        else:
+            ui.warn(_('updating bookmark %s failed!\n') % b)