Distinguish removed and deleted files. Tests are not fixed yet.
authorThomas Arendsen Hein <thomas@intevation.de>
Thu, 12 Jan 2006 13:58:36 +0100
changeset 1619 1ba0d7041ac4
parent 1618 ff339dd21976
child 1620 6c61646fee5e
Distinguish removed and deleted files. Tests are not fixed yet. hg status will now show "R filename" for "hg rm"ed files and "! filename" for files which were deleted manually. Manually deleted files are considered unmodified.
contrib/hbisect.py
contrib/hgk.py
mercurial/commands.py
mercurial/hgweb.py
mercurial/localrepo.py
--- a/contrib/hbisect.py	Thu Jan 12 13:35:09 2006 +0100
+++ b/contrib/hbisect.py	Thu Jan 12 13:58:36 2006 +0100
@@ -21,7 +21,7 @@
     return parents.pop()
 
 def check_clean(ui, repo):
-        modified, added, removed, unknown = repo.changes()
+        modified, added, removed, deleted, unknown = repo.changes()
         if modified or added or removed:
             ui.warn("Repository is not clean, please commit or revert\n")
             sys.exit(1)
--- a/contrib/hgk.py	Thu Jan 12 13:35:09 2006 +0100
+++ b/contrib/hgk.py	Thu Jan 12 13:58:36 2006 +0100
@@ -15,7 +15,7 @@
 
     if not changes:
         changes = repo.changes(node1, node2, files, match=match)
-    modified, added, removed, unknown = changes
+    modified, added, removed, deleted, unknown = changes
     if files:
         modified, added, removed = map(lambda x: filterfiles(x, files),
                                        (modified, added, removed))
@@ -67,12 +67,12 @@
         if node2:
             change = repo.changelog.read(node2)
             mmap2 = repo.manifest.read(change[0])
-            modified, added, removed, unknown = repo.changes(node1, node2)
+            modified, added, removed, deleted, unknown = repo.changes(node1, node2)
             def read(f): return repo.file(f).read(mmap2[f])
             date2 = date(change)
         else:
             date2 = time.asctime()
-            modified, added, removed, unknown = repo.changes(node1)
+            modified, added, removed, deleted, unknown = repo.changes(node1)
             if not node1:
                 node1 = repo.dirstate.parents()[0]
             def read(f): return file(os.path.join(repo.root, f)).read()
--- a/mercurial/commands.py	Thu Jan 12 13:35:09 2006 +0100
+++ b/mercurial/commands.py	Thu Jan 12 13:58:36 2006 +0100
@@ -264,7 +264,7 @@
            changes=None, text=False):
     if not changes:
         changes = repo.changes(node1, node2, files, match=match)
-    modified, added, removed, unknown = changes
+    modified, added, removed, deleted, unknown = changes
     if files:
         modified, added, removed = map(lambda x: filterfiles(x, files),
                                        (modified, added, removed))
@@ -785,10 +785,9 @@
         addremove(ui, repo, *pats, **opts)
     fns, match, anypats, cwd = matchpats(repo, pats, opts)
     if pats:
-        modified, added, removed, unknown = (
+        modified, added, removed, deleted, unknown = (
             repo.changes(files=fns, match=match))
-        files = (modified + added +
-                [fn for fn in removed if repo.dirstate.state(fn) == 'r'])
+        files = modified + added + removed
     else:
         files = []
     try:
@@ -1381,9 +1380,10 @@
         return
 
     hexfunc = ui.verbose and hex or short
-    modified, added, removed, unknown = repo.changes()
-    output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
-                        (modified or added or removed) and "+" or "")]
+    modified, added, removed, deleted, unknown = repo.changes()
+    output = ["%s%s" %
+              ('+'.join([hexfunc(parent) for parent in parents]),
+              (modified or added or removed or deleted) and "+" or "")]
 
     if not ui.quiet:
         # multiple tags for a single parent separated by '/'
@@ -1412,8 +1412,8 @@
     patches = (patch1,) + patches
 
     if not opts['force']:
-        modified, added, removed, unknown = repo.changes()
-        if modified or added or removed:
+        modified, added, removed, deleted, unknown = repo.changes()
+        if modified or added or removed or deleted:
             raise util.Abort(_("outstanding uncommitted changes"))
 
     d = opts["base"]
@@ -1829,7 +1829,7 @@
     """
     names = []
     def okaytoremove(abs, rel, exact):
-        modified, added, removed, unknown = repo.changes(files=[abs])
+        modified, added, removed, deleted, unknown = repo.changes(files=[abs])
         reason = None
         if modified:
             reason = _('is modified')
@@ -1893,9 +1893,9 @@
            repo.dirstate.parents()[0]
 
     files, choose, anypats, cwd = matchpats(repo, pats, opts)
-    modified, added, removed, unknown = repo.changes(match=choose)
+    modified, added, removed, deleted, unknown = repo.changes(match=choose)
     repo.forget(added)
-    repo.undelete(removed)
+    repo.undelete(removed + deleted)
 
     return repo.update(node, False, True, choose, False)
 
@@ -2022,17 +2022,19 @@
     M = modified
     A = added
     R = removed
+    ! = deleted, but still tracked
     ? = not tracked
     """
 
     files, matchfn, anypats, cwd = matchpats(repo, pats, opts)
-    modified, added, removed, unknown = [
+    modified, added, removed, deleted, unknown = [
         [util.pathto(cwd, x) for x in n]
         for n in repo.changes(files=files, match=matchfn)]
 
     changetypes = [(_('modified'), 'M', modified),
                    (_('added'), 'A', added),
                    (_('removed'), 'R', removed),
+                   (_('deleted'), '!', deleted),
                    (_('unknown'), '?', unknown)]
 
     end = opts['print0'] and '\0' or '\n'
@@ -2437,6 +2439,7 @@
          [('m', 'modified', None, _('show only modified files')),
           ('a', 'added', None, _('show only added files')),
           ('r', 'removed', None, _('show only removed files')),
+          ('d', 'deleted', None, _('show only deleted (but tracked) files')),
           ('u', 'unknown', None, _('show only unknown (not tracked) files')),
           ('n', 'no-status', None, _('hide status prefix')),
           ('0', 'print0', None,
--- a/mercurial/hgweb.py	Thu Jan 12 13:35:09 2006 +0100
+++ b/mercurial/hgweb.py	Thu Jan 12 13:58:36 2006 +0100
@@ -265,7 +265,7 @@
         date1 = util.datestr(change1[2])
         date2 = util.datestr(change2[2])
 
-        modified, added, removed, unknown = r.changes(node1, node2)
+        modified, added, removed, deleted, unknown = r.changes(node1, node2)
         if files:
             modified, added, removed = map(lambda x: filterfiles(x, files),
                                            (modified, added, removed))
--- a/mercurial/localrepo.py	Thu Jan 12 13:35:09 2006 +0100
+++ b/mercurial/localrepo.py	Thu Jan 12 13:58:36 2006 +0100
@@ -355,7 +355,7 @@
                 else:
                     self.ui.warn(_("%s not tracked!\n") % f)
         else:
-            modified, added, removed, unknown = self.changes(match=match)
+            modified, added, removed, deleted, unknown = self.changes(match=match)
             commit = modified + added
             remove = removed
 
@@ -544,12 +544,10 @@
 
             removed = mf1.keys()
 
-        removed.extend(deleted) #XXX get rid of this when returning deleted
-
         # sort and return results:
-        for l in modified, added, removed, unknown:
+        for l in modified, added, removed, deleted, unknown:
             l.sort()
-        return (modified, added, removed, unknown)
+        return (modified, added, removed, deleted, unknown)
 
     def add(self, list):
         wlock = self.wlock()
@@ -1392,7 +1390,7 @@
         ma = self.manifest.read(man)
         mfa = self.manifest.readflags(man)
 
-        modified, added, removed, unknown = self.changes()
+        modified, added, removed, deleted, unknown = self.changes()
 
         if allow and not forcemerge:
             if modified or added or removed:
@@ -1434,7 +1432,7 @@
         if moddirstate:
             wlock = self.wlock()
 
-        for f in removed:
+        for f in deleted:
             if f in mw:
                 del mw[f]