From: Gabriele Santilli Date: Thu, 15 Dec 2011 01:04:56 +0000 (-0600) Subject: Adjust Node.__cmp__() to compare full paths. X-Git-Tag: bup-0.25-rc2~162 X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;h=383111ee06546d90f3762f2147a89c46f0784dff;p=bup.git Adjust Node.__cmp__() to compare full paths. 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 Reviewed-by: Rob Browning --- diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index 4543553..20627ab 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -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())