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`.
--- 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,
--- a/tests/test-bookmarks.t Wed Feb 23 20:47:00 2011 -0600
+++ b/tests/test-bookmarks.t Fri Feb 18 17:09:08 2011 -0600
@@ -240,3 +240,7 @@
commit: (clean)
update: 1 new changesets, 2 branch heads (merge)
+test id
+
+ $ hg id
+ db815d6d32e6 tip Y/Z/x y
--- a/tests/test-debugcomplete.t Wed Feb 23 20:47:00 2011 -0600
+++ b/tests/test-debugcomplete.t Fri Feb 18 17:09:08 2011 -0600
@@ -230,7 +230,7 @@
grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
heads: rev, topo, active, closed, style, template
help:
- identify: rev, num, id, branch, tags
+ identify: rev, num, id, branch, tags, bookmarks
import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
locate: rev, print0, fullpath, include, exclude
--- a/tests/test-hook.t Wed Feb 23 20:47:00 2011 -0600
+++ b/tests/test-hook.t Fri Feb 18 17:09:08 2011 -0600
@@ -66,7 +66,7 @@
test generic hooks
$ hg id
- pre-identify hook: HG_ARGS=id HG_OPTS={'branch': None, 'id': None, 'num': None, 'rev': '', 'tags': None} HG_PATS=[]
+ pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'num': None, 'rev': '', 'tags': None} HG_PATS=[]
warning: pre-identify hook exited with status 1
[1]
$ hg cat b
--- a/tests/test-identify.t Wed Feb 23 20:47:00 2011 -0600
+++ b/tests/test-identify.t Fri Feb 18 17:09:08 2011 -0600
@@ -62,10 +62,28 @@
$ hg id http://localhost:$HGPORT1/
cb9a9f314b8b
+remote with rev number?
+
+ $ hg id -n http://localhost:$HGPORT1/
+ abort: can't query remote revision number, branch, tags, or bookmarks
+ [255]
+
remote with tags?
$ hg id -t http://localhost:$HGPORT1/
- abort: can't query remote revision number, branch, or tags
+ abort: can't query remote revision number, branch, tags, or bookmarks
+ [255]
+
+remote with branch?
+
+ $ hg id -b http://localhost:$HGPORT1/
+ abort: can't query remote revision number, branch, tags, or bookmarks
+ [255]
+
+remote with bookmarks?
+
+ $ hg id -B http://localhost:$HGPORT1/
+ abort: can't query remote revision number, branch, tags, or bookmarks
[255]
Make sure we do not obscure unknown requires file entries (issue2649)