/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/diff.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-28 07:08:42 UTC
  • mfrom: (2380 +trunk)
  • mto: (2018.5.146 hpss)
  • mto: This revision was merged to the branch mainline in revision 2414.
  • Revision ID: andrew.bennetts@canonical.com-20070328070842-r843houy668oxb9o
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    osutils,
31
31
    patiencediff,
32
32
    textfile,
 
33
    timestamp,
33
34
    )
34
35
""")
35
36
 
95
96
    print >>to_file
96
97
 
97
98
 
98
 
def _set_lang_C():
99
 
    """Set the env vars LANG=C and LC_ALL=C."""
100
 
    osutils.set_or_unset_env('LANG', 'C')
101
 
    osutils.set_or_unset_env('LC_ALL', 'C')
102
 
    osutils.set_or_unset_env('LC_CTYPE', None)
103
 
    osutils.set_or_unset_env('LANGUAGE', None)
104
 
 
105
 
 
106
99
def _spawn_external_diff(diffcmd, capture_errors=True):
107
100
    """Spawn the externall diff process, and return the child handle.
108
101
 
113
106
    :return: A Popen object.
114
107
    """
115
108
    if capture_errors:
116
 
        if sys.platform == 'win32':
117
 
            # Win32 doesn't support preexec_fn, but that is
118
 
            # okay, because it doesn't support LANG and LC_ALL either.
119
 
            preexec_fn = None
120
 
        else:
121
 
            preexec_fn = _set_lang_C
 
109
        # construct minimal environment
 
110
        env = {}
 
111
        path = os.environ.get('PATH')
 
112
        if path is not None:
 
113
            env['PATH'] = path
 
114
        env['LANGUAGE'] = 'C'   # on win32 only LANGUAGE has effect
 
115
        env['LANG'] = 'C'
 
116
        env['LC_ALL'] = 'C'
122
117
        stderr = subprocess.PIPE
123
118
    else:
124
 
        preexec_fn = None
 
119
        env = None
125
120
        stderr = None
126
121
 
127
122
    try:
129
124
                                stdin=subprocess.PIPE,
130
125
                                stdout=subprocess.PIPE,
131
126
                                stderr=stderr,
132
 
                                preexec_fn=preexec_fn)
 
127
                                env=env)
133
128
    except OSError, e:
134
129
        if e.errno == errno.ENOENT:
135
130
            raise errors.NoDiff(str(e))
397
392
    """
398
393
    old_tree.lock_read()
399
394
    try:
 
395
        if extra_trees is not None:
 
396
            for tree in extra_trees:
 
397
                tree.lock_read()
400
398
        new_tree.lock_read()
401
399
        try:
402
400
            return _show_diff_trees(old_tree, new_tree, to_file,
405
403
                                    extra_trees=extra_trees)
406
404
        finally:
407
405
            new_tree.unlock()
 
406
            if extra_trees is not None:
 
407
                for tree in extra_trees:
 
408
                    tree.unlock()
408
409
    finally:
409
410
        old_tree.unlock()
410
411
 
484
485
 
485
486
def _patch_header_date(tree, file_id, path):
486
487
    """Returns a timestamp suitable for use in a patch header."""
487
 
    tm = time.gmtime(tree.get_file_mtime(file_id, path))
488
 
    return time.strftime('%Y-%m-%d %H:%M:%S +0000', tm)
 
488
    return timestamp.format_patch_date(tree.get_file_mtime(file_id, path))
489
489
 
490
490
 
491
491
def _raise_if_nonexistent(paths, old_tree, new_tree):