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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-07-07 18:00:25 UTC
  • mfrom: (7358.6.3 change-editor-consistent)
  • Revision ID: breezy.the.bot@gmail.com-20190707180025-pi7xd07tqmytn4jz
Use standard syntax for the ``change_editor`` configuration option.

Merged from https://code.launchpad.net/~jelmer/brz/change-editor-consistent/+merge/369364

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import difflib
20
20
import os
21
21
import re
22
 
import string
23
22
import sys
24
23
 
25
24
from .lazy_import import lazy_import
30
29
import tempfile
31
30
 
32
31
from breezy import (
33
 
    cmdline,
34
32
    controldir,
35
33
    errors,
36
34
    osutils,
54
52
DEFAULT_CONTEXT_AMOUNT = 3
55
53
 
56
54
 
57
 
class AtTemplate(string.Template):
58
 
    """Templating class that uses @ instead of $."""
59
 
 
60
 
    delimiter = '@'
61
 
 
62
 
 
63
55
# TODO: Rather than building a changeset object, we should probably
64
56
# invoke callbacks on an object.  That object can either accumulate a
65
57
# list, write them out directly, etc etc.
790
782
        self._root = osutils.mkdtemp(prefix='brz-diff-')
791
783
 
792
784
    @classmethod
793
 
    def from_string(klass, command_string, old_tree, new_tree, to_file,
 
785
    def from_string(klass, command_template, old_tree, new_tree, to_file,
794
786
                    path_encoding='utf-8'):
795
 
        command_template = cmdline.split(command_string)
796
 
        if '@' not in command_string:
797
 
            command_template.extend(['@old_path', '@new_path'])
798
787
        return klass(command_template, old_tree, new_tree, to_file,
799
788
                     path_encoding)
800
789
 
810
799
 
811
800
    def _get_command(self, old_path, new_path):
812
801
        my_map = {'old_path': old_path, 'new_path': new_path}
813
 
        command = [AtTemplate(t).substitute(my_map) for t in
 
802
        command = [t.format(**my_map) for t in
814
803
                   self.command_template]
815
804
        if sys.platform == 'win32':  # Popen doesn't accept unicode on win32
816
805
            command_encoded = []