Show More
@@ -164,11 +164,13 b' class PersistentNodeMapIndexObject(Index' | |||||
164 | """ |
|
164 | """ | |
165 | if self._nm_root is None: |
|
165 | if self._nm_root is None: | |
166 | return None |
|
166 | return None | |
|
167 | docket = self._nm_docket | |||
167 | changed, data = nodemaputil.update_persistent_data( |
|
168 | changed, data = nodemaputil.update_persistent_data( | |
168 | self, self._nm_root, self._nm_max_idx, self._nm_rev |
|
169 | self, self._nm_root, self._nm_max_idx, self._nm_docket.tip_rev | |
169 | ) |
|
170 | ) | |
170 | self._nm_root = self._nm_max_idx = self._nm_rev = None |
|
171 | ||
171 | return changed, data |
|
172 | self._nm_root = self._nm_max_idx = self._nm_docket = None | |
|
173 | return docket, changed, data | |||
172 |
|
174 | |||
173 | def update_nodemap_data(self, docket, nm_data): |
|
175 | def update_nodemap_data(self, docket, nm_data): | |
174 | """provide full block of persisted binary data for a nodemap |
|
176 | """provide full block of persisted binary data for a nodemap | |
@@ -178,9 +180,9 b' class PersistentNodeMapIndexObject(Index' | |||||
178 | if nm_data is not None: |
|
180 | if nm_data is not None: | |
179 | self._nm_root, self._nm_max_idx = nodemaputil.parse_data(nm_data) |
|
181 | self._nm_root, self._nm_max_idx = nodemaputil.parse_data(nm_data) | |
180 | if self._nm_root: |
|
182 | if self._nm_root: | |
181 |
self._nm_ |
|
183 | self._nm_docket = docket | |
182 | else: |
|
184 | else: | |
183 |
self._nm_root = self._nm_max_idx = self._nm_ |
|
185 | self._nm_root = self._nm_max_idx = self._nm_docket = None | |
184 |
|
186 | |||
185 |
|
187 | |||
186 | class InlinedIndexObject(BaseIndexObject): |
|
188 | class InlinedIndexObject(BaseIndexObject): |
@@ -77,18 +77,27 b' def _persist_nodemap(tr, revlog):' | |||||
77 | can_incremental = util.safehasattr(revlog.index, "nodemap_data_incremental") |
|
77 | can_incremental = util.safehasattr(revlog.index, "nodemap_data_incremental") | |
78 | ondisk_docket = revlog._nodemap_docket |
|
78 | ondisk_docket = revlog._nodemap_docket | |
79 |
|
79 | |||
|
80 | data = None | |||
80 | # first attemp an incremental update of the data |
|
81 | # first attemp an incremental update of the data | |
81 | if can_incremental and ondisk_docket is not None: |
|
82 | if can_incremental and ondisk_docket is not None: | |
82 | target_docket = revlog._nodemap_docket.copy() |
|
83 | target_docket = revlog._nodemap_docket.copy() | |
83 | data_changed_count, data = revlog.index.nodemap_data_incremental() |
|
84 | ( | |
84 | datafile = _rawdata_filepath(revlog, target_docket) |
|
85 | src_docket, | |
85 | # EXP-TODO: if this is a cache, this should use a cache vfs, not a |
|
86 | data_changed_count, | |
86 | # store vfs |
|
87 | data, | |
87 | with revlog.opener(datafile, b'a') as fd: |
|
88 | ) = revlog.index.nodemap_data_incremental() | |
88 | fd.write(data) |
|
89 | if src_docket != target_docket: | |
89 | target_docket.data_length += len(data) |
|
90 | data = None | |
90 | target_docket.data_unused += data_changed_count |
|
91 | else: | |
91 | else: |
|
92 | datafile = _rawdata_filepath(revlog, target_docket) | |
|
93 | # EXP-TODO: if this is a cache, this should use a cache vfs, not a | |||
|
94 | # store vfs | |||
|
95 | with revlog.opener(datafile, b'a') as fd: | |||
|
96 | fd.write(data) | |||
|
97 | target_docket.data_length += len(data) | |||
|
98 | target_docket.data_unused += data_changed_count | |||
|
99 | ||||
|
100 | if data is None: | |||
92 | # otherwise fallback to a full new export |
|
101 | # otherwise fallback to a full new export | |
93 | target_docket = NodeMapDocket() |
|
102 | target_docket = NodeMapDocket() | |
94 | datafile = _rawdata_filepath(revlog, target_docket) |
|
103 | datafile = _rawdata_filepath(revlog, target_docket) | |
@@ -182,6 +191,20 b' class NodeMapDocket(object):' | |||||
182 | new.data_unused = self.data_unused |
|
191 | new.data_unused = self.data_unused | |
183 | return new |
|
192 | return new | |
184 |
|
193 | |||
|
194 | def __cmp__(self, other): | |||
|
195 | if self.uid < other.uid: | |||
|
196 | return -1 | |||
|
197 | if self.uid > other.uid: | |||
|
198 | return 1 | |||
|
199 | elif self.data_length < other.data_length: | |||
|
200 | return -1 | |||
|
201 | elif self.data_length > other.data_length: | |||
|
202 | return 1 | |||
|
203 | return 0 | |||
|
204 | ||||
|
205 | def __eq__(self, other): | |||
|
206 | return self.uid == other.uid and self.data_length == other.data_length | |||
|
207 | ||||
185 | def serialize(self): |
|
208 | def serialize(self): | |
186 | """return serialized bytes for a docket using the passed uid""" |
|
209 | """return serialized bytes for a docket using the passed uid""" | |
187 | data = [] |
|
210 | data = [] |
General Comments 0
You need to be logged in to leave comments.
Login now