comparison rust/hg-core/src/repo.rs @ 47374:bd88b6bfd8da

rhg: Add support for dirstate-v2 Differential Revision: https://phab.mercurial-scm.org/D10804
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 25 May 2021 09:20:30 +0200
parents c71e8d9e7f2a
children ebdef6283798
comparison
equal deleted inserted replaced
47373:d2fb8b4adcc3 47374:bd88b6bfd8da
216 Vfs { 216 Vfs {
217 base: &self.working_directory, 217 base: &self.working_directory,
218 } 218 }
219 } 219 }
220 220
221 pub fn has_dirstate_v2(&self) -> bool {
222 self.requirements
223 .contains(requirements::DIRSTATE_V2_REQUIREMENT)
224 }
225
221 pub fn dirstate_parents( 226 pub fn dirstate_parents(
222 &self, 227 &self,
223 ) -> Result<crate::dirstate::DirstateParents, HgError> { 228 ) -> Result<crate::dirstate::DirstateParents, HgError> {
224 let dirstate = self.hg_vfs().mmap_open("dirstate")?; 229 let dirstate = self.hg_vfs().mmap_open("dirstate")?;
225 let parents = 230 if dirstate.is_empty() {
226 crate::dirstate::parsers::parse_dirstate_parents(&dirstate)?; 231 return Ok(crate::dirstate::DirstateParents::NULL);
232 }
233 let parents = if self.has_dirstate_v2() {
234 crate::dirstate_tree::on_disk::parse_dirstate_parents(&dirstate)?
235 } else {
236 crate::dirstate::parsers::parse_dirstate_parents(&dirstate)?
237 };
227 Ok(parents.clone()) 238 Ok(parents.clone())
228 } 239 }
229 } 240 }
230 241
231 impl Vfs<'_> { 242 impl Vfs<'_> {