1. Alexander Solovyov
  2. remote-bookmarks

Commits

Alexander Solovyov  committed c6a4b7a

first working version

  • Participants
  • Branches default

Comments (0)

Files changed (3)

File .hgignore

View file
+\.pyc$

File README

View file
+.. -*- mode: rst -*-
+
+============================
+ Remote bookmarks extension
+============================
+
+Places all bookmarks from remote repository mentioned in ``[paths]`` in your
+repository with names ``remote/path/bookmarkname``.

File remote-bookmarks.py

View file
+from mercurial import localrepo, bookmarks, error
+
+def reposetup(ui, repo):
+    if not isinstance(repo, localrepo.localrepository):
+        return
+
+    class remotebookmarksrepo(repo.__class__):
+        def pull(self, remote, heads=None, force=False):
+            super(remotebookmarksrepo, self).pull(remote, heads, force)
+
+            name = None
+            for k, v in self.ui.configitems('paths'):
+                if v == remote._url:
+                    name = k
+                    break
+
+            if name is None:
+                return
+
+            changed = False
+            for k, v in remote.listkeys('bookmarks').items():
+                try:
+                    ctx = self[v]
+                except error.RepoLookupError:
+                    continue
+
+                key = 'remote/%s/%s' % (name, k)
+                self._bookmarks[key] = ctx.node()
+                changed = True
+
+            if changed:
+                bookmarks.write(self)
+
+    repo.__class__ = remotebookmarksrepo