[PATCH] revset: add "diff" field to "matching" keyword

Angel Ezquerra angel.ezquerra at gmail.com
Thu Jun 14 17:57:32 CDT 2012


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1339623178 -7200
# Node ID 66d2c87b434eccec5d36a2cfce87276311b8a407
# Parent  dea63b30ddd6797eee13026280dcbca4b00efccc
revset: add "diff" field to "matching" keyword

The new "diff" field lets you use the matching revset keyword to find revisions
that apply the same change as the selected revisions.

The match must be exact (i.e. same additions, same deletions, same modified
lines and same change context).

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1027,8 +1027,10 @@
     Valid fields are most regular revision fields and some special fields.
 
     Regular revision fields are ``description``, ``author``, ``branch``,
-    ``date``, ``files``, ``phase``, ``parents``, ``substate`` and ``user``.
-    Note that ``author`` and ``user`` are synonyms.
+    ``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user``
+    and ``diff``.
+    Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the
+    contents of the revision.
 
     Special fields are ``summary`` and ``metadata``:
     ``summary`` matches the first line of the description.
@@ -1067,7 +1069,7 @@
     # Not all fields take the same amount of time to be matched
     # Sort the selected fields in order of increasing matching cost
     fieldorder = ['phase', 'parents', 'user', 'date', 'branch', 'summary',
-        'files', 'description', 'substate']
+        'files', 'description', 'substate', 'diff']
     def fieldkeyfunc(f):
         try:
             return fieldorder.index(f)
@@ -1090,6 +1092,7 @@
         'phase': lambda r: repo[r].phase(),
         'substate': lambda r: repo[r].substate,
         'summary': lambda r: repo[r].description().splitlines()[0],
+        'diff': lambda r: list(repo[r].diff(git=True),)
     }
     for info in fields:
         getfield = _funcs.get(info, None)


More information about the Mercurial-devel mailing list