[PATCH 1 of 4] Extension for pushing and pulling user defined data

David Soria Parra sn_ at gmx.net
Wed Aug 27 05:03:19 CDT 2008

# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1219830241 -7200
# Node ID ecb23d75d99dbcbfd9495ba7aeccc6376b528f57
# Parent  ce94b3236ea4541aa4b96512a1155d4694a36e62
Extension for pushing and pulling user defined data

Extensions can provide additional information during push/pull
if they implement the methods repopush/repopull. They can send
completly userdefined data that is than pickled and transfered.
On the remote side, the corresponding repopull method is called
and receives the unpickled data.

Mercurial's core doesn't store anything. It just provides the
transfer mechanism. This enables extensions to transfer e.g. the
.hg/hgrc file or to decide how data is stored in the repository.

Drawback of this solutions is, that you need to enable the extensions
on both remote and local repositories.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1403,6 +1403,7 @@
     def pull(self, remote, heads=None, force=False):
         lock = self.lock()
+            self.addextras(remote.extras())
             fetch = self.findincoming(remote, heads=heads, force=force)
             if fetch == [nullid]:
                 self.ui.status(_("requesting all changes\n"))
@@ -1421,6 +1422,18 @@
             del lock
+    def addextras(self, extras):
+        for name, module in extensions.extensions():
+            if hasattr(module, 'repopull'):
+                module.repopull(ui=self.ui, repo=self, extras=extras)
+    def extras(self):
+        resp = {}
+        for name, module in extensions.extensions():
+            if hasattr(module, 'repopush'):
+                resp.update(module.repopush(self))
+        return resp
     def push(self, remote, force=False, revs=None):
         # there are two ways to push to remote repo:
@@ -1430,6 +1443,7 @@
         # unbundle assumes local user cannot lock remote repo (new ssh
         # servers, http servers).
+        remote.addextras(self.extras())
         if remote.capable('unbundle'):
             return self.push_unbundle(remote, force, revs)
         return self.push_addchangegroup(remote, force, revs)

More information about the Mercurial-devel mailing list