[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mercurial-devel
Subject:    Re: [PATCH 2 of 3 stable V3] ancestor.deepest: decrement ninteresting correctly (issue3984)
From:       elson <elson.wei+hg () gmail ! com>
Date:       2013-07-26 3:14:27
Message-ID: CA+jbiHGz8Ocogma-VsWwNtNJjyOqMTk0+-L6X4RXBr2EmzdCwg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


# 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.

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;

[Attachment #5 (text/html)]

<div dir="ltr"># HG changeset patch<br># User Wei, Elson &lt;<a \
href="mailto:elson.wei@gmail.com">elson.wei@gmail.com</a>&gt;<br># Date 1374744953 \
-28800<br>#      Thu Jul 25 17:35:53 2013 +0800<br># Branch stable<br># Node ID \
f2dfda6ac1520ec241f35b636af5d1198a77d611<br> # Parent  \
8704477ad3b6b6ffd93f0ab33cfb4b7c8ce81247<br>ancestor.deepest: decrement ninteresting \
correctly (issue3984)<br><br>The invariant this code tries to hold is that \
ninteresting is the number of<br>non-zero elements in the interesting array. \
interesting[nsp] is incremented at<br> the same time as interesting[sp] is \
decremented. So if interesting[nsp] was<br>previously 0, ninteresting shouldn&#39;t \
be decremented.<br><br>diff --git a/mercurial/parsers.c b/mercurial/parsers.c<br>--- \
                a/mercurial/parsers.c<br>
+++ b/mercurial/parsers.c<br>@@ -1362,10 +1362,10 @@<br>                 if (nsp == \
sp)<br>                     continue;<br>                 seen[p] = nsp;<br>+         \
interesting[sp] -= 1;<br>+                if (interesting[sp] == 0 &amp;&amp; \
interesting[nsp] &gt; 0)<br> +                    ninteresting -= 1;<br>              \
interesting[nsp] += 1;<br>-                interesting[sp] -= 1;<br>-                \
if (interesting[sp] == 0)<br>-                    ninteresting -= 1;<br>             \
}<br>  }<br>         interesting[sv] -= 1;<br><br></div>

--089e0160c35a56d76904e2618a1e--


["hg_19503.patch" (application/octet-stream)]

# 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.

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;


_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@selenic.com
http://selenic.com/mailman/listinfo/mercurial-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic