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

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 16, 2014, 9:17 a.m.
Message ID <4fb2a3d7dca6732a2971.1416129428@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6753/
State Accepted
Commit 9a2489015592a54bfc6ce535a00e116b1f04b575
Headers show

Comments

Siddharth Agarwal - Nov. 16, 2014, 9:17 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.

Patch

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