changeset 4392:9770d260a405

Make rm --after simply mark files as removed, unless --force is also given
author Brendan Cully <brendan@kublai.com>
date Mon, 30 Apr 2007 08:51:59 -0700
parents 722417b3d7fa
children cf5f35ec4720
files mercurial/commands.py mercurial/localrepo.py tests/test-remove tests/test-remove.out
diffstat 4 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Apr 29 18:17:35 2007 -0700
+++ b/mercurial/commands.py	Mon Apr 30 08:51:59 2007 -0700
@@ -527,7 +527,7 @@
                     restore = False
                 finally:
                     if restore:
-                        repo.remove([abstarget], wlock)
+                        repo.remove([abstarget], wlock=wlock)
             except IOError, inst:
                 if inst.errno == errno.ENOENT:
                     ui.warn(_('%s: deleted in working copy\n') % relsrc)
@@ -2082,7 +2082,8 @@
     This only removes files from the current branch, not from the
     entire project history.  If the files still exist in the working
     directory, they will be deleted from it.  If invoked with --after,
-    files that have been manually deleted are marked as removed.
+    files are marked as removed, but not actually unlinked unless --force
+    is also given.
 
     This command schedules the files to be removed at the next commit.
     To undo a remove before that, see hg revert.
@@ -2100,9 +2101,7 @@
     remove, forget = [], []
     for src, abs, rel, exact in cmdutil.walk(repo, pats, opts):
         reason = None
-        if abs not in deleted and opts['after']:
-            reason = _('is still present')
-        elif abs in modified and not opts['force']:
+        if abs in modified and not opts['force']:
             reason = _('is modified (use -f to force removal)')
         elif abs in added:
             if opts['force']:
@@ -2121,7 +2120,7 @@
                 ui.status(_('removing %s\n') % rel)
             remove.append(abs)
     repo.forget(forget)
-    repo.remove(remove, unlink=not opts['after'])
+    repo.remove(remove, unlink=opts['force'] or not opts['after'])
 
 def rename(ui, repo, *pats, **opts):
     """rename files; equivalent of copy + remove
@@ -2145,7 +2144,7 @@
             ui.status(_('removing %s\n') % rel)
         names.append(abs)
     if not opts.get('dry_run'):
-        repo.remove(names, True, wlock)
+        repo.remove(names, True, wlock=wlock)
     return errs
 
 def revert(ui, repo, *pats, **opts):
--- a/mercurial/localrepo.py	Sun Apr 29 18:17:35 2007 -0700
+++ b/mercurial/localrepo.py	Mon Apr 30 08:51:59 2007 -0700
@@ -1031,8 +1031,7 @@
         if not wlock:
             wlock = self.wlock()
         for f in list:
-            p = self.wjoin(f)
-            if os.path.exists(p):
+            if unlink and os.path.exists(self.wjoin(f)):
                 self.ui.warn(_("%s still exists!\n") % f)
             elif self.dirstate.state(f) == 'a':
                 self.dirstate.forget([f])
--- a/tests/test-remove	Sun Apr 29 18:17:35 2007 -0700
+++ b/tests/test-remove	Mon Apr 30 08:51:59 2007 -0700
@@ -23,10 +23,13 @@
 hg rm a
 hg rm -f a
 echo b > b
+echo c > c
 hg ci -A -m 3 -d "1000001 0"
 echo c >> b
 hg rm b
 hg rm -f b
+hg rm -A c
+cat c
 
 cd ..
 hg clone a b
--- a/tests/test-remove.out	Sun Apr 29 18:17:35 2007 -0700
+++ b/tests/test-remove.out	Mon Apr 30 08:51:59 2007 -0700
@@ -52,5 +52,7 @@
 not removing a: file has been marked for add (use -f to force removal)
 adding a
 adding b
+adding c
 not removing b: file is modified (use -f to force removal)
-2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+c
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved