comparison recipes/kde_enterprise_4/base.py @ 268:bba100869221

Improve handling of nested subdirectories of tags in the enterprise4 tag detector. This is necessary for the kdebase_runtime and kdebase_workspace packages
author Bernhard Herzog <bh@intevation.de>
date Wed, 06 May 2009 13:52:26 +0000
parents fdee17d71778
children 4b700b39c32f
comparison
equal deleted inserted replaced
267:fdee17d71778 268:bba100869221
25 url -- The base url of the SVN tags directory to use 25 url -- The base url of the SVN tags directory to use
26 pattern -- A regular expression matching the subdirectories to 26 pattern -- A regular expression matching the subdirectories to
27 consider in the tag directory specified by the url 27 consider in the tag directory specified by the url
28 subdir -- A subdirectory of the directory matched by pattern to 28 subdir -- A subdirectory of the directory matched by pattern to
29 export and use to determine revision number 29 export and use to determine revision number
30
31 The subdir parameter is there to cope with the kdepim enterprise
32 tags. The URL for a tag is of the form
33 .../tags/kdepim/enterprise4.0.<date>.<rev> . Each such tag has
34 subdirectories for kdepim, kdelibs, etc. The url and pattern are
35 used to match the URL for the tag, and the subdir is used to select
36 which part of the tag is meant.
37
38 The subdir also determines which SVN directory's revision number is
39 used. Normally, just appending the subdir to the tag URL would be
40 enough for this, but the situation is more complex for
41 kdebase_workspace and kdebase_runtime, whose code comes from
42 different subdirectories of the kdebase-4.X-branch subdirectory (for
43 enterprise4 tags). Here the revision number must be taken from
44 kdebase-4.X-branch, but the URL to use when exporting the sources,
45 must refer to e.g. kdebase-4.1-branch/kdebase_workspace. To achieve
46 that, subdir may contain slashes to indicate subdirectories of
47 subdirectories, but only the first part of subdir (up to the first
48 slash) is used when determining the revision number.
30 """ 49 """
31 50
32 def __init__(self, url, pattern, subdir): 51 def __init__(self, url, pattern, subdir):
33 self.url = url 52 self.url = url
34 self.pattern = re.compile(pattern) 53 self.pattern = re.compile(pattern)
45 def newest_tag_revision(self): 64 def newest_tag_revision(self):
46 """Determines the newest tag revision and returns (tagurl, revno) 65 """Determines the newest tag revision and returns (tagurl, revno)
47 If no tag can be found, the method returns the tuple (None, None). 66 If no tag can be found, the method returns the tuple (None, None).
48 """ 67 """
49 candidates = self.list_tags() 68 candidates = self.list_tags()
69 urlrev = (None, None)
50 if candidates: 70 if candidates:
51 newest = candidates[-1] 71 newest = candidates[-1]
52 subdir = self.subdir 72 urlrev = self.determine_revision(self.url + "/" + newest,
53 if not subdir.endswith("/"): 73 self.subdir)
54 subdir += "/" 74 return urlrev
55 tag_url = self.url + "/" + newest
56 tag_subdirs = treepkg.subversion.list_url(tag_url)
57 if subdir in tag_subdirs:
58 subdir_url = tag_url + "/" + subdir
59 revision = treepkg.subversion.last_changed_revision(subdir_url)
60 return subdir_url, revision
61 return None, None
62 75
76 def determine_revision(self, baseurl, subdir):
77 urlrev = (None, None)
78 revision_url = baseurl + "/" + subdir.split("/")[0]
79 try:
80 revision = treepkg.subversion.last_changed_revision(revision_url)
81 urlrev = (baseurl + "/" + subdir, revision)
82 except treepkg.subversion.SubversionError:
83 pass
84 return urlrev
63 85
64 86
65 class BaseSourcePackager(treepkg.packager.SourcePackager): 87 class BaseSourcePackager(treepkg.packager.SourcePackager):
66 88
67 def __init__(self, *args, **kw): 89 def __init__(self, *args, **kw):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)