/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

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