# HG changeset patch # User Mads Kiilerich # Date 1279924688 -7200 # Node ID f92f8921a5cc262f043c99a9ea7afcb9835b2aca # Parent c29012a73518b95991a2d4bf3b899302ae84de40 dispatch: give better error message when cwd doesn't exist (issue2293) Previous behavior wasn't very helpful: $ hg st foo abort: No such file or directory Now we tell more about what failed: abort: error getting current working directory: No such file or directory diff -r c29012a73518 -r f92f8921a5cc mercurial/dispatch.py --- a/mercurial/dispatch.py Thu Jul 22 23:18:38 2010 +0900 +++ b/mercurial/dispatch.py Sat Jul 24 00:38:08 2010 +0200 @@ -366,7 +366,12 @@ os.chdir(cwd[-1]) # read the local repository .hgrc into a local ui object - path = cmdutil.findrepo(os.getcwd()) or "" + try: + wd = os.getcwd() + except OSError, e: + raise util.Abort(_("error getting current working directory: %s") % + e.strerror) + path = cmdutil.findrepo(wd) or "" if not path: lui = ui else: diff -r c29012a73518 -r f92f8921a5cc tests/test-dispatch --- a/tests/test-dispatch Thu Jul 22 23:18:38 2010 +0900 +++ b/tests/test-dispatch Sat Jul 24 00:38:08 2010 +0200 @@ -3,6 +3,8 @@ "$TESTDIR/hghave" no-outer-repo || exit 80 +dir=`pwd` + hg init a cd a echo a > a @@ -19,8 +21,12 @@ EOF hg cat a +echo '% working directory removed' +rm -rf $dir/a +hg --version + echo '% no repo' -cd .. +cd $dir hg cat exit 0 diff -r c29012a73518 -r f92f8921a5cc tests/test-dispatch.out --- a/tests/test-dispatch.out Thu Jul 22 23:18:38 2010 +0900 +++ b/tests/test-dispatch.out Sat Jul 24 00:38:08 2010 +0200 @@ -33,5 +33,7 @@ % [defaults] a a: No such file in rev 000000000000 +% working directory removed +abort: error getting current working directory: No such file or directory % no repo abort: There is no Mercurial repository here (.hg not found)!