Patchwork [2,of,3,V2] obsolete: pass only new markers to _checkinvalidmarkers()

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 5, 2015, 7:22 a.m.
Message ID <1465976cb03a60d8e572.1423120973@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7681/
State Accepted
Commit 43061f96e40edbb841993197223ae6d1b42128a4
Headers show

Comments

Martin von Zweigbergk - Feb. 5, 2015, 7:22 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1423118448 28800
#      Wed Feb 04 22:40:48 2015 -0800
# Node ID 1465976cb03a60d8e572a1a78c756092528c621a
# Parent  4308a09f48704f942b65e5604ab05b02ef0a9780
obsolete: pass only new markers to _checkinvalidmarkers()

We will soon delay populating precursors until we have to. To prepare
for that, make _checkinvalidmarkers() scan for a nullid precursor in
the list of new markers instead of the (currently) cheaper 'if nullid
in precursors' check.

Patch

diff -r 4308a09f4870 -r 1465976cb03a mercurial/obsolete.py
--- a/mercurial/obsolete.py	Tue Jan 20 22:01:37 2015 -0800
+++ b/mercurial/obsolete.py	Wed Feb 04 22:40:48 2015 -0800
@@ -489,15 +489,16 @@ 
             for p in parents:
                 children.setdefault(p, set()).add(mark)
 
-def _checkinvalidmarkers(obsstore):
+def _checkinvalidmarkers(markers):
     """search for marker with invalid data and raise error if needed
 
     Exist as a separated function to allow the evolve extension for a more
     subtle handling.
     """
-    if node.nullid in obsstore.precursors:
-        raise util.Abort(_('bad obsolescence marker detected: '
-                           'invalid successors nullid'))
+    for mark in markers:
+        if node.nullid in mark[1]:
+            raise util.Abort(_('bad obsolescence marker detected: '
+                               'invalid successors nullid'))
 
 class obsstore(object):
     """Store obsolete markers
@@ -629,7 +630,7 @@ 
         _addsuccessors(self.successors, markers)
         _addprecursors(self.precursors, markers)
         _addchildren(self.children, markers)
-        _checkinvalidmarkers(self)
+        _checkinvalidmarkers(markers)
 
     def relevantmarkers(self, nodes):
         """return a set of all obsolescence markers relevant to a set of nodes.