/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.5.7 by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information.
1
#!/usr/bin/env python
2
"""\
3
Common entries, like strings, etc, for the changeset reading + writing code.
4
"""
5
6
header_str = 'Bazaar-NG (bzr) changeset v'
7
version = (0, 0, 5)
8
9
def get_header():
10
    return [
11
        header_str + '.'.join([str(v) for v in version]),
12
        'This changeset can be applied with bzr apply-changeset',
13
        ''
14
    ]
15
0.5.36 by John Arbash Meinel
Updated so that read_changeset is able to parse the output
16
def canonicalize_revision(branch, revnos):
17
    """Turn some sort of revision information into a single
18
    set of from-to revision ids.
19
20
    A revision id can be None if there is no associated revison.
21
22
    :param revnos:  A list of revisions to lookup, should be at most 2 long
23
    :return: (old, new)
24
    """
25
    # If only 1 entry is given, then we assume we want just the
26
    # changeset between that entry and it's base (we assume parents[0])
27
    if len(revnos) == 0:
28
        revnos = [None, None]
29
    elif len(revnos) == 1:
30
        revnos = [None, revnos[0]]
31
32
    if revnos[1] is None:
33
        new = branch.last_patch()
34
    else:
35
        new = branch.lookup_revision(revnos[1])
36
    if revnos[0] is None:
37
        old = branch.get_revision(new).parents[0].revision_id
38
    else:
39
        old = branch.lookup_revision(revnos[0])
40
41
    return old, new
42