# HG changeset patch
# User Benoit Boissinot <benoit.boissinot@ens-lyon.org>
# Date 1220401645 -7200
# Node ID 2268edff1bec20c1f3ee4bdee43275a216287bc8
# Parent a3fd4aa154afff901779639df0963e4e2848b7dd
allow committing a removed directory
fix issue1089
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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)):
diff --git a/tests/test-issue1089 b/tests/test-issue1089
new file mode 100755
--- /dev/null
+++ b/tests/test-issue1089
@@ -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
diff --git a/tests/test-issue1089.out b/tests/test-issue1089.out
new file mode 100644
--- /dev/null
+++ b/tests/test-issue1089.out
@@ -0,0 +1,4 @@
+adding a/b
+removing a/b
+adding a/b
+removing a/b
|