From 383111ee06546d90f3762f2147a89c46f0784dff Mon Sep 17 00:00:00 2001 From: Gabriele Santilli Date: Wed, 14 Dec 2011 19:04:56 -0600 Subject: [PATCH] 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 --- lib/bup/vfs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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()) -- 2.39.2