~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_directive.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-08 21:37:36 UTC
  • mto: This revision was merged to the branch mainline in revision 4885.
  • Revision ID: john@arbash-meinel.com-20091208213736-vje7ublg3xzp1bs2
Now that we return files directly from the working tree
the windows 'attrib' test needed to be updated.
If we used the working tree for both old and new, then the test wasn't
really testing what we expected, which was that the newly generated
content was readable.

But using basis_tree gets us that. Also, test that the content is
properly marked as readonly, and that we have available content from
the working tree.

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