record: add white space diff options
authorIngo Proetel <proetel@aicas.de>
Fri, 10 Jun 2011 10:58:10 +0200
changeset 14597 3f1dccea9510
parent 14596 6a0070d00bc8
child 14598 259ba7502370
record: add white space diff options
hgext/record.py
tests/test-qrecord.t
--- a/hgext/record.py	Mon Jun 13 13:53:58 2011 +0200
+++ b/hgext/record.py	Fri Jun 10 10:58:10 2011 +0200
@@ -17,6 +17,15 @@
 
 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
 
+diffopts = [
+    ('w', 'ignore-all-space', False,
+     _('ignore white space when comparing lines')),
+    ('b', 'ignore-space-change', None,
+     _('ignore changes in the amount of white space')),
+    ('B', 'ignore-blank-lines', None,
+     _('ignore changes whose lines are all blank')),
+]
+
 def scanpatch(fp):
     """like patch.iterhunks, but yield different events
 
@@ -345,7 +354,8 @@
                if h[0].special() or len(h) > 1], [])
 
 @command("record",
-         commands.table['^commit|ci'][1], # same options as commit
+         # same options as commit + white space diff options
+         commands.table['^commit|ci'][1][:] + diffopts,
           _('hg record [OPTION]... [FILE]...'))
 def record(ui, repo, *pats, **opts):
     '''interactively select changes to commit
@@ -435,7 +445,10 @@
                                '(use "hg commit" instead)'))
 
         changes = repo.status(match=match)[:3]
-        diffopts = mdiff.diffopts(git=True, nodates=True)
+        diffopts = mdiff.diffopts(git=True, nodates=True,
+                                  ignorews=opts.get('ignore_all_space'),
+                                  ignorewsamount=opts.get('ignore_space_change'),
+                                  ignoreblanklines=opts.get('ignore_blank_lines'))
         chunks = patch.diff(repo, changes=changes, opts=diffopts)
         fp = cStringIO.StringIO()
         fp.write(''.join(chunks))
@@ -567,8 +580,8 @@
     cmdtable["qrecord"] = \
         (qrecord,
          # same options as qnew, but copy them so we don't get
-         # -i/--interactive for qrecord
-         mq.cmdtable['^qnew'][1][:],
+         # -i/--interactive for qrecord and add white space diff options
+         mq.cmdtable['^qnew'][1][:] + diffopts,
          _('hg qrecord [OPTION]... PATCH [FILE]...'))
 
     _wrapcmd('qnew', mq.cmdtable, qrecord, _("interactively record a new patch"))
--- a/tests/test-qrecord.t	Mon Jun 13 13:53:58 2011 +0200
+++ b/tests/test-qrecord.t	Fri Jun 10 10:58:10 2011 +0200
@@ -64,6 +64,9 @@
    -l --logfile FILE         read commit message from file
    -d --date DATE            record the specified date as commit date
    -u --user USER            record the specified user as committer
+   -w --ignore-all-space     ignore white space when comparing lines
+   -b --ignore-space-change  ignore changes in the amount of white space
+   -B --ignore-blank-lines   ignore changes whose lines are all blank
   
   [+] marked option can be specified multiple times
   
@@ -136,6 +139,9 @@
    -X --exclude PATTERN [+]  exclude names matching the given patterns
    -m --message TEXT         use text as commit message
    -l --logfile FILE         read commit message from file
+   -w --ignore-all-space     ignore white space when comparing lines
+   -b --ignore-space-change  ignore changes in the amount of white space
+   -B --ignore-blank-lines   ignore changes whose lines are all blank
       --mq                   operate on patch repository
   
   [+] marked option can be specified multiple times