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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-11-19 19:46:23 UTC
  • mfrom: (7524.2.5 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20201119194623-5tfi4z6ktdzo0z3y
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/394038

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Helper functions for proposing merges."""
18
18
 
 
19
import re
 
20
 
19
21
from . import (
20
22
    errors,
21
23
    hooks,
37
39
 
38
40
    _fmt = "A merge proposal already exists: %(url)s."
39
41
 
40
 
    def __init__(self, url):
 
42
    def __init__(self, url, existing_proposal=None):
41
43
        errors.BzrError.__init__(self)
42
44
        self.url = url
 
45
        self.existing_proposal = existing_proposal
43
46
 
44
47
 
45
48
class UnsupportedHoster(errors.BzrError):
338
341
        """Create a Hoster object if this hoster knows about a URL."""
339
342
        raise NotImplementedError(cls.probe_from_url)
340
343
 
341
 
    def iter_my_proposals(self, status='open'):
 
344
    def iter_my_proposals(self, status='open', author=None):
342
345
        """Iterate over the proposals created by the currently logged in user.
343
346
 
344
347
        :param status: Only yield proposals with this status
345
348
            (one of: 'open', 'closed', 'merged', 'all')
 
349
        :param author: Name of author to query (defaults to current user)
346
350
        :return: Iterator over MergeProposal objects
347
351
        :raise HosterLoginRequired: Action requires a hoster login, but none is
348
352
            known.
349
353
        """
350
354
        raise NotImplementedError(self.iter_my_proposals)
351
355
 
352
 
    def iter_my_forks(self):
 
356
    def iter_my_forks(self, owner=None):
353
357
        """Iterate over the currently logged in users' forks.
354
358
 
 
359
        :param owner: Name of owner to query (defaults to current user)
355
360
        :return: Iterator over project_name
356
361
        """
357
362
        raise NotImplementedError(self.iter_my_forks)
383
388
 
384
389
def determine_title(description):
385
390
    """Determine the title for a merge proposal based on full description."""
386
 
    return description.splitlines()[0].split('.')[0]
 
391
    firstline = description.splitlines()[0]
 
392
    try:
 
393
        i = firstline.index('. ')
 
394
    except ValueError:
 
395
        return firstline.rstrip('.')
 
396
    else:
 
397
        return firstline[:i]
387
398
 
388
399
 
389
400
def get_hoster(branch, possible_hosters=None):
410
421
    raise UnsupportedHoster(branch)
411
422
 
412
423
 
413
 
def iter_hoster_instances():
 
424
def iter_hoster_instances(hoster=None):
414
425
    """Iterate over all known hoster instances.
415
426
 
416
427
    :return: Iterator over Hoster instances
417
428
    """
418
 
    for name, hoster_cls in hosters.items():
 
429
    if hoster is None:
 
430
        hoster_clses = [hoster_cls for name, hoster_cls in hosters.items()]
 
431
    else:
 
432
        hoster_clses = [hoster]
 
433
    for hoster_cls in hoster_clses:
419
434
        for instance in hoster_cls.iter_instances():
420
435
            yield instance
421
436