diff mercurial/commands.py @ 13477:0fb2ff949790 stable

id: add bookmarks to id Since bookmarks are no longer merged with repo.tags() as of d012d95499f7, they don't show up in `hg id` as they used to. This adds them back into the summary that `hg id` prints, and adds a -B/--bookmarks flag alongside the -t/--tags and -b/--branch options. Note this introduces a slight backwards-incompatibility: the summary printed by `hg id` now separates bookmarks from tags with a space, as seen below, instead of running it into the tags list. Default summary output: $ hg id db815d6d32e6 tip/tag1 bm1/bm2 Output with --bookmarks: $ hg id --bookmarks bm1 bm2 See also afc84a879ac8 which adds bookmarks back into `hg summary`.
author Kevin Bullock <kbullock@ringworld.org>
date Fri, 18 Feb 2011 17:09:08 -0600
parents bbdd858e3229
children 0b79cf616e65 8ee4b00ddfd8
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Feb 23 20:47:00 2011 -0600
+++ b/mercurial/commands.py	Fri Feb 18 17:09:08 2011 -0600
@@ -2240,8 +2240,8 @@
             else:
                 ui.write("%s\n" % opt)
 
-def identify(ui, repo, source=None,
-             rev=None, num=None, id=None, branch=None, tags=None):
+def identify(ui, repo, source=None, rev=None,
+             num=None, id=None, branch=None, tags=None, bookmarks=None):
     """identify the working copy or specified revision
 
     With no revision, print a summary of the current state of the
@@ -2263,7 +2263,7 @@
                            "(.hg not found)"))
 
     hexfunc = ui.debugflag and hex or short
-    default = not (num or id or branch or tags)
+    default = not (num or id or branch or tags or bookmarks)
     output = []
 
     revs = []
@@ -2277,9 +2277,9 @@
             rev = revs[0]
         if not rev:
             rev = "tip"
-        if num or branch or tags:
-            raise util.Abort(
-                _("can't query remote revision number, branch, or tags"))
+        if num or branch or tags or bookmarks:
+            raise util.Abort(_("can't query remote revision number,"
+                             " branch, tags, or bookmarks"))
         output = [hexfunc(repo.lookup(rev))]
     elif not rev:
         ctx = repo[None]
@@ -2310,12 +2310,20 @@
         if t:
             output.append(t)
 
+        # multiple bookmarks for a single parent separated by '/'
+        bm = '/'.join(ctx.bookmarks())
+        if bm:
+            output.append(bm)
+
     if branch:
         output.append(ctx.branch())
 
     if tags:
         output.extend(ctx.tags())
 
+    if bookmarks:
+        output.extend(ctx.bookmarks())
+
     ui.write("%s\n" % ' '.join(output))
 
 def import_(ui, repo, patch1, *patches, **opts):
@@ -4460,8 +4468,9 @@
           ('n', 'num', None, _('show local revision number')),
           ('i', 'id', None, _('show global revision id')),
           ('b', 'branch', None, _('show branch')),
-          ('t', 'tags', None, _('show tags'))],
-         _('[-nibt] [-r REV] [SOURCE]')),
+          ('t', 'tags', None, _('show tags')),
+          ('B', 'bookmarks', None, _('show bookmarks'))],
+         _('[-nibtB] [-r REV] [SOURCE]')),
     "import|patch":
         (import_,
          [('p', 'strip', 1,