~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mergetools.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Utility functions for managing external merge tools such as kdiff3."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import os
20
22
import shutil
21
23
import subprocess
46
48
    cmd_list = cmdline.split(command_line)
47
49
    exe = cmd_list[0]
48
50
    if sys.platform == 'win32':
49
 
        if os.path.isabs(exe):
50
 
            base, ext = os.path.splitext(exe)
51
 
            path_ext = [unicode(s.lower())
52
 
                        for s in os.getenv('PATHEXT', '').split(os.pathsep)]
53
 
            return os.path.exists(exe) and ext in path_ext
54
 
        else:
55
 
            return osutils.find_executable_on_path(exe) is not None
 
51
        exe = _get_executable_path(exe)
 
52
        if exe is None:
 
53
            return False
 
54
        base, ext = os.path.splitext(exe)
 
55
        path_ext = [unicode(s.lower())
 
56
                    for s in os.getenv('PATHEXT', '').split(os.pathsep)]
 
57
        return os.path.exists(exe) and ext in path_ext
56
58
    else:
57
59
        return (os.access(exe, os.X_OK)
58
60
                or osutils.find_executable_on_path(exe) is not None)
67
69
    if invoker is None:
68
70
        invoker = subprocess_invoker
69
71
    cmd_list = cmdline.split(command_line)
 
72
    exe = _get_executable_path(cmd_list[0])
 
73
    if exe is not None:
 
74
        cmd_list[0] = exe
70
75
    args, tmp_file = _subst_filename(cmd_list, filename)
71
76
    def cleanup(retcode):
72
77
        if tmp_file is not None:
77
82
    return invoker(args[0], args[1:], cleanup)
78
83
 
79
84
 
 
85
def _get_executable_path(exe):
 
86
    if os.path.isabs(exe):
 
87
        return exe
 
88
    return osutils.find_executable_on_path(exe)
 
89
 
 
90
 
80
91
def _subst_filename(args, filename):
81
92
    subst_names = {
82
93
        'base': filename + u'.BASE',