[PATCH] Make rm --after simply mark files as removed, unless --force is also given
Brendan Cully
brendan at kublai.com
Mon Apr 30 01:12:42 UTC 2007
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1177895428 25200
# Node ID b5d988d02048bc5156ba0b4e9dc54645e263bd7e
# Parent 052062b98f2665ae7461cb7c776d63c8e99ab928
Make rm --after simply mark files as removed, unless --force is also given
diff -r 052062b98f26 -r b5d988d02048 mercurial/commands.py
--- a/mercurial/commands.py Sun Apr 29 17:35:03 2007 -0700
+++ b/mercurial/commands.py Sun Apr 29 18:10:28 2007 -0700
@@ -527,7 +527,7 @@ def docopy(ui, repo, pats, opts, wlock):
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 @@ def remove(ui, repo, *pats, **opts):
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 @@ def remove(ui, repo, *pats, **opts):
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 @@ def remove(ui, repo, *pats, **opts):
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 @@ def rename(ui, repo, *pats, **opts):
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):
diff -r 052062b98f26 -r b5d988d02048 mercurial/localrepo.py
--- a/mercurial/localrepo.py Sun Apr 29 17:35:03 2007 -0700
+++ b/mercurial/localrepo.py Sun Apr 29 18:10:28 2007 -0700
@@ -1031,8 +1031,7 @@ class localrepository(repo.repository):
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])
diff -r 052062b98f26 -r b5d988d02048 tests/test-remove
--- a/tests/test-remove Sun Apr 29 17:35:03 2007 -0700
+++ b/tests/test-remove Sun Apr 29 18:10:28 2007 -0700
@@ -23,10 +23,13 @@ hg rm a
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
diff -r 052062b98f26 -r b5d988d02048 tests/test-remove.out
--- a/tests/test-remove.out Sun Apr 29 17:35:03 2007 -0700
+++ b/tests/test-remove.out Sun Apr 29 18:10:28 2007 -0700
@@ -52,5 +52,7 @@ not removing a: file has been marked for
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
More information about the Mercurial-devel
mailing list