~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_directive.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
64
64
            " provided to the next.", (1, 15, 0), False))
65
65
 
66
66
 
67
 
class BaseMergeDirective(object):
68
 
    """A request to perform a merge into a branch.
69
 
 
70
 
    This is the base class that all merge directive implementations 
71
 
    should derive from.
72
 
 
73
 
    :cvar multiple_output_files: Whether or not this merge directive 
74
 
        stores a set of revisions in more than one file
75
 
    """
 
67
class _BaseMergeDirective(object):
76
68
 
77
69
    hooks = MergeDirectiveHooks()
78
70
 
79
 
    multiple_output_files = False
80
 
 
81
71
    def __init__(self, revision_id, testament_sha1, time, timezone,
82
72
                 target_branch, patch=None, source_branch=None, message=None,
83
73
                 bundle=None):
102
92
        self.source_branch = source_branch
103
93
        self.message = message
104
94
 
105
 
    def to_lines(self):
106
 
        """Serialize as a list of lines
107
 
 
108
 
        :return: a list of lines
109
 
        """
110
 
        raise NotImplementedError(self.to_lines)
111
 
 
112
 
    def to_files(self):
113
 
        """Serialize as a set of files.
114
 
 
115
 
        :return: List of tuples with filename and contents as lines
116
 
        """
117
 
        raise NotImplementedError(self.to_files)
118
 
 
119
 
    def get_raw_bundle(self):
120
 
        """Return the bundle for this merge directive.
121
 
 
122
 
        :return: bundle text or None if there is no bundle
123
 
        """
124
 
        return None
125
 
 
126
95
    def _to_lines(self, base_revision=False):
127
96
        """Serialize as a list of lines
128
97
 
142
111
        lines.append('# \n')
143
112
        return lines
144
113
 
145
 
    def write_to_directory(self, path):
146
 
        """Write this merge directive to a series of files in a directory.
147
 
 
148
 
        :param path: Filesystem path to write to
149
 
        """
150
 
        raise NotImplementedError(self.write_to_directory)
151
 
 
152
114
    @classmethod
153
115
    def from_objects(klass, repository, revision_id, time, timezone,
154
116
                 target_branch, patch_type='bundle',
341
303
                                          basename, body)
342
304
 
343
305
 
344
 
class MergeDirective(BaseMergeDirective):
 
306
class MergeDirective(_BaseMergeDirective):
345
307
 
346
308
    """A request to perform a merge into a branch.
347
309
 
376
338
        :param source_branch: A public location to merge the revision from
377
339
        :param message: The message to use when committing this merge
378
340
        """
379
 
        BaseMergeDirective.__init__(self, revision_id, testament_sha1, time,
 
341
        _BaseMergeDirective.__init__(self, revision_id, testament_sha1, time,
380
342
            timezone, target_branch, patch, source_branch, message)
381
343
        if patch_type not in (None, 'diff', 'bundle'):
382
344
            raise ValueError(patch_type)
466
428
        return None, self.revision_id, 'inapplicable'
467
429
 
468
430
 
469
 
class MergeDirective2(BaseMergeDirective):
 
431
class MergeDirective2(_BaseMergeDirective):
470
432
 
471
433
    _format_string = 'Bazaar merge directive format 2 (Bazaar 0.90)'
472
434
 
475
437
                 bundle=None, base_revision_id=None):
476
438
        if source_branch is None and bundle is None:
477
439
            raise errors.NoMergeSource()
478
 
        BaseMergeDirective.__init__(self, revision_id, testament_sha1, time,
 
440
        _BaseMergeDirective.__init__(self, revision_id, testament_sha1, time,
479
441
            timezone, target_branch, patch, source_branch, message)
480
442
        self.bundle = bundle
481
443
        self.base_revision_id = base_revision_id