Patchwork [2,of,3,stable,V3] ancestor.deepest: decrement ninteresting correctly (issue3984)

login
register
mail settings
Submitter elson
Date July 26, 2013, 3:14 a.m.
Message ID <CA+jbiHGz8Ocogma-VsWwNtNJjyOqMTk0+-L6X4RXBr2EmzdCwg@mail.gmail.com>
Download mbox | patch
Permalink /patch/1972/
State Accepted
Commit f2dfda6ac1520ec241f35b636af5d1198a77d611
Headers show

Comments

elson - July 26, 2013, 3:14 a.m.
# HG changeset patch
# User Wei, Elson <elson.wei@gmail.com>
# Date 1374744953 -28800
#      Thu Jul 25 17:35:53 2013 +0800
# Branch stable
# Node ID f2dfda6ac1520ec241f35b636af5d1198a77d611
# Parent  8704477ad3b6b6ffd93f0ab33cfb4b7c8ce81247
ancestor.deepest: decrement ninteresting correctly (issue3984)

The invariant this code tries to hold is that ninteresting is the number of
non-zero elements in the interesting array. interesting[nsp] is incremented
at
the same time as interesting[sp] is decremented. So if interesting[nsp] was
previously 0, ninteresting shouldn't be decremented.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1362,10 +1362,10 @@ 
                 if (nsp == sp)
                     continue;
                 seen[p] = nsp;
+                interesting[sp] -= 1;
+                if (interesting[sp] == 0 && interesting[nsp] > 0)
+                    ninteresting -= 1;
                 interesting[nsp] += 1;
-                interesting[sp] -= 1;
-                if (interesting[sp] == 0)
-                    ninteresting -= 1;
             }
         }
         interesting[sv] -= 1;