[PATCH v2] identify: list bookmarks for remote repositories

Nils Adermann naderman at naderman.de
Sat Mar 12 12:35:05 CST 2011


# HG changeset patch
# User Nils Adermann <naderman at naderman.de>
# Date 1299950114 -3600
# Node ID e29a3b20be0c57207faa0e2879d1810242e79e41
# Parent  1bb2a56a9d73b386378564381807fdf8df38ea3f
identify: list bookmarks for remote repositories

diff -r 1bb2a56a9d73 -r e29a3b20be0c mercurial/commands.py
--- a/mercurial/commands.py	Thu Mar 10 13:43:47 2011 +0100
+++ b/mercurial/commands.py	Sat Mar 12 18:15:14 2011 +0100
@@ -2267,6 +2267,7 @@
     output = []
 
     revs = []
+    bms = []
     if source:
         source, branches = hg.parseurl(ui.expandpath(source))
         repo = hg.repository(ui, source)
@@ -2277,10 +2278,19 @@
             rev = revs[0]
         if not rev:
             rev = "tip"
-        if num or branch or tags or bookmarks:
+        if num or branch or tags:
             raise util.Abort(_("can't query remote revision number,"
                              " branch, tags, or bookmarks"))
-        output = [hexfunc(repo.lookup(rev))]
+
+        remoterev = repo.lookup(rev)
+        if default or id:
+            output = [hexfunc(remoterev)]
+
+        if 'bookmarks' in repo.listkeys('namespaces'):
+            hexremoterev = hex(remoterev)
+            bms = [bm for bm, bmrev in repo.listkeys('bookmarks').iteritems()
+                   if bmrev == hexremoterev]
+
     elif not rev:
         ctx = repo[None]
         parents = ctx.parents()
@@ -2300,6 +2310,9 @@
         if num:
             output.append(str(ctx.rev()))
 
+    if repo.local():
+        bms = ctx.bookmarks()
+
     if repo.local() and default and not ui.quiet:
         b = ctx.branch()
         if b != 'default':
@@ -2310,8 +2323,9 @@
         if t:
             output.append(t)
 
+    if default and not ui.quiet:
         # multiple bookmarks for a single parent separated by '/'
-        bm = '/'.join(ctx.bookmarks())
+        bm = '/'.join(bms)
         if bm:
             output.append(bm)
 
@@ -2322,7 +2336,7 @@
         output.extend(ctx.tags())
 
     if bookmarks:
-        output.extend(ctx.bookmarks())
+        output.extend(bms)
 
     ui.write("%s\n" % ' '.join(output))
 


More information about the Mercurial-devel mailing list