[PATCH] grep: add the option to show full commit hash for every result
Kostia Balytskyi
ikostia at fb.com
Thu Feb 4 17:44:26 UTC 2016
It does not look like this.
From: <timeless.bmo1 at gmail.com<mailto:timeless.bmo1 at gmail.com>> on behalf of timeless <timeless at gmail.com<mailto:timeless at gmail.com>>
Reply-To: "timeless at gmail.com<mailto:timeless at gmail.com>" <timeless at gmail.com<mailto:timeless at gmail.com>>
Date: Thursday, February 4, 2016 at 5:10 PM
To: Kostia Balytskyi <ikostia at fb.com<mailto:ikostia at fb.com>>
Cc: "mercurial-devel at mercurial-scm.org<mailto:mercurial-devel at mercurial-scm.org>" <mercurial-devel at mercurial-scm.org<mailto:mercurial-devel at mercurial-scm.org>>
Subject: Re: [PATCH] grep: add the option to show full commit hash for every result
Normally we'd rely on -T, does grep not have it?
On Feb 4, 2016 10:24 AM, "Kostia Balytskyi" <ikostia at fb.com<mailto:ikostia at fb.com>> wrote:
# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com<mailto:ikostia at fb.com>>
# Date 1454599288 28800
# Thu Feb 04 07:21:28 2016 -0800
# Node ID 436dfb325e8ce1b9cdad569a2bbe408a0d33bb5f
# Parent d73a5ab18015f61ac61e6e77256512fd82b03818
grep: add the option to show full commit hash for every result
People often would want to send the result of hg grep to someone
else with a remote repo. Currently it's of no big use since revision
ids are not global. Introducing --hash will allow people to identify
search results in a global way.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4084,6 +4084,7 @@
_('only search files changed within revision range'), _('REV')),
('u', 'user', None, _('list the author (long with -v)')),
('d', 'date', None, _('list the date (short with -q)')),
+ ('', 'hash', None, _('show full commit hash instead of revision id')),
] + walkopts,
_('[OPTION]... PATTERN [FILE]...'),
inferrepo=True)
@@ -4186,6 +4187,7 @@
def display(fn, ctx, pstates, states):
rev = ctx.rev()
+ hash = ctx.hex()
if ui.quiet:
datefunc = util.shortdate
else:
@@ -4201,8 +4203,12 @@
else:
iter = [('', l) for l in states]
for change, l in iter:
- cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
-
+ cols = [(fn, 'grep.filename')]
+
+ if opts.get('hash'):
+ cols.append((str(hash), 'grep.rev'))
+ else:
+ cols.append((str(rev), 'grep.rev'))
if opts.get('line_number'):
cols.append((str(l.linenum), 'grep.linenumber'))
if opts.get('all'):
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -173,6 +173,11 @@
color:3:-:red
color:1:+:red
+Check that --hash option works
+ $ hg grep --hash --all red
+ color:[a-f0-9]{40}:-:red (re)
+ color:[a-f0-9]{40}:\+:red (re)
+
$ cd ..
$ hg init a
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel at mercurial-scm.org<mailto:Mercurial-devel at mercurial-scm.org>
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel<https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=pwY8QfER4F9c42fP0klPv72_aUtJFjcISdKnNBHQHVo&s=4mPx8gT1xOJixbdzbas6py7Xw2JT5D3fiDV7N5s7HNw&e=>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160204/ddf8b0a3/attachment-0002.html>
More information about the Mercurial-devel
mailing list