[PATCH] commands: New option for 'hg identify', to allow explicit output of long hash
Simon Howkins
simonh at symbian.org
Fri Jun 4 10:41:35 CDT 2010
# HG changeset patch
# User Simon Howkins <simonh at symbian.org>
# Date 1275642988 -3600
# Branch stable
# Node ID 6a39deac68b5a8bee88de5e18fc2a9f436be3fdf
# Parent d3ebb1a0bc49559e1e41d37f69c2afa06722563e
commands: New option for 'hg identify', to allow explicit output of long hash
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1741,7 +1741,7 @@
ui.write("%s\n" % first)
def identify(ui, repo, source=None,
- rev=None, num=None, id=None, branch=None, tags=None):
+ rev=None, num=None, id=None, ID=None, branch=None, tags=None):
"""identify the working copy or specified revision
With no revision, print a summary of the current state of the
@@ -1760,7 +1760,8 @@
raise util.Abort(_("There is no Mercurial repository here "
"(.hg not found)"))
- hexfunc = ui.debugflag and hex or short
+ hexfunc = (ui.debugflag or ID) and hex or short
+ id = id or ID
default = not (num or id or branch or tags)
output = []
@@ -3643,9 +3644,10 @@
[('r', 'rev', '', _('identify the specified revision')),
('n', 'num', None, _('show local revision number')),
('i', 'id', None, _('show global revision id')),
+ ('I', 'ID', None, _('show long global revision id (trumps -i)')),
('b', 'branch', None, _('show branch')),
('t', 'tags', None, _('show tags'))],
- _('[-nibt] [-r REV] [SOURCE]')),
+ _('[-niIbt] [-r REV] [SOURCE]')),
"import|patch":
(import_,
[('p', 'strip', 1,
diff --git a/tests/test-identify b/tests/test-identify
--- a/tests/test-identify
+++ b/tests/test-identify
@@ -23,7 +23,9 @@
hg id -t
hg id -b
hg id -i
+hg id -I
hg id -n -t -b -i
+hg id -n -t -b -i -I
echo % with modifications
echo b > a
@@ -33,12 +35,14 @@
cd ..
hg -R test id
hg id test
+hg id test -I
echo % with remote http repo
cd test
hg serve -p $HGPORT1 -d --pid-file=hg.pid
cat hg.pid >> $DAEMON_PIDS
hg id http://localhost:$HGPORT1/
+hg id http://localhost:$HGPORT1/ -I
echo % remote with tags?
hg id -t http://localhost:$HGPORT1/
diff --git a/tests/test-identify.out b/tests/test-identify.out
--- a/tests/test-identify.out
+++ b/tests/test-identify.out
@@ -13,13 +13,17 @@
tip
default
cb9a9f314b8b
+cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
cb9a9f314b8b 0 default tip
+cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 0 default tip
% with modifications
cb9a9f314b8b+ 0+ default tip
% other local repo
cb9a9f314b8b+ tip
cb9a9f314b8b+ tip
+cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b+
% with remote http repo
cb9a9f314b8b
+cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
% remote with tags?
abort: can't query remote revision number, branch, or tags
Some facts about Symbian that we are legally obliged to tell you:
Symbian Foundation Limited is a Company Limited by Guarantee and not having Share Capital
We're registered in England and Wales - Companies House knows us by the number 6683783
Our address is 1 Boundary Row, Southwark, London SE1 8HP.
More information about the Mercurial-devel
mailing list