/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: 2019-12-23 01:39:21 UTC
  • mfrom: (7424 work)
  • mto: This revision was merged to the branch mainline in revision 7425.
  • Revision ID: jelmer@jelmer.uk-20191223013921-2kzd0wlcoylgxksk
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from __future__ import absolute_import
25
25
 
26
26
import breezy.bzr  # noqa: F401
 
27
from breezy import controldir
27
28
from ..commands import (
28
29
    Command,
29
30
    display_command,
30
31
    )
31
32
from ..option import (
32
33
    Option,
 
34
    RegistryOption,
33
35
    )
34
36
from ..sixish import (
35
37
    text_type,
46
48
 
47
49
    takes_options = [
48
50
        Option('colocated', help='Create colocated branches.'),
 
51
        RegistryOption('dest-format',
 
52
                       help='Specify a format for this branch. '
 
53
                       'See "help formats" for a full list.',
 
54
                       lazy_registry=('breezy.controldir', 'format_registry'),
 
55
                       converter=lambda name: controldir.format_registry.make_controldir(
 
56
                            name),
 
57
                       value_switches=True,
 
58
                       title="Branch format",
 
59
                       ),
49
60
        ]
50
61
 
51
62
    def _get_colocated_branch(self, target_controldir, name):
69
80
        except NotBranchError:
70
81
            return head_controldir.create_branch()
71
82
 
72
 
    def run(self, src_location, dest_location=None, colocated=False):
 
83
    def run(self, src_location, dest_location=None, colocated=False, dest_format=None):
73
84
        import os
74
85
        from .. import (
75
86
            controldir,
100
111
            )
101
112
        from .repository import GitRepository
102
113
 
103
 
        dest_format = controldir.ControlDirFormat.get_default_format()
104
114
        if dest_format is None:
105
 
            raise BzrError('no default format')
 
115
            dest_format = controldir.format_registry.make_controldir('default')
106
116
 
107
117
        if dest_location is None:
108
118
            dest_location = os.path.basename(src_location.rstrip("/\\"))
130
140
        interrepo = InterRepository.get(source_repo, target_repo)
131
141
        mapping = source_repo.get_mapping()
132
142
        refs = interrepo.fetch()
133
 
        pb = ui.ui_factory.nested_progress_bar()
134
 
        try:
 
143
        with ui.ui_factory.nested_progress_bar() as pb:
135
144
            for i, (name, sha) in enumerate(viewitems(refs)):
136
145
                try:
137
146
                    branch_name = ref_to_branch_name(name)
159
168
                        source_branch.base,
160
169
                        {"branch": urlutils.escape(branch_name)})
161
170
                    head_branch.set_parent(url)
162
 
        finally:
163
 
            pb.finished()
164
171
        trace.note(gettext(
165
172
            "Use 'bzr checkout' to create a working tree in "
166
173
            "the newly created branches."))
265
272
        :param f: Patch file to read.
266
273
        :param signoff: Add Signed-Off-By flag.
267
274
        """
268
 
        from ..i18n import gettext
269
 
        from ..errors import BzrCommandError
270
275
        from dulwich.patch import git_am_patch_split
271
 
        import subprocess
 
276
        from breezy.patch import patch_tree
272
277
        (c, diff, version) = git_am_patch_split(f)
273
278
        # FIXME: Cope with git-specific bits in patch
274
279
        # FIXME: Add new files to working tree
275
 
        p = subprocess.Popen(["patch", "-p1"], stdin=subprocess.PIPE,
276
 
                             cwd=wt.basedir)
277
 
        p.communicate(diff)
278
 
        exitcode = p.wait()
279
 
        if exitcode != 0:
280
 
            raise BzrCommandError(gettext("error running patch"))
 
280
        patch_tree(wt, [diff], strip=1, out=self.outf)
281
281
        message = c.message.decode('utf-8')
282
282
        if signoff:
283
283
            signed_off_by = wt.branch.get_config().username()