diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -430,6 +430,8 @@ def commit(ui, repo, *pats, **opts): files = modified + added + removed slist = None for f in fns: + if f == '.': + continue if f not in files: rf = repo.wjoin(f) if f in unknown: diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -442,7 +442,7 @@ class dirstate(object): # don't trip over symlinks st = os.lstat(p) if stat.S_ISDIR(st.st_mode): - if not ignore(p): + if not ignore(np): work.append(p) if directories: yield 'd', np, st diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -447,7 +447,7 @@ def _matcher(canonroot, cwd, names, inc, if c in _globchars: return True return False - def regex(kind, name, tail): + def regex(kind, name): '''convert a pattern into a regular expression''' if not name: return '' @@ -463,16 +463,16 @@ def _matcher(canonroot, cwd, names, inc, if name.startswith('^'): return name return '.*' + name - return globre(name, '', tail) + return globre(name, '', '(?:/|$)') - def matchfn(pats, tail): + def matchfn(pats): """build a matching function from a set of patterns""" if not pats: return matches = [] for k, p in pats: try: - pat = '(?:%s)' % regex(k, p, tail) + pat = '(?:%s)' % regex(k, p) matches.append(re.compile(pat).match) except re.error: if src: raise Abort("%s: invalid pattern (%s): %s" % (src, k, p)) @@ -520,15 +520,15 @@ def _matcher(canonroot, cwd, names, inc, roots, pats, anypats = normalizepats(names, dflt_pat) - patmatch = matchfn(pats, '$') or always + patmatch = matchfn(pats) or always incmatch = always if inc: dummy, inckinds, dummy = normalizepats(inc, 'glob') - incmatch = matchfn(inckinds, '(?:/|$)') + incmatch = matchfn(inckinds) excmatch = lambda fn: False if exc: dummy, exckinds, dummy = normalizepats(exc, 'glob') - excmatch = matchfn(exckinds, '(?:/|$)') + excmatch = matchfn(exckinds) if not names and inc and not exc: # common case: hgignore patterns diff --git a/tests/test-commit b/tests/test-commit --- a/tests/test-commit +++ b/tests/test-commit @@ -71,4 +71,21 @@ echo % full log hg log -v cd .. +echo % dot and subdir commit test +hg init test3 +cd test3 +mkdir foo +echo foo content > foo/plain-file +hg add foo/plain-file +hg ci -d '1000000 0' -u test -m commit-foo-subdir foo +echo modified foo content > foo/plain-file +hg ci -d '2000000 0' -u test -m commit-foo-dot . +echo % full log +hg log -v +echo % subdir log +cd foo +hg log . +cd .. +cd .. + exit 0 diff --git a/tests/test-commit.out b/tests/test-commit.out --- a/tests/test-commit.out +++ b/tests/test-commit.out @@ -64,3 +64,34 @@ description: commit-subdir-1 +% dot and subdir commit test +% full log +changeset: 1:d9180e04fa8a +tag: tip +user: test +date: Sat Jan 24 03:33:20 1970 +0000 +files: foo/plain-file +description: +commit-foo-dot + + +changeset: 0:80b572aaf098 +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +files: foo/plain-file +description: +commit-foo-subdir + + +% subdir log +changeset: 1:d9180e04fa8a +tag: tip +user: test +date: Sat Jan 24 03:33:20 1970 +0000 +summary: commit-foo-dot + +changeset: 0:80b572aaf098 +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: commit-foo-subdir + diff --git a/tests/test-walk.out b/tests/test-walk.out --- a/tests/test-walk.out +++ b/tests/test-walk.out @@ -210,10 +210,20 @@ hg debugwalk beans/.hg beans/.hg: No such file or directory hg debugwalk glob:* -f fennel fennel -f fenugreek fenugreek -f fiddlehead fiddlehead -f glob:glob glob:glob +f beans/black beans/black +f beans/borlotti beans/borlotti +f beans/kidney beans/kidney +f beans/navy beans/navy +f beans/pinto beans/pinto +f beans/turtle beans/turtle +f fennel fennel +f fenugreek fenugreek +f fiddlehead fiddlehead +f glob:glob glob:glob +f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle +f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi +f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon +f mammals/skunk mammals/skunk hg debugwalk re:.*[kb]$ f beans/black beans/black