/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: John Arbash Meinel
  • Date: 2010-01-06 17:46:15 UTC
  • mto: (4634.119.1 2.0)
  • mto: This revision was merged to the branch mainline in revision 4951.
  • Revision ID: john@arbash-meinel.com-20100106174615-cq1nckxhbuyemgjx
Fix bug #503886, errors setting up logging go to stderr.

The basic issue is that we were using logging to describe failures
to set up logging. However, those fail with bad error messages
rather than giving us the output we want. This was especially bad
when the failure was occuring on the server. Since 'ssh' will pass
back the stderr stream without bzr handling it at all.

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)
409
371
        :return: a MergeRequest
410
372
        """
411
373
        line_iter = iter(lines)
412
 
        firstline = ""
413
374
        for line in line_iter:
414
375
            if line.startswith('# Bazaar merge directive format '):
415
 
                return _format_registry.get(line[2:].rstrip())._from_lines(
416
 
                    line_iter)
417
 
            firstline = firstline or line.strip()
418
 
        raise errors.NotAMergeDirective(firstline)
 
376
                break
 
377
        else:
 
378
            if len(lines) > 0:
 
379
                raise errors.NotAMergeDirective(lines[0])
 
380
            else:
 
381
                raise errors.NotAMergeDirective('')
 
382
        return _format_registry.get(line[2:].rstrip())._from_lines(line_iter)
419
383
 
420
384
    @classmethod
421
385
    def _from_lines(klass, line_iter):
466
430
        return None, self.revision_id, 'inapplicable'
467
431
 
468
432
 
469
 
class MergeDirective2(BaseMergeDirective):
 
433
class MergeDirective2(_BaseMergeDirective):
470
434
 
471
435
    _format_string = 'Bazaar merge directive format 2 (Bazaar 0.90)'
472
436
 
475
439
                 bundle=None, base_revision_id=None):
476
440
        if source_branch is None and bundle is None:
477
441
            raise errors.NoMergeSource()
478
 
        BaseMergeDirective.__init__(self, revision_id, testament_sha1, time,
 
442
        _BaseMergeDirective.__init__(self, revision_id, testament_sha1, time,
479
443
            timezone, target_branch, patch, source_branch, message)
480
444
        self.bundle = bundle
481
445
        self.base_revision_id = base_revision_id