/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/commands.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:
45
45
    takes_args = ["src_location", "dest_location?"]
46
46
 
47
47
    takes_options = [
48
 
                     Option('colocated', help='Create colocated branches.'),
49
 
                     ]
 
48
        Option('colocated', help='Create colocated branches.'),
 
49
        ]
50
50
 
51
51
    def _get_colocated_branch(self, target_controldir, name):
52
52
        from ..errors import NotBranchError
110
110
 
111
111
        source_repo = Repository.open(src_location)
112
112
        if not isinstance(source_repo, GitRepository):
113
 
            raise BzrCommandError(gettext("%r is not a git repository") % src_location)
 
113
            raise BzrCommandError(
 
114
                gettext("%r is not a git repository") % src_location)
114
115
        try:
115
116
            target_controldir = ControlDir.open_from_transport(dest_transport)
116
117
        except NotBranchError:
122
123
            target_repo = target_controldir.create_repository(shared=True)
123
124
 
124
125
        if not target_repo.supports_rich_root():
125
 
            raise BzrCommandError(gettext("Target repository doesn't support rich roots"))
 
126
            raise BzrCommandError(
 
127
                gettext("Target repository doesn't support rich roots"))
126
128
 
127
129
        interrepo = InterRepository.get(source_repo, target_repo)
128
130
        mapping = source_repo.get_mapping()
139
141
                if getattr(target_controldir._format, "colocated_branches", False) and colocated:
140
142
                    if name == "HEAD":
141
143
                        branch_name = None
142
 
                    head_branch = self._get_colocated_branch(target_controldir, branch_name)
 
144
                    head_branch = self._get_colocated_branch(
 
145
                        target_controldir, branch_name)
143
146
                else:
144
 
                    head_branch = self._get_nested_branch(dest_transport, dest_format, branch_name)
 
147
                    head_branch = self._get_nested_branch(
 
148
                        dest_transport, dest_format, branch_name)
145
149
                revid = mapping.revision_id_foreign_to_bzr(sha)
146
150
                source_branch = LocalGitBranch(source_repo.controldir, source_repo,
147
 
                    sha)
 
151
                                               sha)
148
152
                if head_branch.last_revision() != revid:
149
153
                    head_branch.generate_revision_history(revid)
150
154
                source_branch.tags.merge_to(head_branch.tags)
171
175
    aliases = ["git-objects", "git-cat"]
172
176
    takes_args = ["sha1?"]
173
177
    takes_options = [Option('directory',
174
 
        short_name='d',
175
 
        help='Location of repository.', type=text_type),
176
 
        Option('pretty', help='Pretty-print objects.')]
 
178
                            short_name='d',
 
179
                            help='Location of repository.', type=text_type),
 
180
                     Option('pretty', help='Pretty-print objects.')]
177
181
    encoding_type = 'exact'
178
182
 
179
183
    @display_command
196
200
                try:
197
201
                    obj = object_store[str(sha1)]
198
202
                except KeyError:
199
 
                    raise BzrCommandError(gettext("Object not found: %s") % sha1)
 
203
                    raise BzrCommandError(
 
204
                        gettext("Object not found: %s") % sha1)
200
205
                if pretty:
201
206
                    text = obj.as_pretty_string()
202
207
                else:
233
238
        with object_store.lock_read():
234
239
            refs = get_refs_container(controldir, object_store)
235
240
            for k, v in sorted(viewitems(refs.as_dict())):
236
 
                self.outf.write("%s -> %s\n" % (k.decode('utf-8'), v.decode('utf-8')))
 
241
                self.outf.write("%s -> %s\n" %
 
242
                                (k.decode('utf-8'), v.decode('utf-8')))
237
243
 
238
244
 
239
245
class cmd_git_apply(Command):
246
252
    takes_options = [
247
253
        Option('signoff', short_name='s', help='Add a Signed-off-by line.'),
248
254
        Option('force',
249
 
            help='Apply patches even if tree has uncommitted changes.')
 
255
               help='Apply patches even if tree has uncommitted changes.')
250
256
        ]
251
257
    takes_args = ["patches*"]
252
258
 
265
271
        # FIXME: Cope with git-specific bits in patch
266
272
        # FIXME: Add new files to working tree
267
273
        p = subprocess.Popen(["patch", "-p1"], stdin=subprocess.PIPE,
268
 
            cwd=wt.basedir)
 
274
                             cwd=wt.basedir)
269
275
        p.communicate(diff)
270
276
        exitcode = p.wait()
271
277
        if exitcode != 0:
295
301
    """Push pristine tar deltas to a git repository."""
296
302
 
297
303
    takes_options = [Option('directory',
298
 
        short_name='d',
299
 
        help='Location of repository.', type=text_type)]
 
304
                            short_name='d',
 
305
                            help='Location of repository.', type=text_type)]
300
306
    takes_args = ['target', 'package']
301
307
 
302
308
    def run(self, target, package, directory='.'):
332
338
                gitid = git_store._lookup_revision_sha1(revid)
333
339
                if not (name.startswith('upstream/') or name.startswith('upstream-')):
334
340
                    warning("Unexpected pristine tar revision tagged %s. Ignoring.",
335
 
                         name)
 
341
                            name)
336
342
                    continue
337
343
                upstream_version = name[len("upstream/"):]
338
 
                filename = '%s_%s.orig.tar.%s' % (package, upstream_version, kind)
 
344
                filename = '%s_%s.orig.tar.%s' % (
 
345
                    package, upstream_version, kind)
339
346
                if not gitid in target:
340
347
                    warning("base git id %s for %s missing in target repository",
341
348
                            gitid, filename)
342
349
                store_git_pristine_tar_data(target, filename.encode('utf-8'),
343
 
                    delta, gitid)
 
350
                                            delta, gitid)