##// END OF EJS Templates
debugstate: Always call dirstatemap.debug_iter()...
Simon Sapin -
r48835:357307fe default
parent child Browse files
Show More
@@ -968,10 +968,7 b' def debugstate(ui, repo, **opts):'
968 ) # sort by mtime, then by filename
968 ) # sort by mtime, then by filename
969 else:
969 else:
970 keyfunc = None # sort by filename
970 keyfunc = None # sort by filename
971 if opts['all']:
971 entries = list(repo.dirstate._map.debug_iter(all=opts['all']))
972 entries = list(repo.dirstate._map.debug_iter())
973 else:
974 entries = list(pycompat.iteritems(repo.dirstate))
975 entries.sort(key=keyfunc)
972 entries.sort(key=keyfunc)
976 for file_, ent in entries:
973 for file_, ent in entries:
977 if ent.v1_mtime() == -1:
974 if ent.v1_mtime() == -1:
@@ -118,7 +118,11 b' class dirstatemap(object):'
118 # forward for python2,3 compat
118 # forward for python2,3 compat
119 iteritems = items
119 iteritems = items
120
120
121 debug_iter = items
121 def debug_iter(self, all):
122 """
123 `all` is unused when Rust is not enabled
124 """
125 return self.item()
122
126
123 def __len__(self):
127 def __len__(self):
124 return len(self._map)
128 return len(self._map)
@@ -700,8 +704,8 b' if rustmod is not None:'
700 def copymap(self):
704 def copymap(self):
701 return self._rustmap.copymap()
705 return self._rustmap.copymap()
702
706
703 def debug_iter(self):
707 def debug_iter(self, all):
704 return self._rustmap.debug_iter()
708 return self._rustmap.debug_iter(all)
705
709
706 def preload(self):
710 def preload(self):
707 self._rustmap
711 self._rustmap
@@ -1289,6 +1289,7 b" impl<'on_disk> super::dispatch::Dirstate"
1289
1289
1290 fn debug_iter(
1290 fn debug_iter(
1291 &self,
1291 &self,
1292 all: bool,
1292 ) -> Box<
1293 ) -> Box<
1293 dyn Iterator<
1294 dyn Iterator<
1294 Item = Result<
1295 Item = Result<
@@ -1298,16 +1299,17 b" impl<'on_disk> super::dispatch::Dirstate"
1298 > + Send
1299 > + Send
1299 + '_,
1300 + '_,
1300 > {
1301 > {
1301 Box::new(self.iter_nodes().map(move |node| {
1302 Box::new(filter_map_results(self.iter_nodes(), move |node| {
1302 let node = node?;
1303 let debug_tuple = if let Some(entry) = node.entry()? {
1303 let debug_tuple = if let Some(entry) = node.entry()? {
1304 entry.debug_tuple()
1304 entry.debug_tuple()
1305 } else if !all {
1306 return Ok(None);
1305 } else if let Some(mtime) = node.cached_directory_mtime() {
1307 } else if let Some(mtime) = node.cached_directory_mtime() {
1306 (b' ', 0, -1, mtime.seconds() as i32)
1308 (b' ', 0, -1, mtime.seconds() as i32)
1307 } else {
1309 } else {
1308 (b' ', 0, -1, -1)
1310 (b' ', 0, -1, -1)
1309 };
1311 };
1310 Ok((node.full_path(self.on_disk)?, debug_tuple))
1312 Ok(Some((node.full_path(self.on_disk)?, debug_tuple)))
1311 }))
1313 }))
1312 }
1314 }
1313 }
1315 }
@@ -290,13 +290,15 b' pub trait DirstateMapMethods {'
290 /// node stored in this dirstate map, for the purpose of the `hg
290 /// node stored in this dirstate map, for the purpose of the `hg
291 /// debugdirstate` command.
291 /// debugdirstate` command.
292 ///
292 ///
293 /// For nodes that don’t have an entry, `state` is the ASCII space.
293 /// If `all` is true, include nodes that don’t have an entry.
294 /// For such nodes `state` is the ASCII space.
294 /// An `mtime` may still be present. It is used to optimize `status`.
295 /// An `mtime` may still be present. It is used to optimize `status`.
295 ///
296 ///
296 /// Because parse errors can happen during iteration, the iterated items
297 /// Because parse errors can happen during iteration, the iterated items
297 /// are `Result`s.
298 /// are `Result`s.
298 fn debug_iter(
299 fn debug_iter(
299 &self,
300 &self,
301 all: bool,
300 ) -> Box<
302 ) -> Box<
301 dyn Iterator<
303 dyn Iterator<
302 Item = Result<
304 Item = Result<
@@ -538,6 +540,7 b' impl DirstateMapMethods for DirstateMap '
538
540
539 fn debug_iter(
541 fn debug_iter(
540 &self,
542 &self,
543 all: bool,
541 ) -> Box<
544 ) -> Box<
542 dyn Iterator<
545 dyn Iterator<
543 Item = Result<
546 Item = Result<
@@ -547,6 +550,9 b' impl DirstateMapMethods for DirstateMap '
547 > + Send
550 > + Send
548 + '_,
551 + '_,
549 > {
552 > {
553 // Not used for the flat (not tree-based) DirstateMap
554 let _ = all;
555
550 Box::new(
556 Box::new(
551 (&**self)
557 (&**self)
552 .iter()
558 .iter()
@@ -226,6 +226,7 b' impl DirstateMapMethods for OwningDirsta'
226
226
227 fn debug_iter(
227 fn debug_iter(
228 &self,
228 &self,
229 all: bool,
229 ) -> Box<
230 ) -> Box<
230 dyn Iterator<
231 dyn Iterator<
231 Item = Result<
232 Item = Result<
@@ -235,6 +236,6 b' impl DirstateMapMethods for OwningDirsta'
235 > + Send
236 > + Send
236 + '_,
237 + '_,
237 > {
238 > {
238 self.get().debug_iter()
239 self.get().debug_iter(all)
239 }
240 }
240 }
241 }
@@ -606,9 +606,9 b' py_class!(pub class DirstateMap |py| {'
606 Ok(dirs)
606 Ok(dirs)
607 }
607 }
608
608
609 def debug_iter(&self) -> PyResult<PyList> {
609 def debug_iter(&self, all: bool) -> PyResult<PyList> {
610 let dirs = PyList::new(py, &[]);
610 let dirs = PyList::new(py, &[]);
611 for item in self.inner(py).borrow().debug_iter() {
611 for item in self.inner(py).borrow().debug_iter(all) {
612 let (path, (state, mode, size, mtime)) =
612 let (path, (state, mode, size, mtime)) =
613 item.map_err(|e| v2_error(py, e))?;
613 item.map_err(|e| v2_error(py, e))?;
614 let path = PyBytes::new(py, path.as_bytes());
614 let path = PyBytes::new(py, path.as_bytes());
General Comments 0
You need to be logged in to leave comments. Login now