/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 bzrlib/merge_directive.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from __future__ import absolute_import
18
18
 
 
19
from StringIO import StringIO
19
20
import re
20
21
 
21
 
from . import lazy_import
 
22
from bzrlib import lazy_import
22
23
lazy_import.lazy_import(globals(), """
23
 
from breezy import (
 
24
from bzrlib import (
24
25
    branch as _mod_branch,
25
26
    diff,
26
27
    email_message,
34
35
    timestamp,
35
36
    trace,
36
37
    )
37
 
from breezy.bundle import (
 
38
from bzrlib.bundle import (
38
39
    serializer as bundle_serializer,
39
40
    )
40
41
""")
41
 
from .sixish import (
42
 
    BytesIO,
43
 
    )
44
42
 
45
43
 
46
44
class MergeRequestBodyParams(object):
62
60
    """Hooks for MergeDirective classes."""
63
61
 
64
62
    def __init__(self):
65
 
        hooks.Hooks.__init__(self, "breezy.merge_directive", "BaseMergeDirective.hooks")
 
63
        hooks.Hooks.__init__(self, "bzrlib.merge_directive", "BaseMergeDirective.hooks")
66
64
        self.add_hook('merge_request_body',
67
65
            "Called with a MergeRequestBodyParams when a body is needed for"
68
66
            " a merge request.  Callbacks must return a body.  If more"
226
224
        else:
227
225
            revno = branch.get_revision_id_to_revno_map().get(self.revision_id,
228
226
                ['merge'])
229
 
        nick = re.sub('(\\W+)', '-', branch.nick).strip('-')
 
227
        nick = re.sub('(\W+)', '-', branch.nick).strip('-')
230
228
        return '%s-%s' % (nick, '.'.join(str(n) for n in revno))
231
229
 
232
230
    @staticmethod
233
231
    def _generate_diff(repository, revision_id, ancestor_id):
234
232
        tree_1 = repository.revision_tree(ancestor_id)
235
233
        tree_2 = repository.revision_tree(revision_id)
236
 
        s = BytesIO()
 
234
        s = StringIO()
237
235
        diff.show_diff_trees(tree_1, tree_2, s, old_label='', new_label='')
238
236
        return s.getvalue()
239
237
 
240
238
    @staticmethod
241
239
    def _generate_bundle(repository, revision_id, ancestor_id):
242
 
        s = BytesIO()
 
240
        s = StringIO()
243
241
        bundle_serializer.write_bundle(repository, revision_id,
244
242
                                       ancestor_id, s)
245
243
        return s.getvalue()
251
249
        :return: a string
252
250
        """
253
251
        my_gpg = gpg.GPGStrategy(branch.get_config_stack())
254
 
        return my_gpg.sign(''.join(self.to_lines()), gpg.MODE_CLEAR)
 
252
        return my_gpg.sign(''.join(self.to_lines()))
255
253
 
256
254
    def to_email(self, mail_to, branch, sign=False):
257
255
        """Serialize as an email message.
281
279
        if not target_repo.has_revision(self.revision_id):
282
280
            if self.patch_type == 'bundle':
283
281
                info = bundle_serializer.read_bundle(
284
 
                    BytesIO(self.get_raw_bundle()))
 
282
                    StringIO(self.get_raw_bundle()))
285
283
                # We don't use the bundle's target revision, because
286
284
                # MergeDirective.revision_id is authoritative.
287
285
                try:
437
435
        else:
438
436
            patch = ''.join(patch_lines)
439
437
            try:
440
 
                bundle_serializer.read_bundle(BytesIO(patch))
 
438
                bundle_serializer.read_bundle(StringIO(patch))
441
439
            except (errors.NotABundle, errors.BundleNotSupported,
442
440
                    errors.BadBundle):
443
441
                patch_type = 'diff'
463
461
 
464
462
    @staticmethod
465
463
    def _generate_bundle(repository, revision_id, ancestor_id):
466
 
        s = BytesIO()
 
464
        s = StringIO()
467
465
        bundle_serializer.write_bundle(repository, revision_id,
468
466
                                       ancestor_id, s, '0.9')
469
467
        return s.getvalue()
516
514
        patch = None
517
515
        bundle = None
518
516
        try:
519
 
            start = next(line_iter)
 
517
            start = line_iter.next()
520
518
        except StopIteration:
521
519
            pass
522
520
        else: