manifest: simplify manifest.add() by making args required
authorAugie Fackler <raf@durin42.com>
Wed, 08 Oct 2014 11:52:30 -0400
changeset 22787 4a13849ca359
parent 22786 079a0ed5ee4a
child 22788 160efd225b24
manifest: simplify manifest.add() by making args required I verified that changed was never false (it was always a 2-tuple) by adding @@ -220,6 +225,8 @@ class manifest(revlog.revlog): def add(self, map, transaction, link, p1=None, p2=None, changed=None): + if not changed: + assert False, 'changed was %r' % changed # if we're using the cache, make sure it is valid and # parented by the same node we're diffing against if not (changed and p1 and (p1 in self._mancache)): and observing that the test suite still passed. Making all the arguments required should help future readers understand what's going on here.
mercurial/localrepo.py
mercurial/manifest.py
--- a/mercurial/localrepo.py	Thu Sep 25 14:13:31 2014 -0400
+++ b/mercurial/localrepo.py	Wed Oct 08 11:52:30 2014 -0400
@@ -1415,7 +1415,7 @@
                 for f in drop:
                     del m1[f]
                 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
-                                       p2.manifestnode(), (new, drop))
+                                       p2.manifestnode(), new, drop)
                 files = changed + removed
             else:
                 mn = p1.manifestnode()
--- a/mercurial/manifest.py	Thu Sep 25 14:13:31 2014 -0400
+++ b/mercurial/manifest.py	Wed Oct 08 11:52:30 2014 -0400
@@ -159,11 +159,10 @@
         f, n = l.split('\0')
         return revlog.bin(n[:40]), n[40:-1]
 
-    def add(self, map, transaction, link, p1=None, p2=None,
-            changed=None):
+    def add(self, map, transaction, link, p1, p2, added, removed):
         # if we're using the cache, make sure it is valid and
         # parented by the same node we're diffing against
-        if not (changed and p1 and (p1 in self._mancache)):
+        if not (p1 and (p1 in self._mancache)):
             files = sorted(map)
             _checkforbidden(files)
 
@@ -175,7 +174,6 @@
             arraytext = array.array('c', text)
             cachedelta = None
         else:
-            added, removed = changed
             addlist = self._mancache[p1][1]
 
             _checkforbidden(added)