##// END OF EJS Templates
revlog: use the native implementation of issnapshot...
Boris Feld -
r41118:a28833d7 default
parent child Browse files
Show More
@@ -1029,6 +1029,27 b' static int index_issnapshotrev(indexObje'
1029 return rev == -1;
1029 return rev == -1;
1030 }
1030 }
1031
1031
1032 static PyObject *index_issnapshot(indexObject *self, PyObject *value)
1033 {
1034 long rev;
1035 int issnap;
1036 Py_ssize_t length = index_length(self);
1037
1038 if (!pylong_to_long(value, &rev)) {
1039 return NULL;
1040 }
1041 if (rev < -1 || rev >= length) {
1042 PyErr_Format(PyExc_ValueError, "revlog index out of range: %ld",
1043 rev);
1044 return NULL;
1045 };
1046 issnap = index_issnapshotrev(self, (Py_ssize_t)rev);
1047 if (issnap < 0) {
1048 return NULL;
1049 };
1050 return PyBool_FromLong((long)issnap);
1051 }
1052
1032 static PyObject *index_deltachain(indexObject *self, PyObject *args)
1053 static PyObject *index_deltachain(indexObject *self, PyObject *args)
1033 {
1054 {
1034 int rev, generaldelta;
1055 int rev, generaldelta;
@@ -2641,6 +2662,8 b' static PyMethodDef index_methods[] = {'
2641 "get head revisions"}, /* Can do filtering since 3.2 */
2662 "get head revisions"}, /* Can do filtering since 3.2 */
2642 {"headrevsfiltered", (PyCFunction)index_headrevs, METH_VARARGS,
2663 {"headrevsfiltered", (PyCFunction)index_headrevs, METH_VARARGS,
2643 "get filtered head revisions"}, /* Can always do filtering */
2664 "get filtered head revisions"}, /* Can always do filtering */
2665 {"issnapshot", (PyCFunction)index_issnapshot, METH_O,
2666 "True if the object is a snapshot"},
2644 {"deltachain", (PyCFunction)index_deltachain, METH_VARARGS,
2667 {"deltachain", (PyCFunction)index_deltachain, METH_VARARGS,
2645 "determine revisions with deltas to reconstruct fulltext"},
2668 "determine revisions with deltas to reconstruct fulltext"},
2646 {"slicechunktodensity", (PyCFunction)index_slicechunktodensity,
2669 {"slicechunktodensity", (PyCFunction)index_slicechunktodensity,
@@ -1533,14 +1533,18 b' class revlog(object):'
1533 def issnapshot(self, rev):
1533 def issnapshot(self, rev):
1534 """tells whether rev is a snapshot
1534 """tells whether rev is a snapshot
1535 """
1535 """
1536 if not self._sparserevlog:
1537 return self.deltaparent(rev) == nullrev
1538 elif util.safehasattr(self.index, 'issnapshot'):
1539 # directly assign the method to cache the testing and access
1540 self.issnapshot = self.index.issnapshot
1541 return self.issnapshot(rev)
1536 if rev == nullrev:
1542 if rev == nullrev:
1537 return True
1543 return True
1538 entry = self.index[rev]
1544 entry = self.index[rev]
1539 base = entry[3]
1545 base = entry[3]
1540 if base == rev:
1546 if base == rev:
1541 return True
1547 return True
1542 elif not self._sparserevlog:
1543 return False
1544 if base == nullrev:
1548 if base == nullrev:
1545 return True
1549 return True
1546 p1 = entry[5]
1550 p1 = entry[5]
General Comments 0
You need to be logged in to leave comments. Login now