bookmarks: update known bookmarks on the target on push
authorMatt Mackall <mpm@selenic.com>
Thu, 17 Jun 2010 12:22:21 -0500
changeset 11374 e291c039d8ec
parent 11373 306fef8440af
child 11375 0f33abfccaa1
bookmarks: update known bookmarks on the target on push
hgext/bookmarks.py
--- a/hgext/bookmarks.py	Thu Jun 17 12:10:47 2010 -0500
+++ b/hgext/bookmarks.py	Thu Jun 17 12:22:21 2010 -0500
@@ -310,6 +310,28 @@
 
             return result
 
+        def push(self, remote, force=False, revs=None, newbranch=False):
+            result = super(bookmark_repo, self).push(remote, force, revs,
+                                                     newbranch)
+
+            self.ui.debug("checking for updated bookmarks\n")
+            rb = remote.listkeys('bookmarks')
+            for k in rb.keys():
+                if k in self._bookmarks:
+                    nr, nl = rb[k], self._bookmarks[k]
+                    if nr in self:
+                        cr = self[nr]
+                        cl = self[nl]
+                        if cl in cr.descendants():
+                            r = remote.pushkey('bookmarks', k, nr, nl)
+                            if r:
+                                self.ui.status(_("updating bookmark %s\n") % k)
+                            else:
+                                self.ui.warn(_("failed to update bookmark"
+                                                  " %s!\n") % k)
+
+            return result
+
         def addchangegroup(self, source, srctype, url, emptyok=False):
             parents = self.dirstate.parents()