~al-maisan/bzr-builddeb/merge-package

« back to all changes in this revision

Viewing changes to util.py

  • Committer: James Westby
  • Author(s): Jelmer Vernooij
  • Date: 2009-07-15 18:17:12 UTC
  • Revision ID: james.westby@canonical.com-20090715181712-l0xitryd9lfi38xy
Look past UNRELEASED changelog entries in merge-upstream. Thanks Jelmer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
            shutil.copy(path, todir)
64
64
 
65
65
 
66
 
def find_changelog(t, merge):
 
66
def find_changelog(t, merge, max_blocks=1):
67
67
    """Find the changelog in the given tree.
68
68
 
69
69
    First looks for 'debian/changelog'. If "merge" is true will also
70
70
    look for 'changelog'.
71
71
 
72
 
    The returned changelog is created with 'max_blocks=1' and
73
 
    'allow_empty_author=True'. The first to try and prevent old broken
74
 
    changelog entries from causing the command to fail, and the
75
 
    second as some people do this but still want to build.
 
72
    The returned changelog is created with 'allow_empty_author=True'
 
73
    as some people do this but still want to build.
 
74
    'max_blocks' defaults to 1 to try and prevent old broken
 
75
    changelog entries from causing the command to fail, 
76
76
 
77
77
    "larstiq" is a subset of "merge" mode. It indicates that the
78
78
    '.bzr' dir is at the same level as 'changelog' etc., rather
80
80
 
81
81
    :param t: the Tree to look in.
82
82
    :param merge: whether this is a "merge" package.
 
83
    :param max_blocks: Number of max_blocks to parse (defaults to 1)
83
84
    :return: (changelog, larstiq) where changelog is the Changelog,
84
85
        and larstiq is a boolean indicating whether the file is at
85
86
        'changelog' if merge was given, False otherwise.
115
116
       t.unlock()
116
117
    changelog = Changelog()
117
118
    try:
118
 
        changelog.parse_changelog(contents, max_blocks=1, allow_empty_author=True)
 
119
        changelog.parse_changelog(contents, max_blocks=max_blocks, allow_empty_author=True)
119
120
    except ChangelogParseError, e:
120
121
        raise UnparseableChangelog(str(e))
121
122
    return changelog, larstiq
412
413
        thanks = find_thanks(changes)
413
414
        message = "\n".join(changes)
414
415
    return (message, authors, thanks, bugs)
 
416
 
 
417
 
 
418
def find_last_distribution(changelog):
 
419
    """Find the last changelog that was used in a changelog.
 
420
 
 
421
    This will skip stanzas with the 'UNRELEASED' distribution.
 
422
    
 
423
    :param changelog: Changelog to analyze
 
424
    """
 
425
    for block in changelog._blocks:
 
426
        distribution = block.distributions.split(" ")[0]
 
427
        if distribution != "UNRELEASED":
 
428
            return distribution
 
429
    return None