[PATCH 06 of 16] ancestor.missingancestors: calculate start point after filtering revsvisit

Siddharth Agarwal sid0 at fb.com
Sun Nov 16 03:17:08 CST 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1416001645 28800
#      Fri Nov 14 13:47:25 2014 -0800
# Node ID 4fb2a3d7dca6732a297151cb0ef12647542b22b2
# Parent  cb87c30f2674da84818c9f3f416b41e493ed9422
ancestor.missingancestors: calculate start point after filtering revsvisit

Any revs that are filtered out are also in basesvisit, which means they
wouldn't be returned in the missing list anyway. There's no need to explore
such revs or their ancestors.

The 'if not revsvisit' check moves down because we can't call max() on an empty
set.

diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py
--- a/mercurial/ancestor.py
+++ b/mercurial/ancestor.py
@@ -148,13 +148,13 @@
 
     revsvisit = set(revs)
     basesvisit = set(bases)
+    if not basesvisit:
+        basesvisit.add(nullrev)
+    bothvisit = revsvisit.intersection(basesvisit)
+    revsvisit.difference_update(bothvisit)
     if not revsvisit:
         return []
-    if not basesvisit:
-        basesvisit.add(nullrev)
     start = max(max(revsvisit), max(basesvisit))
-    bothvisit = revsvisit.intersection(basesvisit)
-    revsvisit.difference_update(bothvisit)
     # At this point, we hold the invariants that:
     # - revsvisit is the set of nodes we know are an ancestor of at least one
     #   of the nodes in revs


More information about the Mercurial-devel mailing list