##// END OF EJS Templates
debugsate: Change debug_iter() to yield tuples instead of DirstateItem...
Simon Sapin -
r48836:cedfe260 default
parent child Browse files
Show More
@@ -962,32 +962,29 b' def debugstate(ui, repo, **opts):'
962 datesort = opts.get('datesort')
962 datesort = opts.get('datesort')
963
963
964 if datesort:
964 if datesort:
965 keyfunc = lambda x: (
965
966 x[1].v1_mtime(),
966 def keyfunc(entry):
967 x[0],
967 filename, _state, _mode, _size, mtime = entry
968 ) # sort by mtime, then by filename
968 return (mtime, filename)
969
969 else:
970 else:
970 keyfunc = None # sort by filename
971 keyfunc = None # sort by filename
971 entries = list(repo.dirstate._map.debug_iter(all=opts['all']))
972 entries = list(repo.dirstate._map.debug_iter(all=opts['all']))
972 entries.sort(key=keyfunc)
973 entries.sort(key=keyfunc)
973 for file_, ent in entries:
974 for entry in entries:
974 if ent.v1_mtime() == -1:
975 filename, state, mode, size, mtime = entry
976 if mtime == -1:
975 timestr = b'unset '
977 timestr = b'unset '
976 elif nodates:
978 elif nodates:
977 timestr = b'set '
979 timestr = b'set '
978 else:
980 else:
979 timestr = time.strftime(
981 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(mtime))
980 "%Y-%m-%d %H:%M:%S ", time.localtime(ent.v1_mtime())
981 )
982 timestr = encoding.strtolocal(timestr)
982 timestr = encoding.strtolocal(timestr)
983 if ent.mode & 0o20000:
983 if mode & 0o20000:
984 mode = b'lnk'
984 mode = b'lnk'
985 else:
985 else:
986 mode = b'%3o' % (ent.v1_mode() & 0o777 & ~util.umask)
986 mode = b'%3o' % (mode & 0o777 & ~util.umask)
987 ui.write(
987 ui.write(b"%c %s %10d %s%s\n" % (state, mode, size, timestr, filename))
988 b"%c %s %10d %s%s\n"
989 % (ent.v1_state(), mode, ent.v1_size(), timestr, file_)
990 )
991 for f in repo.dirstate.copies():
988 for f in repo.dirstate.copies():
992 ui.write(_(b"copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
989 ui.write(_(b"copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
993
990
@@ -120,9 +120,12 b' class dirstatemap(object):'
120
120
121 def debug_iter(self, all):
121 def debug_iter(self, all):
122 """
122 """
123 Return an iterator of (filename, state, mode, size, mtime) tuples
124
123 `all` is unused when Rust is not enabled
125 `all` is unused when Rust is not enabled
124 """
126 """
125 return self.item()
127 for (filename, item) in self.items():
128 yield (filename, item.state, item.mode, item.size, item.mtime)
126
129
127 def __len__(self):
130 def __len__(self):
128 return len(self._map)
131 return len(self._map)
@@ -705,6 +708,13 b' if rustmod is not None:'
705 return self._rustmap.copymap()
708 return self._rustmap.copymap()
706
709
707 def debug_iter(self, all):
710 def debug_iter(self, all):
711 """
712 Return an iterator of (filename, state, mode, size, mtime) tuples
713
714 `all`: also include with `state == b' '` dirstate tree nodes that
715 don't have an associated `DirstateItem`.
716
717 """
708 return self._rustmap.debug_iter(all)
718 return self._rustmap.debug_iter(all)
709
719
710 def preload(self):
720 def preload(self):
@@ -20,7 +20,6 b' use cpython::{'
20 use crate::{
20 use crate::{
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
22 dirstate::make_dirstate_item,
22 dirstate::make_dirstate_item,
23 dirstate::make_dirstate_item_raw,
24 dirstate::non_normal_entries::{
23 dirstate::non_normal_entries::{
25 NonNormalEntries, NonNormalEntriesIterator,
24 NonNormalEntries, NonNormalEntriesIterator,
26 },
25 },
@@ -612,8 +611,8 b' py_class!(pub class DirstateMap |py| {'
612 let (path, (state, mode, size, mtime)) =
611 let (path, (state, mode, size, mtime)) =
613 item.map_err(|e| v2_error(py, e))?;
612 item.map_err(|e| v2_error(py, e))?;
614 let path = PyBytes::new(py, path.as_bytes());
613 let path = PyBytes::new(py, path.as_bytes());
615 let item = make_dirstate_item_raw(py, state, mode, size, mtime)?;
614 let item = (path, state, mode, size, mtime);
616 dirs.append(py, (path, item).to_py_object(py).into_object())
615 dirs.append(py, item.to_py_object(py).into_object())
617 }
616 }
618 Ok(dirs)
617 Ok(dirs)
619 }
618 }
General Comments 0
You need to be logged in to leave comments. Login now