equal
deleted
inserted
replaced
99 int ntlookups; /* # lookups */ |
99 int ntlookups; /* # lookups */ |
100 int ntmisses; /* # lookups that miss the cache */ |
100 int ntmisses; /* # lookups that miss the cache */ |
101 int inlined; |
101 int inlined; |
102 long entry_size; /* size of index headers. Differs in v1 v.s. v2 format |
102 long entry_size; /* size of index headers. Differs in v1 v.s. v2 format |
103 */ |
103 */ |
|
104 char format_version; /* size of index headers. Differs in v1 v.s. v2 |
|
105 format */ |
104 }; |
106 }; |
105 |
107 |
106 static Py_ssize_t index_length(const indexObject *self) |
108 static Py_ssize_t index_length(const indexObject *self) |
107 { |
109 { |
108 return self->length + self->new_length; |
110 return self->length + self->new_length; |
126 /* A RevlogNG v1 index entry is 64 bytes long. */ |
128 /* A RevlogNG v1 index entry is 64 bytes long. */ |
127 static const long v1_entry_size = 64; |
129 static const long v1_entry_size = 64; |
128 |
130 |
129 /* A Revlogv2 index entry is 96 bytes long. */ |
131 /* A Revlogv2 index entry is 96 bytes long. */ |
130 static const long v2_entry_size = 96; |
132 static const long v2_entry_size = 96; |
|
133 |
|
134 static const long format_v1 = 1; /* Internal only, could be any number */ |
|
135 static const long format_v2 = 2; /* Internal only, could be any number */ |
131 |
136 |
132 static void raise_revlog_error(void) |
137 static void raise_revlog_error(void) |
133 { |
138 { |
134 PyObject *mod = NULL, *dict = NULL, *errclass = NULL; |
139 PyObject *mod = NULL, *dict = NULL, *errclass = NULL; |
135 |
140 |
2755 PyErr_SetString(PyExc_RuntimeError, "unsupported node size"); |
2760 PyErr_SetString(PyExc_RuntimeError, "unsupported node size"); |
2756 return -1; |
2761 return -1; |
2757 } |
2762 } |
2758 |
2763 |
2759 if (revlogv2 && PyObject_IsTrue(revlogv2)) { |
2764 if (revlogv2 && PyObject_IsTrue(revlogv2)) { |
|
2765 self->format_version = format_v2; |
2760 self->entry_size = v2_entry_size; |
2766 self->entry_size = v2_entry_size; |
2761 } else { |
2767 } else { |
|
2768 self->format_version = format_v1; |
2762 self->entry_size = v1_entry_size; |
2769 self->entry_size = v1_entry_size; |
2763 } |
2770 } |
2764 |
2771 |
2765 if (self->entry_size == v1_entry_size) { |
2772 if (self->format_version == format_v1) { |
2766 self->nullentry = |
2773 self->nullentry = |
2767 Py_BuildValue(PY23("iiiiiiis#", "iiiiiiiy#"), 0, 0, 0, -1, |
2774 Py_BuildValue(PY23("iiiiiiis#", "iiiiiiiy#"), 0, 0, 0, -1, |
2768 -1, -1, -1, nullid, self->nodelen); |
2775 -1, -1, -1, nullid, self->nodelen); |
2769 } else { |
2776 } else { |
2770 self->nullentry = |
2777 self->nullentry = |