Fix dodiff/changes
authormpm@selenic.com
Fri, 01 Jul 2005 11:24:09 -0800
changeset 561 cdddf4652aec
parent 560 f9ad1a2c72eb
child 562 be6233a2bfdd
Fix dodiff/changes -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fix dodiff/changes dodiff was failing to pass both nodes to changes changes was comparing things backwards, resulting in added/deleted confusion in dodiff changes was deleting things from cached manifests, use copy() changes now sorts output lists manifest hash: 6ad972b0895b9d855e246efef49c2ebd943946b3 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxZhZywK+sNU5EO8RApZWAJ9mYv1zc7IjXPIMwbVsfroQs8jfBACgn7R7 rTqLTTyIkM1OpL/ebnMtCOY= =VcIr -----END PGP SIGNATURE-----
mercurial/commands.py
mercurial/hg.py
tests/test-diffdir.out
tests/test-tags.out
--- a/mercurial/commands.py	Fri Jul 01 11:21:04 2005 -0800
+++ b/mercurial/commands.py	Fri Jul 01 11:24:09 2005 -0800
@@ -37,7 +37,7 @@
     def date(c):
         return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
 
-    (c, a, d, u) = repo.changes(None, node1, files)
+    (c, a, d, u) = repo.changes(node1, node2, files)
     if files:
         c, a, d = map(lambda x: filterfiles(files, x), (c, a, d))
 
--- a/mercurial/hg.py	Fri Jul 01 11:21:04 2005 -0800
+++ b/mercurial/hg.py	Fri Jul 01 11:24:09 2005 -0800
@@ -95,7 +95,7 @@
     def read(self, node):
         if node == nullid: return {} # don't upset local cache
         if self.mapcache and self.mapcache[0] == node:
-            return self.mapcache[1].copy()
+            return self.mapcache[1]
         text = self.revision(node)
         map = {}
         flag = {}
@@ -687,7 +687,7 @@
 
     def changes(self, node1, node2, files=None):
         # changed, added, deleted, unknown
-        c, a, d, u, mf1 = [], [], [], [], None
+        c, a, d, u, mf2 = [], [], [], [], None
 
         def fcmp(fn, mf):
             t1 = self.wfile(fn).read()
@@ -695,48 +695,54 @@
             return cmp(t1, t2)
 
         # are we comparing the working directory?
-        if not node1:
+        if not node2:
             l, c, a, d, u = self.dirstate.changes(files, self.ignore)
 
             # are we comparing working dir against its parent?
-            if not node2:
+            if not node1:
                 if l:
                     # do a full compare of any files that might have changed
                     change = self.changelog.read(self.dirstate.parents()[0])
-                    mf1 = self.manifest.read(change[0])
+                    mf2 = self.manifest.read(change[0])
                     for f in l:
-                        if fcmp(f, mf1):
+                        if fcmp(f, mf2):
                             c.append(f)
+
+                for l in c, a, d, u:
+                    l.sort()
+
                 return (c, a, d, u)
 
         # are we comparing working dir against non-tip?
         # generate a pseudo-manifest for the working dir
-        if not node1:
-            if not mf1:
+        if not node2:
+            if not mf2:
                 change = self.changelog.read(self.dirstate.parents()[0])
-                mf1 = self.manifest.read(change[0])
+                mf2 = self.manifest.read(change[0]).copy()
             for f in a + c + l:
-                mf1[f] = ""
+                mf2[f] = ""
             for f in d:
-                if f in mf1: del mf1[f]
+                if f in mf2: del mf2[f]
         else:
-            change = self.changelog.read(node1)
-            mf1 = self.manifest.read(change[0])
+            change = self.changelog.read(node2)
+            mf2 = self.manifest.read(change[0])
 
-        change = self.changelog.read(node2)
-        mf2 = self.manifest.read(change[0])
+        change = self.changelog.read(node1)
+        mf1 = self.manifest.read(change[0]).copy()
 
         for fn in mf2:
             if mf1.has_key(fn):
                 if mf1[fn] != mf2[fn]:
-                    if mf1[fn] != "" or fcmp(fn, mf2):
+                    if mf2[fn] != "" or fcmp(fn, mf1):
                         c.append(fn)
                 del mf1[fn]
             else:
                 a.append(fn)
 
         d = mf1.keys()
-        d.sort()
+
+        for l in c, a, d, u:
+            l.sort()
 
         return (c, a, d, u)
 
--- a/tests/test-diffdir.out	Fri Jul 01 11:21:04 2005 -0800
+++ b/tests/test-diffdir.out	Fri Jul 01 11:24:09 2005 -0800
@@ -8,3 +8,8 @@
 +++ b/b
 @@ -0,0 +1,1 @@
 +123
+diff -r 3903775176ed b
+--- /dev/null
++++ b/b
+@@ -0,0 +1,1 @@
++123
--- a/tests/test-tags.out	Fri Jul 01 11:21:04 2005 -0800
+++ b/tests/test-tags.out	Fri Jul 01 11:24:09 2005 -0800
@@ -43,5 +43,5 @@
 + hg id
 c8edf04160c7+b9154636be93+ tip
 + hg status
+C .hgtags
 C a
-C .hgtags