Anonymous avatar Anonymous committed e95e532

first version of a pullnamespacedbookmarks extension.

Comments (0)

Files changed (1)

+#!/usr/bin/env python
+# encoding: utf-8
+"""pull namespaced bookmarks."""
+import os
+from mercurial import commands
+def pullnamespacedbookmarks(ui, repo, target=None, prefix="", postfix="", **opts):
+    """Pull bookmarks with a namespace."""
+    # use namespaces for bookmarks
+    ui.pushbuffer()
+    commands.incoming(ui, repo, target, bundle=False, force=True, quiet=True, bookmarks=True)
+    marks=[tuple(b.split()) for b in ui.popbuffer().splitlines()[2:]]
+    # pull, to make sure that we have all required revs in the repo
+    commands.pull(ui, repo, target, rev=[rev for boo,rev in marks], force=True)
+    ui.debug("remote bookmarks "+ str(marks) + "\n")
+    for mark, rev in marks: 
+        commands.bookmark(ui, repo, prefix+mark+postfix, rev=rev, force=True)
+cmdtable = {
+    # "command-name": (function-call, options-list, help-string)
+    "pullnamespacedbookmarks": (pullnamespacedbookmarks,
+                     [
+                      ('p', 'prefix', "", 'set the prefix for all pulled bookmarks'),
+                      ('postfix', "", 'set the postfix for all pulled bookmarks')
+                     "[options] [repo]")
+if __name__ == "__main__": 
+    print """Take the branch rebasing challenge:
+This is a mercurial extension (now). 
+Run it in an empty repo with 
+    hg --config extensions.bran=<path/to/> test100branches
+Enjoy your time with Mercurial!
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.