From 4cb0182da105d18f067c1a10482c89c966b02827 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 4 Dec 2009 22:44:12 -0500 Subject: [PATCH] Use __cmp__ instead of __eq__ for Tree comparison. This ensures that __ne__ will also work, and makes it easier to subclass Tree. For example, in the previous implementation you could have >>> commA == commB False >>> cmp(commA, commB) 0 if the comments had different ids, but equivalent content. At the user-interface level, this removes some false "modified comments" from `be diff`. --- libbe/tree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libbe/tree.py b/libbe/tree.py index 8077da7..d3f6bcd 100644 --- a/libbe/tree.py +++ b/libbe/tree.py @@ -84,8 +84,8 @@ class Tree(list): >>> a.has_descendant(a, match_self=True) True """ - def __eq__(self, other): - return id(self) == id(other) + def __cmp__(self, other): + return cmp(id(self), id(other)) def branch_len(self): """ -- 2.26.2