[PATCH 1 of 2] patch: add new diffopt filenameonly
Laurent Charignon
lcharignon at fb.com
Tue Aug 11 13:03:25 UTC 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1439295186 25200
# Tue Aug 11 05:13:06 2015 -0700
# Node ID e3166b55525d48d0b69231d793ef2918046320e0
# Parent a7527c5769bbe9e6a5afda9e615ad40e69665e9e
patch: add new diffopt filenameonly
This series of patches adds a --filenameonly flag to hg diff --stat to only
display the filenames and omit the number of changes and summary line.
I had the need for this feature trying to compute the list of files that changed
between two branches with:
hg log -T {files % "{file}\\n"} -r 'only(r1,r2)'
and having to pipe the result to sort, uniq to get the list of file that
changed between the branches without duplicates
hg diff -r r1 -r r2 --stat
gave the right result but required parsing the output to eliminate the +,- and
summary line
This series solves this issues with a new flag that combines with --stat:
hg diff -r r1 -r r2 --stat --filenameonly
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -23,6 +23,7 @@ class diffopts(object):
'''context is the number of context lines
text treats all files as text
showfunc enables diff -p output
+ filenameonly only shows filenames
git enables the git extended patch format
nodates removes dates from diff headers
nobinary ignores binary files
@@ -38,6 +39,7 @@ class diffopts(object):
'text': False,
'showfunc': False,
'git': False,
+ 'filenameonly': False,
'nodates': False,
'nobinary': False,
'noprefix': False,
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2098,12 +2098,13 @@ class GitDiffRequired(Exception):
def diffallopts(ui, opts=None, untrusted=False, section='diff'):
'''return diffopts with all features supported and parsed'''
return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section,
- git=True, whitespace=True, formatchanging=True)
+ git=True, whitespace=True, formatchanging=True,
+ filenameonly=True)
diffopts = diffallopts
def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False,
- whitespace=False, formatchanging=False):
+ whitespace=False, formatchanging=False, filenameonly=False):
'''return diffopts with only opted-in features parsed
Features:
@@ -2130,6 +2131,8 @@ def difffeatureopts(ui, opts=None, untru
if git:
buildopts['git'] = get('git')
+ if filenameonly:
+ buildopts['filenameonly'] = get('filenameonly')
if whitespace:
buildopts['ignorews'] = get('ignore_all_space', 'ignorews')
buildopts['ignorewsamount'] = get('ignore_space_change',
More information about the Mercurial-devel
mailing list