##// END OF EJS Templates
changelog: fix bug in heads computation...
Laurent Charignon -
r25297:3966e39f default
parent child Browse files
Show More
@@ -1194,7 +1194,7 static inline void index_get_parents(ind
1194
1194
1195 static PyObject *index_headrevs(indexObject *self, PyObject *args)
1195 static PyObject *index_headrevs(indexObject *self, PyObject *args)
1196 {
1196 {
1197 Py_ssize_t i, len, addlen;
1197 Py_ssize_t i, j, len;
1198 char *nothead = NULL;
1198 char *nothead = NULL;
1199 PyObject *heads = NULL;
1199 PyObject *heads = NULL;
1200 PyObject *filter = NULL;
1200 PyObject *filter = NULL;
@@ -1237,9 +1237,9 static PyObject *index_headrevs(indexObj
1237 if (nothead == NULL)
1237 if (nothead == NULL)
1238 goto bail;
1238 goto bail;
1239
1239
1240 for (i = 0; i < self->raw_length; i++) {
1240 for (i = 0; i < len; i++) {
1241 const char *data;
1241 int isfiltered;
1242 int parent_1, parent_2, isfiltered;
1242 int parents[2];
1243
1243
1244 isfiltered = check_filter(filter, i);
1244 isfiltered = check_filter(filter, i);
1245 if (isfiltered == -1) {
1245 if (isfiltered == -1) {
@@ -1253,49 +1253,11 static PyObject *index_headrevs(indexObj
1253 continue;
1253 continue;
1254 }
1254 }
1255
1255
1256 data = index_deref(self, i);
1256 index_get_parents(self, i, parents);
1257 parent_1 = getbe32(data + 24);
1257 for (j = 0; j < 2; j++) {
1258 parent_2 = getbe32(data + 28);
1258 if (parents[j] >= 0)
1259
1259 nothead[parents[j]] = 1;
1260 if (parent_1 >= 0)
1261 nothead[parent_1] = 1;
1262 if (parent_2 >= 0)
1263 nothead[parent_2] = 1;
1264 }
1260 }
1265
1266 addlen = self->added ? PyList_GET_SIZE(self->added) : 0;
1267
1268 for (i = 0; i < addlen; i++) {
1269 PyObject *rev = PyList_GET_ITEM(self->added, i);
1270 PyObject *p1 = PyTuple_GET_ITEM(rev, 5);
1271 PyObject *p2 = PyTuple_GET_ITEM(rev, 6);
1272 long parent_1, parent_2;
1273 int isfiltered;
1274
1275 if (!PyInt_Check(p1) || !PyInt_Check(p2)) {
1276 PyErr_SetString(PyExc_TypeError,
1277 "revlog parents are invalid");
1278 goto bail;
1279 }
1280
1281 isfiltered = check_filter(filter, i);
1282 if (isfiltered == -1) {
1283 PyErr_SetString(PyExc_TypeError,
1284 "unable to check filter");
1285 goto bail;
1286 }
1287
1288 if (isfiltered) {
1289 nothead[i] = 1;
1290 continue;
1291 }
1292
1293 parent_1 = PyInt_AS_LONG(p1);
1294 parent_2 = PyInt_AS_LONG(p2);
1295 if (parent_1 >= 0)
1296 nothead[parent_1] = 1;
1297 if (parent_2 >= 0)
1298 nothead[parent_2] = 1;
1299 }
1261 }
1300
1262
1301 for (i = 0; i < len; i++) {
1263 for (i = 0; i < len; i++) {
@@ -886,3 +886,33 Test issue 4506
886
886
887 #endif
887 #endif
888
888
889 Test heads computation on pending index changes with obsolescence markers
890 $ cd ..
891 $ cat >$TESTTMP/test_extension.py << EOF
892 > from mercurial import cmdutil
893 > from mercurial.i18n import _
894 >
895 > cmdtable = {}
896 > command = cmdutil.command(cmdtable)
897 > @command("amendtransient",[], _('hg amendtransient [rev]'))
898 > def amend(ui, repo, *pats, **opts):
899 > def commitfunc(ui, repo, message, match, opts):
900 > return repo.commit(message, repo['.'].user(), repo['.'].date(), match)
901 > opts['message'] = 'Test'
902 > opts['logfile'] = None
903 > cmdutil.amend(ui, repo, commitfunc, repo['.'], {}, pats, opts)
904 > print repo.changelog.headrevs()
905 > EOF
906 $ cat >> $HGRCPATH << EOF
907 > [extensions]
908 > testextension=$TESTTMP/test_extension.py
909 > EOF
910 $ hg init repo-issue-nativerevs-pending-changes
911 $ cd repo-issue-nativerevs-pending-changes
912 $ mkcommit a
913 $ mkcommit b
914 $ hg up ".^"
915 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
916 $ echo aa > a
917 $ hg amendtransient
918 [1, 3]
General Comments 0
You need to be logged in to leave comments. Login now