Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 48046:cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
This removes the need for `DirstateItem`?to support the `state == ' '`
special case which represents dirstate tree nodes without an item.
Differential Revision: https://phab.mercurial-scm.org/D11463
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 20 Sep 2021 20:20:55 +0200 |
parents | 357307feaf61 |
children | c87844960a35 |
comparison
equal
deleted
inserted
replaced
48045:357307feaf61 | 48046:cedfe2606adf |
---|---|
960 if opts.get('nodates') is not None: | 960 if opts.get('nodates') is not None: |
961 nodates = True | 961 nodates = True |
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 |
994 | 991 |
995 @command( | 992 @command( |