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

Implement to_files() for git merge directives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    branch as _mod_branch,
27
27
    diff as _mod_diff,
28
28
    errors,
29
 
    merge_directive,
30
29
    osutils,
31
30
    revision as _mod_revision,
32
31
    )
33
32
 
 
33
try:
 
34
    from bzrlib.merge_directive import BaseMergeDirective
 
35
except ImportError:
 
36
    from bzrlib.merge_directive import (
 
37
        _BaseMergeDirective as BaseMergeDirective,
 
38
        )
 
39
 
34
40
from bzrlib.plugins.git import (
35
41
    version_info as bzr_git_version_info,
36
42
    )
102
108
        return has_changes
103
109
 
104
110
 
105
 
class GitMergeDirective(merge_directive._BaseMergeDirective):
 
111
class GitMergeDirective(BaseMergeDirective):
 
112
 
 
113
    multiple_output_files = True
 
114
 
 
115
    def __init__(self, revision_id, testament_sha1, time, timezone,
 
116
                 target_branch, source_branch=None, message=None,
 
117
                 patches=None):
 
118
        super(GitMergeDirective, self).__init__(revision_id=revision_id,
 
119
            testament_sha1=testament_sha1, time=time, timezone=timezone,
 
120
            target_branch=target_branch, patch=None,
 
121
            source_branch=source_branch, message=message, bundle=None)
 
122
        self.patches = patches
106
123
 
107
124
    def to_lines(self):
108
125
        return self.patch.splitlines(True)
109
126
 
 
127
    def to_files(self):
 
128
        return self.patches
 
129
 
110
130
    @classmethod
111
131
    def _generate_commit(cls, repository, revision_id, num, total):
112
132
        s = StringIO()
125
145
        differ.show_diff(None, None)
126
146
        write_commit_patch(s, commit, contents.getvalue(), (num, total),
127
147
                           version_tail)
128
 
        summary = "%04d-%s" % (num, get_summary(commit))
 
148
        summary = "%04d-%s.patch" % (num, get_summary(commit).rstrip("."))
129
149
        return summary, s.getvalue()
130
150
 
131
151
    @classmethod
143
163
            total = len(todo)
144
164
            for i, revid in enumerate(graph.iter_topo_order(todo)):
145
165
                patches.append(cls._generate_commit(repository, revid, i+1,
146
 
                                                    total))
 
166
                    total))
147
167
        finally:
148
168
            submit_branch.unlock()
149
 
        return cls(revision_id, None, time, timezone, target_branch,
150
 
            "".join([patch for (summary, patch) in patches]),
151
 
            None, public_branch, message)
 
169
        return cls(revision_id, None, time, timezone,
 
170
            target_branch=target_branch, source_branch=public_branch,
 
171
            message=message, patches=patches)
152
172
 
153
173
 
154
174
def send_git(branch, revision_id, submit_branch, public_branch, no_patch,