~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mergetools.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-21 20:32:16 UTC
  • mfrom: (5809.1.2 pwit1)
  • mto: This revision was merged to the branch mainline in revision 5821.
  • Revision ID: jelmer@samba.org-20110421203216-r04j4x5vugrup6u9
Merge per-wt-inventory-tests-pt1.

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
 
 
21
19
import os
22
20
import shutil
23
21
import subprocess
48
46
    cmd_list = cmdline.split(command_line)
49
47
    exe = cmd_list[0]
50
48
    if sys.platform == 'win32':
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
 
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
58
56
    else:
59
57
        return (os.access(exe, os.X_OK)
60
58
                or osutils.find_executable_on_path(exe) is not None)
69
67
    if invoker is None:
70
68
        invoker = subprocess_invoker
71
69
    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
75
70
    args, tmp_file = _subst_filename(cmd_list, filename)
76
71
    def cleanup(retcode):
77
72
        if tmp_file is not None:
82
77
    return invoker(args[0], args[1:], cleanup)
83
78
 
84
79
 
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
 
 
91
80
def _subst_filename(args, filename):
92
81
    subst_names = {
93
82
        'base': filename + u'.BASE',