/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/plugins/commitfromnews/committemplate.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
 
import patiencediff
22
 
 
23
 
from ... import bugtracker, osutils
 
21
from ... import bugtracker, osutils, patiencediff
24
22
import re
25
23
 
26
24
_BUG_MATCH = re.compile(r'lp:(\d+)')
61
59
            _, new_chunks = list(
62
60
                self.commit.builder.repository.iter_files_bytes(
63
61
                    [(found_entry.file_id, found_entry.revision, None)]))[0]
64
 
            content = b''.join(new_chunks).decode('utf-8')
 
62
            content = ''.join(new_chunks)
65
63
            return self.merge_message(content)
66
64
        else:
67
65
            # Get a diff. XXX Is this hookable? I thought it was, can't find it
68
 
            # though.... add DiffTree.diff_factories. Sadly thats not at the
 
66
            # though.... add DiffTree.diff_factories. Sadly thats not at the 
69
67
            # right level: we want to identify the changed lines, not have the
70
 
            # final diff: because we want to grab the sections for regions
 
68
            # final diff: because we want to grab the sections for regions 
71
69
            # changed in new version of the file. So for now a direct diff
72
70
            # using patiencediff is done.
73
 
            old_revision = self.commit.basis_tree.get_file_revision(old_path)
 
71
            old_revision = self.commit.basis_tree.get_file_revision(
 
72
                old_path, found_entry.file_id)
74
73
            needed = [(found_entry.file_id, found_entry.revision, 'new'),
75
74
                      (found_entry.file_id, old_revision, 'old')]
76
75
            contents = self.commit.builder.repository.iter_files_bytes(needed)
87
86
                    continue
88
87
                if tag == 'delete':
89
88
                    continue
90
 
                new_lines.extend([l.decode('utf-8') for l in new[j1:j2]])
 
89
                new_lines.extend(new[j1:j2])
91
90
            if not self.commit.revprops.get('bugs'):
92
91
                # TODO: Allow the user to configure the bug tracker to use
93
92
                # rather than hardcoding Launchpad.
97
96
                    bugids.extend(_BUG_MATCH.findall(line))
98
97
                self.commit.revprops['bugs'] = \
99
98
                    bugtracker.encode_fixes_bug_urls(
100
 
                        [(bt.get_bug_url(bugid), bugtracker.FIXED)
101
 
                         for bugid in bugids])
 
99
                        [bt.get_bug_url(bugid) for bugid in bugids])
102
100
            return self.merge_message(''.join(new_lines))
103
101
 
104
102
    def merge_message(self, new_message):