Show More
@@ -232,7 +232,16 b' impl Repo {' | |||||
232 | try_with_lock_no_wait(self.hg_vfs(), "wlock", f) |
|
232 | try_with_lock_no_wait(self.hg_vfs(), "wlock", f) | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | pub fn has_dirstate_v2(&self) -> bool { |
|
235 | /// Whether this repo should use dirstate-v2. | |
|
236 | /// The presence of `dirstate-v2` in the requirements does not mean that | |||
|
237 | /// the on-disk dirstate is necessarily in version 2. In most cases, | |||
|
238 | /// a dirstate-v2 file will indeed be found, but in rare cases (like the | |||
|
239 | /// upgrade mechanism being cut short), the on-disk version will be a | |||
|
240 | /// v1 file. | |||
|
241 | /// Semantically, having a requirement only means that a client should be | |||
|
242 | /// able to understand the repo *if* it uses the requirement, but not that | |||
|
243 | /// the requirement is actually used. | |||
|
244 | pub fn use_dirstate_v2(&self) -> bool { | |||
236 | self.requirements |
|
245 | self.requirements | |
237 | .contains(requirements::DIRSTATE_V2_REQUIREMENT) |
|
246 | .contains(requirements::DIRSTATE_V2_REQUIREMENT) | |
238 | } |
|
247 | } | |
@@ -277,7 +286,7 b' impl Repo {' | |||||
277 | let dirstate = self.dirstate_file_contents()?; |
|
286 | let dirstate = self.dirstate_file_contents()?; | |
278 | let parents = if dirstate.is_empty() { |
|
287 | let parents = if dirstate.is_empty() { | |
279 | DirstateParents::NULL |
|
288 | DirstateParents::NULL | |
280 |
} else if self. |
|
289 | } else if self.use_dirstate_v2() { | |
281 | let docket = |
|
290 | let docket = | |
282 | crate::dirstate_tree::on_disk::read_docket(&dirstate)?; |
|
291 | crate::dirstate_tree::on_disk::read_docket(&dirstate)?; | |
283 | docket.parents() |
|
292 | docket.parents() | |
@@ -296,7 +305,7 b' impl Repo {' | |||||
296 | &self, |
|
305 | &self, | |
297 | ) -> Result<DirstateMapIdentity, HgError> { |
|
306 | ) -> Result<DirstateMapIdentity, HgError> { | |
298 | assert!( |
|
307 | assert!( | |
299 |
self. |
|
308 | self.use_dirstate_v2(), | |
300 | "accessing dirstate data file ID without dirstate-v2" |
|
309 | "accessing dirstate data file ID without dirstate-v2" | |
301 | ); |
|
310 | ); | |
302 | // Get the identity before the contents since we could have a race |
|
311 | // Get the identity before the contents since we could have a race | |
@@ -316,7 +325,7 b' impl Repo {' | |||||
316 | } |
|
325 | } | |
317 |
|
326 | |||
318 | fn new_dirstate_map(&self) -> Result<OwningDirstateMap, DirstateError> { |
|
327 | fn new_dirstate_map(&self) -> Result<OwningDirstateMap, DirstateError> { | |
319 |
if self. |
|
328 | if self.use_dirstate_v2() { | |
320 | // The v2 dirstate is split into a docket and a data file. |
|
329 | // The v2 dirstate is split into a docket and a data file. | |
321 | // Since we don't always take the `wlock` to read it |
|
330 | // Since we don't always take the `wlock` to read it | |
322 | // (like in `hg status`), it is susceptible to races. |
|
331 | // (like in `hg status`), it is susceptible to races. | |
@@ -550,7 +559,7 b' impl Repo {' | |||||
550 | // TODO: Maintain a `DirstateMap::dirty` flag, and return early here if |
|
559 | // TODO: Maintain a `DirstateMap::dirty` flag, and return early here if | |
551 | // it’s unset |
|
560 | // it’s unset | |
552 | let parents = self.dirstate_parents()?; |
|
561 | let parents = self.dirstate_parents()?; | |
553 |
let (packed_dirstate, old_uuid_to_remove) = if self. |
|
562 | let (packed_dirstate, old_uuid_to_remove) = if self.use_dirstate_v2() { | |
554 | let (identity, uuid, data_size) = |
|
563 | let (identity, uuid, data_size) = | |
555 | self.get_dirstate_data_file_integrity()?; |
|
564 | self.get_dirstate_data_file_integrity()?; | |
556 | let identity_changed = identity != map.old_identity(); |
|
565 | let identity_changed = identity != map.old_identity(); |
General Comments 0
You need to be logged in to leave comments.
Login now