changeset 2312:4f04368423ec

merge with crew.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 18 May 2006 16:49:45 -0700
parents d01eac5968c6 (diff) b832b6eb65ab (current diff)
children a600d9997521 b30aa02c85e7
files mercurial/hgweb.py
diffstat 5 files changed, 45 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu May 18 11:48:33 2006 -0700
+++ b/mercurial/commands.py	Thu May 18 16:49:45 2006 -0700
@@ -2189,34 +2189,42 @@
     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.
+
+    Modified files and added files are not removed by default.  To
+    remove them, use the -f/--force option.
     """
     names = []
     if not opts['after'] and not pats:
         raise util.Abort(_('no files specified'))
-    def okaytoremove(abs, rel, exact):
-        modified, added, removed, deleted, unknown = repo.changes(files=[abs])
+    files, matchfn, anypats = matchpats(repo, pats, opts)
+    exact = dict.fromkeys(files)
+    mardu = map(dict.fromkeys, repo.changes(files=files, match=matchfn))
+    modified, added, removed, deleted, unknown = mardu
+    remove, forget = [], []
+    for src, abs, rel, exact in walk(repo, pats, opts):
         reason = None
-        if not deleted and opts['after']:
+        if abs not in deleted and opts['after']:
             reason = _('is still present')
-        elif modified and not opts['force']:
-            reason = _('is modified')
-        elif added:
-            reason = _('has been marked for add')
-        elif unknown:
+        elif abs in modified and not opts['force']:
+            reason = _('is modified (use -f to force removal)')
+        elif abs in added:
+            if opts['force']:
+                forget.append(abs)
+                continue
+            reason = _('has been marked for add (use -f to force removal)')
+        elif abs in unknown:
             reason = _('is not managed')
-        elif removed:
-            return False
+        elif abs in removed:
+            continue
         if reason:
             if exact:
                 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
         else:
-            return True
-    for src, abs, rel, exact in walk(repo, pats, opts):
-        if okaytoremove(abs, rel, exact):
             if ui.verbose or not exact:
                 ui.status(_('removing %s\n') % rel)
-            names.append(abs)
-    repo.remove(names, unlink=not opts['after'])
+            remove.append(abs)
+    repo.forget(forget)
+    repo.remove(remove, unlink=not opts['after'])
 
 def rename(ui, repo, *pats, **opts):
     """rename files; equivalent of copy + remove
--- a/mercurial/demandload.py	Thu May 18 11:48:33 2006 -0700
+++ b/mercurial/demandload.py	Thu May 18 16:49:45 2006 -0700
@@ -81,6 +81,10 @@
 
         return getattr(importer.module(), target)
 
+    def __call__(self, *args, **kwargs):
+        target = object.__getattribute__(self, 'module')()
+        return target(*args, **kwargs)
+
 def demandload(scope, modules):
     '''import modules into scope when each is first used.
 
--- a/mercurial/util.py	Thu May 18 11:48:33 2006 -0700
+++ b/mercurial/util.py	Thu May 18 16:49:45 2006 -0700
@@ -734,7 +734,7 @@
         def rename(self):
             if not self.closed:
                 posixfile.close(self)
-                rename(self.temp, self.__name)
+                rename(self.temp, localpath(self.__name))
         def __del__(self):
             if not self.closed:
                 try:
--- a/tests/test-remove	Thu May 18 11:48:33 2006 -0700
+++ b/tests/test-remove	Thu May 18 16:49:45 2006 -0700
@@ -3,6 +3,7 @@
 hg init a
 cd a
 echo a > foo
+hg rm foo
 hg add foo
 hg commit -m 1 -d "1000000 0"
 hg remove
@@ -17,5 +18,15 @@
 hg log -p -r 0
 hg log -p -r 1
 
+echo a > a
+hg add a
+hg rm a
+hg rm -f a
+echo b > b
+hg ci -A -m 3 -d "1000001 0"
+echo c >> b
+hg rm b
+hg rm -f b
+
 cd ..
 hg clone a b
--- a/tests/test-remove.out	Thu May 18 11:48:33 2006 -0700
+++ b/tests/test-remove.out	Thu May 18 16:49:45 2006 -0700
@@ -1,3 +1,4 @@
+not removing foo: file is not managed
 abort: no files specified
 undeleting foo
 removing foo
@@ -50,4 +51,8 @@
 -a
 
 
-0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+not removing a: file has been marked for add (use -f to force removal)
+adding a
+adding b
+not removing b: file is modified (use -f to force removal)
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved