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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    def _show_diff(self, specific_files, extra_trees):
64
64
        from dulwich.patch import write_blob_diff
65
65
        iterator = self.new_tree.iter_changes(self.old_tree,
66
 
            specific_files=specific_files, extra_trees=extra_trees,
67
 
            require_versioned=True)
 
66
                                              specific_files=specific_files, extra_trees=extra_trees,
 
67
                                              require_versioned=True)
68
68
        has_changes = 0
 
69
 
69
70
        def get_encoded_path(path):
70
71
            if path is not None:
71
72
                return path.encode(self.path_encoding, "replace")
 
73
 
72
74
        def get_file_mode(tree, path, kind, executable):
73
75
            if path is None:
74
76
                return 0
75
77
            return object_mode(kind, executable)
 
78
 
76
79
        def get_blob(present, tree, path):
77
80
            if present:
78
81
                with tree.get_file(path) as f:
100
103
                    get_file_mode(trees[1], path_encoded[1],
101
104
                                  kind[1], executable[1]))
102
105
            write_blob_diff(self.to_file,
103
 
                (path_encoded[0], mode[0], contents[0]),
104
 
                (path_encoded[1], mode[1], contents[1]))
 
106
                            (path_encoded[0], mode[0], contents[0]),
 
107
                            (path_encoded[1], mode[1], contents[1]))
105
108
            has_changes |= (changed_content or renamed)
106
109
        return has_changes
107
110
 
118
121
                 target_branch, source_branch=None, message=None,
119
122
                 patches=None, local_target_branch=None):
120
123
        super(GitMergeDirective, self).__init__(revision_id=revision_id,
121
 
            testament_sha1=testament_sha1, time=time, timezone=timezone,
122
 
            target_branch=target_branch, patch=None,
123
 
            source_branch=source_branch, message=message,
124
 
            bundle=None)
 
124
                                                testament_sha1=testament_sha1, time=time, timezone=timezone,
 
125
                                                target_branch=target_branch, patch=None,
 
126
                                                source_branch=source_branch, message=message,
 
127
                                                bundle=None)
125
128
        self.patches = patches
126
129
 
127
130
    def to_lines(self):
145
148
        tree_2 = repository.revision_tree(revision_id)
146
149
        contents = BytesIO()
147
150
        differ = GitDiffTree.from_trees_options(tree_1, tree_2,
148
 
                contents, 'utf8', None, 'a/', 'b/', None)
 
151
                                                contents, 'utf8', None, 'a/', 'b/', None)
149
152
        differ.show_diff(None, None)
150
153
        write_commit_patch(s, commit, contents.getvalue(), (num, total),
151
154
                           version_tail)
165
168
            todo = graph.find_difference(submit_revision_id, revision_id)[1]
166
169
            total = len(todo)
167
170
            for i, revid in enumerate(graph.iter_topo_order(todo)):
168
 
                patches.append(cls._generate_commit(repository, revid, i+1,
169
 
                    total))
 
171
                patches.append(cls._generate_commit(repository, revid, i + 1,
 
172
                                                    total))
170
173
        return cls(revision_id, None, time, timezone,
171
 
            target_branch=target_branch, source_branch=public_branch,
172
 
            message=message, patches=patches)
 
174
                   target_branch=target_branch, source_branch=public_branch,
 
175
                   message=message, patches=patches)
173
176
 
174
177
 
175
178
def send_git(branch, revision_id, submit_branch, public_branch, no_patch, no_bundle, message, base_revision_id, local_target_branch=None):
176
179
    if no_patch:
177
 
        raise errors.BzrCommandError("no patch not supported for git-am style patches")
 
180
        raise errors.BzrCommandError(
 
181
            "no patch not supported for git-am style patches")
178
182
    if no_bundle:
179
 
        raise errors.BzrCommandError("no bundle not supported for git-am style patches")
 
183
        raise errors.BzrCommandError(
 
184
            "no bundle not supported for git-am style patches")
180
185
    return GitMergeDirective.from_objects(
181
186
        branch.repository, revision_id, time.time(),
182
187
        osutils.local_time_offset(), submit_branch,