hg remove implicit for whole tree commits?
Thomas Arendsen Hein
thomas at intevation.de
Mon Aug 8 00:53:29 CDT 2005
* Robin Farine <robin.farine at terminus.org> [20050807 02:56]:
> On Sunday 07 August 2005 01.15, Matt Mackall wrote:
> > That behavior seems to have snuck in quietly. We probably don't
> > want to be automatically deleting files without the -A flag.
>
> Perhaps hg status could display a 'D' for deleted but not removed
> files?
I think a '!' would be a good status character, because
1. R(emoved) and D(eleted) may be confused easily
2. ! is kind of a warning that something is wrong here.
Here is a first patch to dirstate.changes() which will not change
the real functionality, but internally already does everything
what's needed. It is not yet in my public tree.
Thomas
diff -r fbe964ae7325 mercurial/hg.py
--- a/mercurial/hg.py Sun Aug 7 16:41:13 2005
+++ b/mercurial/hg.py Mon Aug 8 07:51:58 2005
@@ -487,30 +487,38 @@
def changes(self, files = None, match = util.always):
self.read()
dc = self.map.copy()
- lookup, changed, added, unknown = [], [], [], []
+ lookup, modified, added, removed = [], [], [], []
+ deleted, unknown = [], []
for src, fn in self.walk(files, match):
- try: s = os.stat(os.path.join(self.root, fn))
- except: continue
+ try:
+ s = os.stat(os.path.join(self.root, fn))
+ except OSError:
+ s = None
if fn in dc:
c = dc[fn]
del dc[fn]
- if c[0] == 'm':
- changed.append(fn)
- elif c[0] == 'a':
- added.append(fn)
+ if s:
+ if c[0] == 'm':
+ modified.append(fn)
+ elif c[0] == 'a':
+ added.append(fn)
+ elif c[0] == 'r':
+ unknown.append(fn)
+ elif c[2] != s.st_size or (c[1] ^ s.st_mode) & 0100:
+ modified.append(fn)
+ elif c[1] != s.st_mode or c[3] != s.st_mtime:
+ lookup.append(fn)
elif c[0] == 'r':
- unknown.append(fn)
- elif c[2] != s.st_size or (c[1] ^ s.st_mode) & 0100:
- changed.append(fn)
- elif c[1] != s.st_mode or c[3] != s.st_mtime:
- lookup.append(fn)
- else:
- if match(fn): unknown.append(fn)
-
- return (lookup, changed, added, filter(match, dc.keys()), unknown)
+ removed.append(fn)
+ else:
+ deleted.append(fn)
+ elif s and match(fn):
+ unknown.append(fn)
+
+ return (lookup, modified, added, removed + deleted, unknown)
# used to avoid circular references so destructors work
def opener(base):
--
Email: thomas at intevation.de
http://intevation.de/~thomas/
More information about the Mercurial
mailing list