changeset 6980:2268edff1bec

allow committing a removed directory fix issue1089
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Wed, 03 Sep 2008 02:27:25 +0200
parents a3fd4aa154af
children 029a54423a96
files mercurial/cmdutil.py tests/test-issue1089 tests/test-issue1089.out
diffstat 3 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Sep 03 01:49:16 2008 +0200
+++ b/mercurial/cmdutil.py	Wed Sep 03 02:27:25 2008 +0200
@@ -1155,6 +1155,12 @@
         modified, added, removed = repo.status(match=m)[:3]
         files = util.sort(modified + added + removed)
         slist = None
+
+        def is_dir(f):
+            name = f + '/'
+            i = bisect.bisect(files, name)
+            return i < len(files) and files[i].startswith(name)
+
         for f in m.files():
             if f == '.':
                 continue
@@ -1164,11 +1170,11 @@
                 try:
                     mode = os.lstat(rf)[stat.ST_MODE]
                 except OSError:
+                    if is_dir(f): # deleted directory ?
+                        continue
                     raise util.Abort(_("file %s not found!") % rel)
                 if stat.S_ISDIR(mode):
-                    name = f + '/'
-                    i = bisect.bisect(files, name)
-                    if i >= len(files) or not files[i].startswith(name):
+                    if not is_dir(f):
                         raise util.Abort(_("no match under directory %s!")
                                          % rel)
                 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-issue1089	Wed Sep 03 02:27:25 2008 +0200
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+hg init a
+cd a
+mkdir a
+echo a > a/b
+hg ci -Am m
+hg rm a
+hg ci -m m a
+
+mkdir a b
+echo a > a/b
+hg ci -Am m
+hg rm a
+cd b
+# relative delete
+hg ci -m m ../a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-issue1089.out	Wed Sep 03 02:27:25 2008 +0200
@@ -0,0 +1,4 @@
+adding a/b
+removing a/b
+adding a/b
+removing a/b