dispatch: show empty filename in OSError aborts
authorMads Kiilerich <mads@kiilerich.com>
Mon, 07 Jan 2013 02:00:29 +0100
changeset 18227 720308f741cb
parent 18226 fe67db018bd7
child 18228 1528ff6ac7ee
dispatch: show empty filename in OSError aborts Mercurial would sometimes exit with: abort: No such file or directory where str of the actual OSError exception was the more helpful: [Errno 2] No such file or directory: '' The exception will now always show the filename and quote it: abort: No such file or directory: ''
mercurial/dispatch.py
tests/test-audit-path.t
tests/test-clone.t
tests/test-convert.t
tests/test-dispatch.t
--- a/mercurial/dispatch.py	Sun Jan 06 04:04:44 2013 +0100
+++ b/mercurial/dispatch.py	Mon Jan 07 02:00:29 2013 +0100
@@ -183,8 +183,8 @@
         else:
             raise
     except OSError, inst:
-        if getattr(inst, "filename", None):
-            ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
+        if getattr(inst, "filename", None) is not None:
+            ui.warn(_("abort: %s: '%s'\n") % (inst.strerror, inst.filename))
         else:
             ui.warn(_("abort: %s\n") % inst.strerror)
     except KeyboardInterrupt:
--- a/tests/test-audit-path.t	Sun Jan 06 04:04:44 2013 +0100
+++ b/tests/test-audit-path.t	Mon Jan 07 02:00:29 2013 +0100
@@ -86,7 +86,7 @@
   $ hg manifest -r4
   /tmp/test
   $ hg update -Cr4
-  abort: *: $TESTTMP/target//tmp/test (glob)
+  abort: *: '$TESTTMP/target//tmp/test' (glob)
   [255]
 
   $ cd ..
--- a/tests/test-clone.t	Sun Jan 06 04:04:44 2013 +0100
+++ b/tests/test-clone.t	Mon Jan 07 02:00:29 2013 +0100
@@ -558,7 +558,7 @@
   $ hg init b
   $ cd b
   $ hg clone . ../a
-  abort: Permission denied: ../a
+  abort: Permission denied: '../a'
   [255]
   $ cd ..
   $ chmod 700 a
--- a/tests/test-convert.t	Sun Jan 06 04:04:44 2013 +0100
+++ b/tests/test-convert.t	Mon Jan 07 02:00:29 2013 +0100
@@ -316,7 +316,7 @@
   $ chmod 000 bogusdir
 
   $ hg convert a bogusdir
-  abort: Permission denied: bogusdir
+  abort: Permission denied: 'bogusdir'
   [255]
 
 user permissions should succeed
--- a/tests/test-dispatch.t	Sun Jan 06 04:04:44 2013 +0100
+++ b/tests/test-dispatch.t	Mon Jan 07 02:00:29 2013 +0100
@@ -46,6 +46,12 @@
 
   $ cd "$TESTTMP"
 
+OSError ... and with filename even when it is empty
+
+  $ hg -R a archive ''
+  abort: No such file or directory: ''
+  [255]
+
 #if no-outer-repo
 
 No repo: