[PATCH 2 of 4 status-via-diff] manifest: add optional recording of clean entries to diff
Augie Fackler
raf at durin42.com
Wed Jan 7 15:10:24 CST 2015
# HG changeset patch
# User Augie Fackler <augie at 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.
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:
More information about the Mercurial-devel
mailing list