mercurial/obsolete.py
changeset 19054 d5f968f7716f
parent 19053 f74f2a4e3327
child 19528 f4a0f6dd95a3
--- a/mercurial/obsolete.py	Wed Apr 17 11:18:36 2013 +0200
+++ b/mercurial/obsolete.py	Wed Apr 17 11:47:49 2013 +0200
@@ -386,6 +386,27 @@
             msg = _('failed to push some obsolete markers!\n')
             repo.ui.warn(msg)
 
+def syncpull(repo, remote, gettransaction):
+    """utility function to pull bookmark to a remote
+
+    The `gettransaction` is function that return the pull transaction, creating
+    one if necessary. We return the transaction to inform the calling code that
+    a new transaction have been created (when applicable).
+
+    Exists mostly to allow overridding for experimentation purpose"""
+    tr = None
+    if _enabled:
+        repo.ui.debug('fetching remote obsolete markers\n')
+        remoteobs = remote.listkeys('obsolete')
+        if 'dump0' in remoteobs:
+            tr = gettransaction()
+            for key in sorted(remoteobs, reverse=True):
+                if key.startswith('dump'):
+                    data = base85.b85decode(remoteobs[key])
+                    repo.obsstore.mergemarkers(tr, data)
+            repo.invalidatevolatilesets()
+    return tr
+
 def allmarkers(repo):
     """all obsolete markers known in a repository"""
     for markerdata in repo.obsstore: