/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/mergetools.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    cmd_list = cmdline.split(command_line)
49
49
    exe = cmd_list[0]
50
50
    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
 
51
        if os.path.isabs(exe):
 
52
            base, ext = os.path.splitext(exe)
 
53
            path_ext = [unicode(s.lower())
 
54
                        for s in os.getenv('PATHEXT', '').split(os.pathsep)]
 
55
            return os.path.exists(exe) and ext in path_ext
 
56
        else:
 
57
            return osutils.find_executable_on_path(exe) is not None
58
58
    else:
59
59
        return (os.access(exe, os.X_OK)
60
60
                or osutils.find_executable_on_path(exe) is not None)
69
69
    if invoker is None:
70
70
        invoker = subprocess_invoker
71
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
75
72
    args, tmp_file = _subst_filename(cmd_list, filename)
76
73
    def cleanup(retcode):
77
74
        if tmp_file is not None:
82
79
    return invoker(args[0], args[1:], cleanup)
83
80
 
84
81
 
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
82
def _subst_filename(args, filename):
92
83
    subst_names = {
93
84
        'base': filename + u'.BASE',