Patchwork [2,of,4,status-via-diff] manifest: add optional recording of clean entries to diff

login
register
mail settings
Submitter Augie Fackler
Date Jan. 7, 2015, 9:10 p.m.
Message ID <e3478ceadf3216a60c88.1420665024@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7355/
State Accepted
Commit 829f640b5540d9da98258ab54b91ca96d797e9f0
Headers show

Comments

Augie Fackler - Jan. 7, 2015, 9:10 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1418677468 18000
#      Mon Dec 15 16:04:28 2014 -0500
# Node ID e3478ceadf3216a60c88b0be7c5bd4cfc6ec6e2d
# Parent  0c9ac5831b88025a0047bed1529a94f3000c5820
manifest: add optional recording of clean entries to diff

This makes manifest slightly easier to use for status code.

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -58,13 +58,21 @@  class manifestdict(dict):
                 del mf[fn]
         return mf
 
-    def diff(self, m2):
-        '''Finds changes between the current manifest and m2. The result is
-        returned as a dict with filename as key and values of the form
-        ((n1,fl1),(n2,fl2)), where n1/n2 is the nodeid in the current/other
-        manifest and fl1/fl2 is the flag in the current/other manifest. Where
-        the file does not exist, the nodeid will be None and the flags will be
-        the empty string.'''
+    def diff(self, m2, clean=False):
+        '''Finds changes between the current manifest and m2.
+
+        Args:
+          m2: the manifest to which this manifest should be compared.
+          clean: if true, include files unchanged between these manifests
+                 with a None value in the returned dictionary.
+
+        The result is returned as a dict with filename as key and
+        values of the form ((n1,fl1),(n2,fl2)), where n1/n2 is the
+        nodeid in the current/other manifest and fl1/fl2 is the flag
+        in the current/other manifest. Where the file does not exist,
+        the nodeid will be None and the flags will be the empty
+        string.
+        '''
         diff = {}
 
         for fn, n1 in self.iteritems():
@@ -75,6 +83,8 @@  class manifestdict(dict):
                 fl2 = ''
             if n1 != n2 or fl1 != fl2:
                 diff[fn] = ((n1, fl1), (n2, fl2))
+            elif clean:
+                diff[fn] = None
 
         for fn, n2 in m2.iteritems():
             if fn not in self: