diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py --- a/mercurial/pathutil.py +++ b/mercurial/pathutil.py @@ -79,20 +79,24 @@ return # AIX ignores "/" at end of path, others raise EISDIR. if util.endswithsep(path): - raise error.Abort(_(b"path ends in directory separator: %s") % path) + raise error.InputError( + _(b"path ends in directory separator: %s") % path + ) parts = util.splitpath(path) if ( os.path.splitdrive(path)[0] or _lowerclean(parts[0]) in (b'.hg', b'.hg.', b'') or pycompat.ospardir in parts ): - raise error.Abort(_(b"path contains illegal component: %s") % path) + raise error.InputError( + _(b"path contains illegal component: %s") % path + ) # Windows shortname aliases for p in parts: if b"~" in p: first, last = p.split(b"~", 1) if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]: - raise error.Abort( + raise error.InputError( _(b"path contains illegal component: %s") % path ) if b'.hg' in _lowerclean(path): @@ -101,7 +105,7 @@ if p in lparts[1:]: pos = lparts.index(p) base = os.path.join(*parts[:pos]) - raise error.Abort( + raise error.InputError( _(b"path '%s' is inside nested repo %r") % (path, pycompat.bytestr(base)) ) diff --git a/tests/test-audit-path.t b/tests/test-audit-path.t --- a/tests/test-audit-path.t +++ b/tests/test-audit-path.t @@ -8,7 +8,7 @@ $ hg add .hg/00changelog.i abort: path contains illegal component: .hg/00changelog.i - [255] + [10] #if symlink @@ -91,7 +91,7 @@ .hg/test $ hg update -Cr0 abort: path contains illegal component: .hg/test - [255] + [10] attack foo/.hg/test @@ -99,7 +99,7 @@ foo/.hg/test $ hg update -Cr1 abort: path 'foo/.hg/test' is inside nested repo 'foo' - [255] + [10] attack back/test where back symlinks to .. @@ -125,7 +125,7 @@ $ echo data > ../test/file $ hg update -Cr3 abort: path contains illegal component: ../test - [255] + [10] $ cat ../test/file data @@ -135,7 +135,7 @@ /tmp/test $ hg update -Cr4 abort: path contains illegal component: /tmp/test - [255] + [10] $ cd .. diff --git a/tests/test-audit-subrepo.t b/tests/test-audit-subrepo.t --- a/tests/test-audit-subrepo.t +++ b/tests/test-audit-subrepo.t @@ -10,7 +10,7 @@ $ echo 'sub/.hg = sub/.hg' >> .hgsub $ hg ci -qAm 'add subrepo "sub/.hg"' abort: path 'sub/.hg' is inside nested repo 'sub' - [255] + [10] prepare tampered repo (including the commit above): @@ -34,7 +34,7 @@ $ hg clone -q hgname hgname2 abort: path 'sub/.hg' is inside nested repo 'sub' - [255] + [10] Test absolute path ------------------ @@ -47,7 +47,7 @@ $ echo '/sub = sub' >> .hgsub $ hg ci -qAm 'add subrepo "/sub"' abort: path contains illegal component: /sub - [255] + [10] prepare tampered repo (including the commit above): @@ -71,7 +71,7 @@ $ hg clone -q absolutepath absolutepath2 abort: path contains illegal component: /sub - [255] + [10] Test root path -------------- @@ -84,7 +84,7 @@ $ echo '/ = sub' >> .hgsub $ hg ci -qAm 'add subrepo "/"' abort: path ends in directory separator: / - [255] + [10] prepare tampered repo (including the commit above): @@ -108,7 +108,7 @@ $ hg clone -q rootpath rootpath2 abort: path ends in directory separator: / - [255] + [10] Test empty path --------------- @@ -197,7 +197,7 @@ $ echo '../sub = ../sub' >> .hgsub $ hg ci -qAm 'add subrepo "../sub"' abort: path contains illegal component: ../sub - [255] + [10] prepare tampered repo (including the commit above): @@ -221,7 +221,7 @@ $ hg clone -q main main2 abort: path contains illegal component: ../sub - [255] + [10] $ cd .. Test variable expansion diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -665,7 +665,7 @@ #else $ hg co --clean tip abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc) - [255] + [10] #endif $ hg rollback -f @@ -686,7 +686,7 @@ $ "$PYTHON" evil-commit.py $ hg co --clean tip abort: path contains illegal component: HG~1/hgrc - [255] + [10] $ hg rollback -f repository tip rolled back to revision 2 (undo commit) @@ -706,7 +706,7 @@ $ "$PYTHON" evil-commit.py $ hg co --clean tip abort: path contains illegal component: HG8B6C~2/hgrc - [255] + [10] $ cd .. diff --git a/tests/test-import.t b/tests/test-import.t --- a/tests/test-import.t +++ b/tests/test-import.t @@ -1085,7 +1085,7 @@ > EOF applying patch from stdin abort: path contains illegal component: ../outside/foo - [255] + [10] $ cd .. diff --git a/tests/test-rename.t b/tests/test-rename.t --- a/tests/test-rename.t +++ b/tests/test-rename.t @@ -610,7 +610,7 @@ $ hg rename d1/d11/a1 .hg/foo abort: path contains illegal component: .hg/foo - [255] + [10] $ hg status -C $ hg rename d1/d11/a1 ../foo abort: ../foo not under root '$TESTTMP' @@ -620,7 +620,7 @@ $ mv d1/d11/a1 .hg/foo $ hg rename --after d1/d11/a1 .hg/foo abort: path contains illegal component: .hg/foo - [255] + [10] $ hg status -C ! d1/d11/a1 $ hg update -C @@ -629,11 +629,11 @@ $ hg rename d1/d11/a1 .hg abort: path contains illegal component: .hg/a1 - [255] + [10] $ hg --config extensions.largefiles= rename d1/d11/a1 .hg The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) abort: path contains illegal component: .hg/a1 - [255] + [10] $ hg status -C $ hg rename d1/d11/a1 .. abort: ../a1 not under root '$TESTTMP' @@ -647,7 +647,7 @@ $ mv d1/d11/a1 .hg $ hg rename --after d1/d11/a1 .hg abort: path contains illegal component: .hg/a1 - [255] + [10] $ hg status -C ! d1/d11/a1 $ hg update -C @@ -656,7 +656,7 @@ $ (cd d1/d11; hg rename ../../d2/b ../../.hg/foo) abort: path contains illegal component: .hg/foo - [255] + [10] $ hg status -C $ (cd d1/d11; hg rename ../../d2/b ../../../foo) abort: ../../../foo not under root '$TESTTMP' diff --git a/tests/test-walk.t b/tests/test-walk.t --- a/tests/test-walk.t +++ b/tests/test-walk.t @@ -299,10 +299,10 @@ f mammals/skunk skunk $ hg debugwalk -v .hg abort: path 'mammals/.hg' is inside nested repo 'mammals' - [255] + [10] $ hg debugwalk -v ../.hg abort: path contains illegal component: .hg - [255] + [10] $ cd .. $ hg debugwalk -v -Ibeans @@ -410,16 +410,16 @@ [255] $ hg debugwalk -v .hg abort: path contains illegal component: .hg - [255] + [10] $ hg debugwalk -v beans/../.hg abort: path contains illegal component: .hg - [255] + [10] $ hg debugwalk -v beans/../.hg/data abort: path contains illegal component: .hg/data - [255] + [10] $ hg debugwalk -v beans/.hg abort: path 'beans/.hg' is inside nested repo 'beans' - [255] + [10] Test explicit paths and excludes: