##// END OF EJS Templates
rank: add a "rank" value to the revlog-entry tuple...
marmoute -
r49330:52034c42 default
parent child Browse files
Show More
@@ -120,9 +120,11 b' static Py_ssize_t inline_scan(indexObjec'
120 static int index_find_node(indexObject *self, const char *node);
120 static int index_find_node(indexObject *self, const char *node);
121
121
122 #if LONG_MAX == 0x7fffffffL
122 #if LONG_MAX == 0x7fffffffL
123 static const char *const tuple_format = PY23("Kiiiiiis#KiBB", "Kiiiiiiy#KiBB");
123 static const char *const tuple_format =
124 PY23("Kiiiiiis#KiBBi", "Kiiiiiiy#KiBBi");
124 #else
125 #else
125 static const char *const tuple_format = PY23("kiiiiiis#kiBB", "kiiiiiiy#kiBB");
126 static const char *const tuple_format =
127 PY23("kiiiiiis#kiBBi", "kiiiiiiy#kiBBi");
126 #endif
128 #endif
127
129
128 /* A RevlogNG v1 index entry is 64 bytes long. */
130 /* A RevlogNG v1 index entry is 64 bytes long. */
@@ -135,6 +137,7 b' static const long format_v1 = 1; /* Inte'
135 static const long format_v2 = 2; /* Internal only, could be any number */
137 static const long format_v2 = 2; /* Internal only, could be any number */
136
138
137 static const char comp_mode_inline = 2;
139 static const char comp_mode_inline = 2;
140 static const char rank_unknown = -1;
138
141
139 static void raise_revlog_error(void)
142 static void raise_revlog_error(void)
140 {
143 {
@@ -352,7 +355,7 b' static PyObject *index_get(indexObject *'
352 return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len,
355 return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len,
353 base_rev, link_rev, parent_1, parent_2, c_node_id,
356 base_rev, link_rev, parent_1, parent_2, c_node_id,
354 self->nodelen, sidedata_offset, sidedata_comp_len,
357 self->nodelen, sidedata_offset, sidedata_comp_len,
355 data_comp_mode, sidedata_comp_mode);
358 data_comp_mode, sidedata_comp_mode, rank_unknown);
356 }
359 }
357 /*
360 /*
358 * Pack header information in binary
361 * Pack header information in binary
@@ -453,7 +456,7 b' static PyObject *index_append(indexObjec'
453 {
456 {
454 uint64_t offset_flags, sidedata_offset;
457 uint64_t offset_flags, sidedata_offset;
455 int rev, comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2,
458 int rev, comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2,
456 sidedata_comp_len;
459 sidedata_comp_len, rank;
457 char data_comp_mode, sidedata_comp_mode;
460 char data_comp_mode, sidedata_comp_mode;
458 Py_ssize_t c_node_id_len;
461 Py_ssize_t c_node_id_len;
459 const char *c_node_id;
462 const char *c_node_id;
@@ -464,8 +467,8 b' static PyObject *index_append(indexObjec'
464 &uncomp_len, &base_rev, &link_rev, &parent_1,
467 &uncomp_len, &base_rev, &link_rev, &parent_1,
465 &parent_2, &c_node_id, &c_node_id_len,
468 &parent_2, &c_node_id, &c_node_id_len,
466 &sidedata_offset, &sidedata_comp_len,
469 &sidedata_offset, &sidedata_comp_len,
467 &data_comp_mode, &sidedata_comp_mode)) {
470 &data_comp_mode, &sidedata_comp_mode, &rank)) {
468 PyErr_SetString(PyExc_TypeError, "11-tuple required");
471 PyErr_SetString(PyExc_TypeError, "12-tuple required");
469 return NULL;
472 return NULL;
470 }
473 }
471
474
@@ -2797,9 +2800,10 b' static int index_init(indexObject *self,'
2797 self->entry_size = v1_entry_size;
2800 self->entry_size = v1_entry_size;
2798 }
2801 }
2799
2802
2800 self->nullentry = Py_BuildValue(
2803 self->nullentry =
2801 PY23("iiiiiiis#iiBB", "iiiiiiiy#iiBB"), 0, 0, 0, -1, -1, -1, -1,
2804 Py_BuildValue(PY23("iiiiiiis#iiBBi", "iiiiiiiy#iiBBi"), 0, 0, 0, -1,
2802 nullid, self->nodelen, 0, 0, comp_mode_inline, comp_mode_inline);
2805 -1, -1, -1, nullid, self->nodelen, 0, 0,
2806 comp_mode_inline, comp_mode_inline, rank_unknown);
2803
2807
2804 if (!self->nullentry)
2808 if (!self->nullentry)
2805 return -1;
2809 return -1;
@@ -584,6 +584,7 b' class BaseIndexObject(object):'
584 0,
584 0,
585 revlog_constants.COMP_MODE_INLINE,
585 revlog_constants.COMP_MODE_INLINE,
586 revlog_constants.COMP_MODE_INLINE,
586 revlog_constants.COMP_MODE_INLINE,
587 revlog_constants.RANK_UNKNOWN,
587 )
588 )
588
589
589 @util.propertycache
590 @util.propertycache
@@ -671,6 +672,7 b' class BaseIndexObject(object):'
671 0,
672 0,
672 revlog_constants.COMP_MODE_INLINE,
673 revlog_constants.COMP_MODE_INLINE,
673 revlog_constants.COMP_MODE_INLINE,
674 revlog_constants.COMP_MODE_INLINE,
675 revlog_constants.RANK_UNKNOWN,
674 )
676 )
675 return r
677 return r
676
678
@@ -853,7 +855,7 b' class IndexObject2(IndexObject):'
853 entry = data[:10]
855 entry = data[:10]
854 data_comp = data[10] & 3
856 data_comp = data[10] & 3
855 sidedata_comp = (data[10] & (3 << 2)) >> 2
857 sidedata_comp = (data[10] & (3 << 2)) >> 2
856 return entry + (data_comp, sidedata_comp)
858 return entry + (data_comp, sidedata_comp, revlog_constants.RANK_UNKNOWN)
857
859
858 def _pack_entry(self, rev, entry):
860 def _pack_entry(self, rev, entry):
859 data = entry[:10]
861 data = entry[:10]
@@ -896,6 +898,7 b' class IndexChangelogV2(IndexObject2):'
896 items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3,
898 items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3,
897 (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2)
899 (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2)
898 & 3,
900 & 3,
901 revlog_constants.RANK_UNKNOWN,
899 )
902 )
900
903
901 def _pack_entry(self, rev, entry):
904 def _pack_entry(self, rev, entry):
@@ -12,6 +12,7 b' from ..interfaces import repository'
12
12
13 # See mercurial.revlogutils.constants for doc
13 # See mercurial.revlogutils.constants for doc
14 COMP_MODE_INLINE = 2
14 COMP_MODE_INLINE = 2
15 RANK_UNKNOWN = -1
15
16
16
17
17 def offset_type(offset, type):
18 def offset_type(offset, type):
@@ -34,6 +35,7 b' def entry('
34 sidedata_offset=0,
35 sidedata_offset=0,
35 sidedata_compressed_length=0,
36 sidedata_compressed_length=0,
36 sidedata_compression_mode=COMP_MODE_INLINE,
37 sidedata_compression_mode=COMP_MODE_INLINE,
38 rank=RANK_UNKNOWN,
37 ):
39 ):
38 """Build one entry from symbolic name
40 """Build one entry from symbolic name
39
41
@@ -56,6 +58,7 b' def entry('
56 sidedata_compressed_length,
58 sidedata_compressed_length,
57 data_compression_mode,
59 data_compression_mode,
58 sidedata_compression_mode,
60 sidedata_compression_mode,
61 rank,
59 )
62 )
60
63
61
64
@@ -103,6 +103,17 b' ENTRY_DATA_COMPRESSION_MODE = 10'
103 # (see "COMP_MODE_*" constants for details)
103 # (see "COMP_MODE_*" constants for details)
104 ENTRY_SIDEDATA_COMPRESSION_MODE = 11
104 ENTRY_SIDEDATA_COMPRESSION_MODE = 11
105
105
106 # [12] Revision rank:
107 # The number of revision under this one.
108 #
109 # Formally this is defined as : rank(X) = len(ancestors(X) + X)
110 #
111 # If rank == -1; then we do not have this information available.
112 # Only `null` has a rank of 0.
113 ENTRY_RANK = 12
114
115 RANK_UNKNOWN = -1
116
106 ### main revlog header
117 ### main revlog header
107
118
108 # We cannot rely on Struct.format is inconsistent for python <=3.6 versus above
119 # We cannot rely on Struct.format is inconsistent for python <=3.6 versus above
@@ -71,6 +71,7 b' class unionrevlog(revlog.revlog):'
71 _sds,
71 _sds,
72 _dcm,
72 _dcm,
73 _sdcm,
73 _sdcm,
74 rank,
74 ) = rev
75 ) = rev
75 flags = _start & 0xFFFF
76 flags = _start & 0xFFFF
76
77
@@ -107,6 +108,7 b' class unionrevlog(revlog.revlog):'
107 0, # sidedata size
108 0, # sidedata size
108 revlog_constants.COMP_MODE_INLINE,
109 revlog_constants.COMP_MODE_INLINE,
109 revlog_constants.COMP_MODE_INLINE,
110 revlog_constants.COMP_MODE_INLINE,
111 rank,
110 )
112 )
111 self.index.append(e)
113 self.index.append(e)
112 self.bundlerevs.add(n)
114 self.bundlerevs.add(n)
@@ -57,6 +57,7 b' def py_parseindex(data, inline):'
57 0,
57 0,
58 constants.COMP_MODE_INLINE,
58 constants.COMP_MODE_INLINE,
59 constants.COMP_MODE_INLINE,
59 constants.COMP_MODE_INLINE,
60 constants.RANK_UNKNOWN,
60 )
61 )
61 nodemap[e[7]] = n
62 nodemap[e[7]] = n
62 append(e)
63 append(e)
@@ -72,6 +73,7 b' def py_parseindex(data, inline):'
72 0,
73 0,
73 constants.COMP_MODE_INLINE,
74 constants.COMP_MODE_INLINE,
74 constants.COMP_MODE_INLINE,
75 constants.COMP_MODE_INLINE,
76 constants.RANK_UNKNOWN,
75 )
77 )
76 nodemap[e[7]] = n
78 nodemap[e[7]] = n
77 append(e)
79 append(e)
@@ -268,6 +270,7 b' class parseindex2tests(unittest.TestCase'
268 0,
270 0,
269 constants.COMP_MODE_INLINE,
271 constants.COMP_MODE_INLINE,
270 constants.COMP_MODE_INLINE,
272 constants.COMP_MODE_INLINE,
273 constants.RANK_UNKNOWN,
271 )
274 )
272 index, junk = parsers.parse_index2(data_inlined, True)
275 index, junk = parsers.parse_index2(data_inlined, True)
273 got = index[-1]
276 got = index[-1]
@@ -303,6 +306,7 b' class parseindex2tests(unittest.TestCase'
303 0,
306 0,
304 constants.COMP_MODE_INLINE,
307 constants.COMP_MODE_INLINE,
305 constants.COMP_MODE_INLINE,
308 constants.COMP_MODE_INLINE,
309 constants.RANK_UNKNOWN,
306 )
310 )
307 index.append(e)
311 index.append(e)
308
312
General Comments 0
You need to be logged in to leave comments. Login now