Rev 3154: Handle missing tools gracefully in diff --using (abentley) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jan 2 20:46:56 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3154
revision-id:pqm at pqm.ubuntu.com-20080102204644-m6dav0cszl5e471x
parent: pqm at pqm.ubuntu.com-20080102195223-2kpjtcoeqvvcrcki
parent: abentley at panoramicfeedback.com-20071228165208-7lw04cwy51rxagsk
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-01-02 20:46:44 +0000
message:
Handle missing tools gracefully in diff --using (abentley)
modified:
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/test_diff.py testdiff.py-20050727164403-d1a3496ebb12e339
------------------------------------------------------------
revno: 3145.1.2
revision-id:abentley at panoramicfeedback.com-20071228165208-7lw04cwy51rxagsk
parent: abentley at panoramicfeedback.com-20071228163746-975r76opsppiwstk
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: no-inventory4
timestamp: Fri 2007-12-28 11:52:08 -0500
message:
Don't swallow other OSErrors
modified:
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
------------------------------------------------------------
revno: 3145.1.1
revision-id:abentley at panoramicfeedback.com-20071228163746-975r76opsppiwstk
parent: pqm at pqm.ubuntu.com-20071227150146-08nqv2gvo5e3i1n3
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: no-inventory4
timestamp: Fri 2007-12-28 11:37:46 -0500
message:
Handle missing tools gracefully in diff --using
modified:
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/test_diff.py testdiff.py-20050727164403-d1a3496ebb12e339
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2007-12-26 21:13:53 +0000
+++ b/bzrlib/diff.py 2007-12-28 16:52:08 +0000
@@ -773,8 +773,15 @@
return [t % my_map for t in self.command_template]
def _execute(self, old_path, new_path):
- proc = subprocess.Popen(self._get_command(old_path, new_path),
- stdout=subprocess.PIPE, cwd=self._root)
+ command = self._get_command(old_path, new_path)
+ try:
+ proc = subprocess.Popen(command, stdout=subprocess.PIPE,
+ cwd=self._root)
+ except OSError, e:
+ if e.errno == errno.ENOENT:
+ raise errors.ExecutableMissing(command[0])
+ else:
+ raise
self.to_file.write(proc.stdout.read())
return proc.wait()
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2007-12-27 08:25:04 +0000
+++ b/bzrlib/errors.py 2008-01-02 20:46:44 +0000
@@ -1870,6 +1870,14 @@
BzrError.__init__(self, path)
+class ExecutableMissing(BzrError):
+
+ _fmt = "%(exe_name)s could not be found on this machine"
+
+ def __init__(self, exe_name):
+ BzrError.__init__(self, exe_name=exe_name)
+
+
class NoDiff(BzrError):
_fmt = "Diff is not installed on this machine: %(msg)s"
=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py 2007-12-26 21:13:53 +0000
+++ b/bzrlib/tests/test_diff.py 2007-12-28 16:37:46 +0000
@@ -30,7 +30,7 @@
internal_diff,
show_diff_trees,
)
-from bzrlib.errors import BinaryFile, NoDiff
+from bzrlib.errors import BinaryFile, NoDiff, ExecutableMissing
import bzrlib.osutils as osutils
import bzrlib.patiencediff
import bzrlib._patiencediff_py
@@ -1258,6 +1258,15 @@
diff_obj._execute('old', 'new')
self.assertEqual(output.getvalue(), 'old new\n')
+ def test_excute_missing(self):
+ diff_obj = DiffFromTool(['a-tool-which-is-unlikely-to-exist'],
+ None, None, None)
+ self.addCleanup(diff_obj.finish)
+ e = self.assertRaises(ExecutableMissing, diff_obj._execute, 'old',
+ 'new')
+ self.assertEqual('a-tool-which-is-unlikely-to-exist could not be found'
+ ' on this machine', str(e))
+
def test_prepare_files(self):
output = StringIO()
tree = self.make_branch_and_tree('tree')
More information about the bazaar-commits
mailing list