[PATCH V2] changelog: fix bug in native head computation

Laurent Charignon lcharignon at fb.com
Thu May 21 14:56:46 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432236833 25200
#      Thu May 21 12:33:53 2015 -0700
# Node ID 86a3b8c985bd1d7ab831ccf5f00ddfba266c9e58
# Parent  451df92cec4912aefac57a4cf82e9268192c867b
changelog: fix bug in native head computation

Native head computations was not taking filtering properly into account pending
changes in the index. We also add a test to avoid introducing regression.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1263,7 +1263,7 @@
 			goto bail;
 		}
 
-		isfiltered = check_filter(filter, i);
+		isfiltered = check_filter(filter, i + self->raw_length);
 		if (isfiltered == -1) {
 			PyErr_SetString(PyExc_TypeError,
 				"unable to check filter");
@@ -1271,7 +1271,7 @@
 		}
 
 		if (isfiltered) {
-			nothead[i] = 1;
+			nothead[i + self->raw_length] = 1;
 			continue;
 		}
 
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -883,6 +883,35 @@
   200 Script output follows
 
   $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
-
 #endif
 
+Test heads computation on pending index changes with obsolescence markers
+  $ cd ..
+  $ cat >$TESTTMP/test_extension.py  << EOF
+  > from mercurial import cmdutil
+  > from mercurial.i18n import _
+  > 
+  > cmdtable = {}
+  > command = cmdutil.command(cmdtable)
+  > @command("amendtransient",[], _('hg amendtransient [rev]'))
+  > def amend(ui, repo, *pats, **opts):
+  >   def commitfunc(ui, repo, message, match, opts):
+  >     return repo.commit(message, repo['.'].user(), repo['.'].date(), match)
+  >   opts['message'] = 'Test'
+  >   opts['logfile'] = None
+  >   cmdutil.amend(ui, repo, commitfunc, repo['.'], {}, pats, opts)
+  >   print repo.changelog.headrevs()
+  > EOF
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > testextension=$TESTTMP/test_extension.py
+  > EOF
+  $ hg init repo-issue-nativerevs-pending-changes
+  $ cd repo-issue-nativerevs-pending-changes
+  $ mkcommit a
+  $ mkcommit b
+  $ hg up ".^"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo aa > a
+  $ hg amendtransient
+  [1, 3]


More information about the Mercurial-devel mailing list