~spiv/bzr-builddeb/trunk-merge-of-use-dpkg-mergechangelogs

« back to all changes in this revision

Viewing changes to tagging.py

  • Committer: Jelmer Vernooij
  • Date: 2011-06-28 08:21:35 UTC
  • mfrom: (578.1.1 move-upstream-tag)
  • Revision ID: jelmer@samba.org-20110628082135-b5peulc3cf16ej55
Merge moving of upstream tag functionality to upstream/pristinetar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
"""Tagging related functions for bzr-builddeb."""
21
21
 
22
 
__all__ = ['is_upstream_tag', 'upstream_tag_version']
23
 
 
24
 
 
25
22
try:
26
23
    from debian.changelog import Version
27
24
except ImportError:
29
26
    from debian_bundle.changelog import Version
30
27
 
31
28
 
32
 
def is_upstream_tag(tag):
33
 
    """Return true if tag is an upstream tag.
34
 
    
35
 
    :param tag: The string name of the tag.
36
 
    :return: True if the tag name is one generated by upstream tag operations.
37
 
 
38
 
    >>> is_upstream_tag('2.1')
39
 
    False
40
 
    >>> is_upstream_tag('upstream-2.1')
41
 
    True
42
 
    """
43
 
    return tag.startswith('upstream-') or tag.startswith('upstream/')
44
 
 
45
 
 
46
 
def upstream_tag_version(tag):
47
 
    """Return the upstream version portion of an upstream tag name.
48
 
 
49
 
    :param tag: The string name of the tag.
50
 
    :return: The version portion of the tag.
51
 
 
52
 
    >>> upstream_tag_version('upstream-2.1')
53
 
    '2.1'
54
 
    """
55
 
    assert is_upstream_tag(tag), "Not an upstream tag: %s" % tag
56
 
    if tag.startswith('upstream/'):
57
 
        tag = tag[len('upstream/'):]
58
 
    elif tag.startswith('upstream-'):
59
 
        tag = tag[len('upstream-'):]
60
 
        if tag.startswith('debian-'):
61
 
            tag = tag[len('debian-'):]
62
 
        elif tag.startswith('ubuntu-'):
63
 
            tag = tag[len('ubuntu-'):]
64
 
    return tag
65
 
 
66
 
 
67
29
def sort_debversion(branch, tags):
68
30
    """Sort tags using Debian version in-place.
69
31