##// END OF EJS Templates
phases: add set per phase in C phase computation...
Laurent Charignon -
r25190:22438cfd default
parent child Browse files
Show More
@@ -1071,14 +1071,17 b' static inline void set_phase_from_parent'
1071 phases[i] = phases[parent_2];
1071 phases[i] = phases[parent_2];
1072 }
1072 }
1073
1073
1074 static PyObject *compute_phases(indexObject *self, PyObject *args)
1074 static PyObject *compute_phases_map_sets(indexObject *self, PyObject *args)
1075 {
1075 {
1076 PyObject *roots = Py_None;
1076 PyObject *roots = Py_None;
1077 PyObject *ret = NULL;
1077 PyObject *phaseslist = NULL;
1078 PyObject *phaseslist = NULL;
1078 PyObject *phaseroots = NULL;
1079 PyObject *phaseroots = NULL;
1079 PyObject *rev = NULL;
1080 PyObject *rev = NULL;
1080 PyObject *p1 = NULL;
1081 PyObject *p1 = NULL;
1081 PyObject *p2 = NULL;
1082 PyObject *p2 = NULL;
1083 PyObject *phaseset = NULL;
1084 PyObject *phasessetlist = NULL;
1082 Py_ssize_t addlen = self->added ? PyList_GET_SIZE(self->added) : 0;
1085 Py_ssize_t addlen = self->added ? PyList_GET_SIZE(self->added) : 0;
1083 Py_ssize_t len = index_length(self) - 1;
1086 Py_ssize_t len = index_length(self) - 1;
1084 Py_ssize_t numphase = 0;
1087 Py_ssize_t numphase = 0;
@@ -1088,6 +1091,7 b' static PyObject *compute_phases(indexObj'
1088 int parent_1, parent_2;
1091 int parent_1, parent_2;
1089 char *phases = NULL;
1092 char *phases = NULL;
1090 const char *data;
1093 const char *data;
1094 long phase;
1091
1095
1092 if (!PyArg_ParseTuple(args, "O", &roots))
1096 if (!PyArg_ParseTuple(args, "O", &roots))
1093 goto release_none;
1097 goto release_none;
@@ -1100,13 +1104,24 b' static PyObject *compute_phases(indexObj'
1100 /* Put the phase information of all the roots in phases */
1104 /* Put the phase information of all the roots in phases */
1101 numphase = PyList_GET_SIZE(roots)+1;
1105 numphase = PyList_GET_SIZE(roots)+1;
1102 minrevallphases = len + 1;
1106 minrevallphases = len + 1;
1107 phasessetlist = PyList_New(numphase);
1108 if (phasessetlist == NULL)
1109 goto release_none;
1110
1111 PyList_SET_ITEM(phasessetlist, 0, Py_None);
1112 Py_INCREF(Py_None);
1113
1103 for (i = 0; i < numphase-1; i++) {
1114 for (i = 0; i < numphase-1; i++) {
1104 phaseroots = PyList_GET_ITEM(roots, i);
1115 phaseroots = PyList_GET_ITEM(roots, i);
1116 phaseset = PySet_New(NULL);
1117 if (phaseset == NULL)
1118 goto release_phasesetlist;
1119 PyList_SET_ITEM(phasessetlist, i+1, phaseset);
1105 if (!PyList_Check(phaseroots))
1120 if (!PyList_Check(phaseroots))
1106 goto release_phases;
1121 goto release_phasesetlist;
1107 minrevphase = add_roots_get_min(self, phaseroots, i+1, phases);
1122 minrevphase = add_roots_get_min(self, phaseroots, i+1, phases);
1108 if (minrevphase == -2) /* Error from add_roots_get_min */
1123 if (minrevphase == -2) /* Error from add_roots_get_min */
1109 goto release_phases;
1124 goto release_phasesetlist;
1110 minrevallphases = MIN(minrevallphases, minrevphase);
1125 minrevallphases = MIN(minrevallphases, minrevphase);
1111 }
1126 }
1112 /* Propagate the phase information from the roots to the revs */
1127 /* Propagate the phase information from the roots to the revs */
@@ -1121,7 +1136,7 b' static PyObject *compute_phases(indexObj'
1121 p2 = PyTuple_GET_ITEM(rev, 6);
1136 p2 = PyTuple_GET_ITEM(rev, 6);
1122 if (!PyInt_Check(p1) || !PyInt_Check(p2)) {
1137 if (!PyInt_Check(p1) || !PyInt_Check(p2)) {
1123 PyErr_SetString(PyExc_TypeError, "revlog parents are invalid");
1138 PyErr_SetString(PyExc_TypeError, "revlog parents are invalid");
1124 goto release_phases;
1139 goto release_phasesetlist;
1125 }
1140 }
1126 parent_1 = (int)PyInt_AS_LONG(p1);
1141 parent_1 = (int)PyInt_AS_LONG(p1);
1127 parent_2 = (int)PyInt_AS_LONG(p2);
1142 parent_2 = (int)PyInt_AS_LONG(p2);
@@ -1131,14 +1146,35 b' static PyObject *compute_phases(indexObj'
1131 /* Transform phase list to a python list */
1146 /* Transform phase list to a python list */
1132 phaseslist = PyList_New(len);
1147 phaseslist = PyList_New(len);
1133 if (phaseslist == NULL)
1148 if (phaseslist == NULL)
1134 goto release_phases;
1149 goto release_phasesetlist;
1135 for (i = 0; i < len; i++)
1150 for (i = 0; i < len; i++) {
1136 PyList_SET_ITEM(phaseslist, i, PyInt_FromLong(phases[i]));
1151 phase = phases[i];
1152 /* We only store the sets of phase for non public phase, the public phase
1153 * is computed as a difference */
1154 if (phase != 0) {
1155 phaseset = PyList_GET_ITEM(phasessetlist, phase);
1156 PySet_Add(phaseset, PyInt_FromLong(i));
1157 }
1158 PyList_SET_ITEM(phaseslist, i, PyInt_FromLong(phase));
1159 }
1160 ret = PyList_New(2);
1161 if (ret == NULL)
1162 goto release_phaseslist;
1137
1163
1164 PyList_SET_ITEM(ret, 0, phaseslist);
1165 PyList_SET_ITEM(ret, 1, phasessetlist);
1166 /* We don't release phaseslist and phasessetlist as we return them to
1167 * python */
1168 goto release_phases;
1169
1170 release_phaseslist:
1171 Py_XDECREF(phaseslist);
1172 release_phasesetlist:
1173 Py_XDECREF(phasessetlist);
1138 release_phases:
1174 release_phases:
1139 free(phases);
1175 free(phases);
1140 release_none:
1176 release_none:
1141 return phaseslist;
1177 return ret;
1142 }
1178 }
1143
1179
1144 static PyObject *index_headrevs(indexObject *self, PyObject *args)
1180 static PyObject *index_headrevs(indexObject *self, PyObject *args)
@@ -2278,8 +2314,8 b' static PyMethodDef index_methods[] = {'
2278 "clear the index caches"},
2314 "clear the index caches"},
2279 {"get", (PyCFunction)index_m_get, METH_VARARGS,
2315 {"get", (PyCFunction)index_m_get, METH_VARARGS,
2280 "get an index entry"},
2316 "get an index entry"},
2281 {"computephases", (PyCFunction)compute_phases, METH_VARARGS,
2317 {"computephasesmapsets", (PyCFunction)compute_phases_map_sets,
2282 "compute phases"},
2318 METH_VARARGS, "compute phases"},
2283 {"headrevs", (PyCFunction)index_headrevs, METH_VARARGS,
2319 {"headrevs", (PyCFunction)index_headrevs, METH_VARARGS,
2284 "get head revisions"}, /* Can do filtering since 3.2 */
2320 "get head revisions"}, /* Can do filtering since 3.2 */
2285 {"headrevsfiltered", (PyCFunction)index_headrevs, METH_VARARGS,
2321 {"headrevsfiltered", (PyCFunction)index_headrevs, METH_VARARGS,
@@ -155,6 +155,7 b' class phasecache(object):'
155 # Cheap trick to allow shallow-copy without copy module
155 # Cheap trick to allow shallow-copy without copy module
156 self.phaseroots, self.dirty = _readroots(repo, phasedefaults)
156 self.phaseroots, self.dirty = _readroots(repo, phasedefaults)
157 self._phaserevs = None
157 self._phaserevs = None
158 self._phasesets = None
158 self.filterunknown(repo)
159 self.filterunknown(repo)
159 self.opener = repo.svfs
160 self.opener = repo.svfs
160
161
@@ -177,7 +178,7 b' class phasecache(object):'
177 nativeroots = []
178 nativeroots = []
178 for phase in trackedphases:
179 for phase in trackedphases:
179 nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase]))
180 nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase]))
180 return repo.changelog.computephases(nativeroots)
181 return repo.changelog.computephasesmapsets(nativeroots)
181
182
182 def _computephaserevspure(self, repo):
183 def _computephaserevspure(self, repo):
183 repo = repo.unfiltered()
184 repo = repo.unfiltered()
@@ -199,7 +200,8 b' class phasecache(object):'
199 'nativephaseskillswitch'):
200 'nativephaseskillswitch'):
200 self._computephaserevspure(repo)
201 self._computephaserevspure(repo)
201 else:
202 else:
202 self._phaserevs = self._getphaserevsnative(repo)
203 res = self._getphaserevsnative(repo)
204 self._phaserevs, self._phasesets = res
203 except AttributeError:
205 except AttributeError:
204 self._computephaserevspure(repo)
206 self._computephaserevspure(repo)
205 return self._phaserevs
207 return self._phaserevs
General Comments 0
You need to be logged in to leave comments. Login now