]> arthur.barton.de Git - bup.git/commitdiff
Adjust Node.__cmp__() to compare full paths.
authorGabriele Santilli <santilli.gabriele@gmail.com>
Thu, 15 Dec 2011 01:04:56 +0000 (19:04 -0600)
committerRob Browning <rlb@defaultvalue.org>
Fri, 17 Aug 2012 18:42:56 +0000 (13:42 -0500)
The function now returns immediately if the two arguments are the same
Python object, otherwise it compares the full path name (rather than
just the file name).

Discussion: https://groups.google.com/group/bup-list/browse_thread/thread/1afc33b26394d69e/1a7a8155a1005600

Signed-off-by: Gabriele Santilli <gabriele@colellachiara.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/vfs.py

index 454355337c4b06bde89f231657be66647a7fea14..20627ab852532e5d129ac229a045bd5f2d6dc691 100644 (file)
@@ -173,7 +173,10 @@ class Node:
         self._subs = None
 
     def __cmp__(a, b):
-        return cmp(a and a.name or None, b and b.name or None)
+        if a is b:
+            return 0
+        return (cmp(a and a.parent, b and b.parent) or
+                cmp(a and a.name, b and b.name))
 
     def __iter__(self):
         return iter(self.subs())