/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/plugins/propose/propose.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-02 22:31:28 UTC
  • mfrom: (7291 work)
  • mto: This revision was merged to the branch mainline in revision 7293.
  • Revision ID: jelmer@jelmer.uk-20190302223128-0qk1i5tozmzq5nyq
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    errors,
23
23
    hooks,
24
24
    registry,
 
25
    urlutils,
25
26
    )
26
27
 
27
28
 
83
84
        self.hoster = hoster
84
85
 
85
86
 
 
87
class HosterLoginRequired(errors.BzrError):
 
88
    """Action requires hoster login credentials."""
 
89
 
 
90
    _fmt = "Action requires credentials for hosting site %(hoster)r."""
 
91
 
 
92
    def __init__(self, hoster):
 
93
        errors.BzrError.__init__(self)
 
94
        self.hoster = hoster
 
95
 
 
96
 
86
97
class MergeProposal(object):
87
98
    """A merge proposal.
88
99
 
175
186
        :param base_branch: branch to derive the new branch from
176
187
        :param new_branch: branch to publish
177
188
        :return: resulting branch, public URL
 
189
        :raise HosterLoginRequired: Action requires a hoster login, but none is
 
190
            known.
178
191
        """
179
192
        raise NotImplementedError(self.publish)
180
193
 
213
226
        raise NotImplementedError(self.hosts)
214
227
 
215
228
    @classmethod
216
 
    def probe(cls, branch):
 
229
    def probe_from_branch(cls, branch):
217
230
        """Create a Hoster object if this hoster knows about a branch."""
218
 
        raise NotImplementedError(cls.probe)
 
231
        url = urlutils.split_segment_parameters(branch.user_url)[0]
 
232
        return cls.probe_from_url(url)
 
233
 
 
234
    @classmethod
 
235
    def probe_from_url(cls, url):
 
236
        """Create a Hoster object if this hoster knows about a URL."""
 
237
        raise NotImplementedError(cls.probe_from_url)
219
238
 
220
239
    # TODO(jelmer): Some way of cleaning up old branch proposals/branches
221
240
 
225
244
        :param status: Only yield proposals with this status
226
245
            (one of: 'open', 'closed', 'merged', 'all')
227
246
        :return: Iterator over MergeProposal objects
 
247
        :raise HosterLoginRequired: Action requires a hoster login, but none is
 
248
            known.
228
249
        """
229
250
        raise NotImplementedError(self.iter_my_proposals)
230
251
 
245
266
                return hoster
246
267
    for name, hoster_cls in hosters.items():
247
268
        try:
248
 
            hoster = hoster_cls.probe(branch)
 
269
            hoster = hoster_cls.probe_from_branch(branch)
249
270
        except UnsupportedHoster:
250
271
            pass
251
272
        else: