--- a/mercurial/commands.py Mon Dec 04 17:10:31 2006 -0600
+++ b/mercurial/commands.py Tue Nov 21 20:00:15 2006 -0200
@@ -8,7 +8,7 @@
from demandload import demandload
from node import *
from i18n import gettext as _
-demandload(globals(), "os re sys signal imp urllib pdb shlex")
+demandload(globals(), "bisect os re sys signal imp urllib pdb shlex stat")
demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo")
demandload(globals(), "difflib patch time")
demandload(globals(), "traceback errno version atexit")
@@ -423,12 +423,28 @@
status = repo.status(files=fns, match=match)
modified, added, removed, deleted, unknown = status[:5]
files = modified + added + removed
+ slist = None
for f in fns:
- if f not in modified + added + removed:
+ if f not in files:
+ rf = repo.wjoin(f)
if f in unknown:
- raise util.Abort(_("file %s not tracked!") % f)
- else:
- raise util.Abort(_("file %s not found!") % f)
+ raise util.Abort(_("file %s not tracked!") % rf)
+ try:
+ mode = os.lstat(rf)[stat.ST_MODE]
+ except OSError:
+ raise util.Abort(_("file %s not found!") % rf)
+ if stat.S_ISDIR(mode):
+ name = f + '/'
+ if slist is None:
+ slist = list(files)
+ slist.sort()
+ i = bisect.bisect(slist, name)
+ if i >= len(slist) or not slist[i].startswith(name):
+ raise util.Abort(_("no match under directory %s!")
+ % rf)
+ elif not stat.S_ISREG(mode):
+ raise util.Abort(_("can't commit %s: "
+ "unsupported file type!") % rf)
else:
files = []
try:
--- a/tests/test-commit Mon Dec 04 17:10:31 2006 -0600
+++ b/tests/test-commit Tue Nov 21 20:00:15 2006 -0200
@@ -1,5 +1,10 @@
#!/bin/sh
+cleanpath()
+{
+ sed -e "s:/.*\(/test/.*\):...\1:"
+}
+
echo % commit date test
hg init test
cd test
@@ -17,7 +22,35 @@
echo bar > bar
hg add bar
rm bar
-hg commit -d "1000000 0" -m commit-8 2>&1 | sed -e "s:/.*\(/test/.*\):...\1:"
+hg commit -d "1000000 0" -m commit-8 2>&1 | cleanpath
+
+hg -q revert -a --no-backup
+
+mkdir dir
+echo boo > dir/file
+hg add
+hg -v commit -d '0 0' -m commit-9 dir
+
+echo > dir.file
+hg add
+hg commit -d '0 0' -m commit-10 dir dir.file 2>&1 | cleanpath
+
+echo >> dir/file
+mkdir bleh
+mkdir dir2
+cd bleh
+hg commit -d '0 0' -m commit-11 . 2>&1 | cleanpath
+hg commit -d '0 0' -m commit-12 ../dir ../dir2 2>&1 | cleanpath
+hg -v commit -d '0 0' -m commit-13 ../dir
+cd ..
+
+hg commit -d '0 0' -m commit-14 does-not-exist 2>&1 | cleanpath
+ln -s foo baz
+hg commit -d '0 0' -m commit-15 baz 2>&1 | cleanpath
+touch quux
+hg commit -d '0 0' -m commit-16 quux 2>&1 | cleanpath
+echo >> dir/file
+hg -v commit -d '0 0' -m commit-17 dir/file
cd ..
echo % partial subdir commit test
--- a/tests/test-commit.out Mon Dec 04 17:10:31 2006 -0600
+++ b/tests/test-commit.out Tue Nov 21 20:00:15 2006 -0200
@@ -17,6 +17,19 @@
% partial commit test
trouble committing bar!
abort: No such file or directory: .../test/bar
+adding dir/file
+dir/file
+adding dir.file
+abort: no match under directory .../test/dir!
+abort: no match under directory .../test/bleh!
+abort: no match under directory .../test/dir2!
+dir/file
+does-not-exist: No such file or directory
+abort: file .../test/does-not-exist not found!
+baz: unsupported file type (type is symbolic link)
+abort: can't commit .../test/baz: unsupported file type!
+abort: file .../test/quux not tracked!
+dir/file
% partial subdir commit test
adding bar/bar
adding foo/foo