~luoyonggang/bzr-svn/b2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from bzrlib.branch import Branch
import sys

b = Branch.open(".")

DOWNLOAD_URL = "http://samba.org/~jelmer/bzr"

def write_releaselist(f):
    f.write("\nReleases\n")
    f.write("--------\n\n")

    versions = []

    for release in b.tags.get_tag_dict():
        (name, version) = release.rsplit("-", 1)
        if name == "bzr-svn":
            versions.append(version)

    def version_sort(a, b):
        def versiontuple(a):
            if "rc" in a and not "~rc" in a:
                a = a.replace("rc", "~rc")
            if "~" in a:
                a = a.split("~")[0]
            return [int(x) for x in a.split(".")]
        return cmp(versiontuple(a), versiontuple(b))

    versions.sort(version_sort, reverse=True)

    for version in versions:
        f.write("* `%s`_\n" % version)

    f.write("\n")

    for version in versions:
        f.write(".. _%s: %s/bzr-svn-%s.tar.gz\n" % (version, DOWNLOAD_URL, version))

    f.write("\n")

f = sys.stdout
f.write("#FORMAT rst\n")
f.write(open("README", "r").read())
write_releaselist(f)
f.write(open("INSTALL", "r").read())
f.write("""
Credits
-------
bzr-svn was written by JelmerVernooij_ with the help from various other people.
See the AUTHORS file in the source distribution for a list.

.. _JelmerVernooij: http://samba.org/~jelmer/

""")