# HG changeset patch # User Vadim Gelfer # Date 1144973495 25200 # Node ID 15ec724ba351d9e1fa4e04a342676cdecfec1b47 # Parent 4a49daa3a40ca0226490154bbe104a1b7277859b# Parent 547ede0123a2ea5d3ef072b5b563306793b31fa0 merge with crew. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -342,7 +342,16 @@ class dirstate(object): names.sort() # nd is the top of the repository dir tree nd = util.normpath(top[len(self.root) + 1:]) - if nd == '.': nd = '' + if nd == '.': + nd = '' + else: + # do not recurse into a repo contained in this + # one. use bisect to find .hg directory so speed + # is good on big directory. + hg = bisect.bisect_left(names, '.hg') + if hg < len(names) and names[hg] == '.hg': + if os.path.isdir(os.path.join(top, '.hg')): + continue for f in names: np = util.pconvert(os.path.join(nd, f)) if seen(np): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -373,8 +373,10 @@ def unlink(f): """unlink and remove the directory if it is empty""" os.unlink(f) # try removing directories that might now be empty - try: os.removedirs(os.path.dirname(f)) - except: pass + try: + os.removedirs(os.path.dirname(f)) + except OSError: + pass def copyfiles(src, dst, hardlink=None): """Copy a directory tree using hardlinks if possible""" diff --git a/tests/run-tests b/tests/run-tests --- a/tests/run-tests +++ b/tests/run-tests @@ -24,6 +24,16 @@ HGEDITOR=true; export HGEDITOR HGMERGE=true; export HGMERGE HGUSER="test"; export HGUSER HGRCPATH=""; export HGRCPATH +OS=`uname` + +case "$OS" in + HP-UX|SunOS) + DIFFOPTS= + ;; + *) + DIFFOPTS=-u + ;; +esac if [ `echo -n HG` = "-n HG" ] then @@ -118,13 +128,13 @@ run_one() { cat "$ERR" fail=1 elif [ -r "$OUTOK" ]; then - if diff -u "$OUTOK" "$OUT" > /dev/null; then + if diff $DIFFOPTS "$OUTOK" "$OUT" > /dev/null; then : no differences else cp "$OUT" "$ERR" echo echo "$1 output changed:" - diff -u "$OUTOK" "$ERR" || true + diff $DIFFOPTS "$OUTOK" "$ERR" || true fail=1 fi fi diff --git a/tests/test-nested-repo b/tests/test-nested-repo new file mode 100755 --- /dev/null +++ b/tests/test-nested-repo @@ -0,0 +1,19 @@ +#!/bin/sh + +hg init a +cd a +hg init b +echo x > b/x +echo '# should print nothing' +hg st +echo '# should print ? b/x' +hg st b/x + +hg add b/x + +echo '# should print A b/x' +hg st +echo '# should forget b/x' +hg forget +echo '# should print nothing' +hg st b diff --git a/tests/test-nested-repo.out b/tests/test-nested-repo.out new file mode 100644 --- /dev/null +++ b/tests/test-nested-repo.out @@ -0,0 +1,8 @@ +# should print nothing +# should print ? b/x +? b/x +# should print A b/x +A b/x +# should forget b/x +forgetting b/x +# should print nothing