summaryrefslogtreecommitdiff
path: root/subversion/bindings/swig/python/svn/fs.py
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/bindings/swig/python/svn/fs.py')
-rw-r--r--subversion/bindings/swig/python/svn/fs.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/subversion/bindings/swig/python/svn/fs.py b/subversion/bindings/swig/python/svn/fs.py
index 13acc04..7d00d1a 100644
--- a/subversion/bindings/swig/python/svn/fs.py
+++ b/subversion/bindings/swig/python/svn/fs.py
@@ -23,6 +23,7 @@
# under the License.
######################################################################
+import errno
from libsvn.fs import *
from svn.core import _unprefix_names, Pool, _as_list
_unprefix_names(locals(), 'svn_fs_')
@@ -130,6 +131,18 @@ class FileDiff:
return self.tempfile1, self.tempfile2
def get_pipe(self):
+ """Perform diff and return a file object from which the output can
+ be read.
+
+ When DIFFOPTIONS is None (the default), use svn's internal diff.
+
+ With any other DIFFOPTIONS, exec the external diff found on PATH,
+ passing it DIFFOPTIONS. On Windows, exec diff.exe rather than
+ diff. If a diff utility is not installed or found on PATH, throws
+ FileNotFoundError. Caveat: On some systems, including Windows, an
+ external diff may not be available unless installed and added to
+ PATH manually.
+ """
self.get_files()
# If diffoptions were provided, then the diff command needs to be
@@ -142,8 +155,17 @@ class FileDiff:
+ [self.tempfile1, self.tempfile2]
# open the pipe, and return the file object for reading from the child.
- p = _subprocess.Popen(cmd, stdout=_subprocess.PIPE, bufsize=-1,
- close_fds=_sys.platform != "win32")
+ try:
+ p = _subprocess.Popen(cmd, stdout=_subprocess.PIPE, bufsize=-1,
+ close_fds=_sys.platform != "win32")
+ # When removing Python 2 support: Change to FileNotFoundError and
+ # remove check for ENOENT (FileNotFoundError "Corresponds to errno
+ # ENOENT" according to documentation)
+ except OSError as err:
+ if err.errno == errno.ENOENT:
+ err.strerror = "External diff command not found in PATH"
+ raise err
+
return _PopenStdoutWrapper(p)
else: