[PATCH 3 of 3] bookmarks: use "changectx.descendant()" for efficient descendant examination

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Sep 18 07:44:07 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1347971952 -32400
# Node ID aa4802d1cd2bd6c8a52a8e09218cc04c040a5067
# Parent  0e7f7a718a160bfa71adf573b8e20c5fbad22d9e
bookmarks: use "changectx.descendant()" for efficient descendant examination

This patch uses "old.descendant(new)" expression instead of
"new in old.descendants()" for efficiency.

diff -r 0e7f7a718a16 -r aa4802d1cd2b mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Tue Sep 18 21:39:12 2012 +0900
+++ b/mercurial/bookmarks.py	Tue Sep 18 21:39:12 2012 +0900
@@ -159,7 +159,7 @@
         if mark and marks[mark] in parents:
             old = repo[marks[mark]]
             new = repo[node]
-            if new in old.descendants() and mark == cur:
+            if old.descendant(new) and mark == cur:
                 marks[cur] = new.node()
                 update = True
             if mark != cur:
@@ -281,4 +281,4 @@
         validdests.remove(old)
         return new in validdests
     else:
-        return new in old.descendants()
+        return old.descendant(new)


More information about the Mercurial-devel mailing list