Gaudi Framework, version v22r4

Home   Generated: Fri Sep 2 2011
Functions | Variables

tag_release Namespace Reference

Functions

def extract_version
def gather_new_versions
def svn
def svn_ls
def basename
def dirname
def svn_exists
def checkout_structure
def main

Variables

string __author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"
tuple _req_version_pattern = re.compile(r"^\s*version\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*$")
tuple _use_pattern = re.compile(r"^\s*use\s*(\w+)\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*(\w+)?\s*$")

Function Documentation

def tag_release::basename (   url )

Definition at line 42 of file tag_release.py.

00043                  :
00044     return url.rsplit("/", 1)[-1]

def tag_release::checkout_structure (   url,
  proj,
  branch 
)

Definition at line 53 of file tag_release.py.

00054                                          :
00055     def checkout_level(base):
00056         dirs = ["%s/%s" % (base, d) for d in svn_ls(base) if d.endswith("/")]
00057         apply(svn, ["up", "-N"] + dirs).wait()
00058         return dirs
00059 
00060     root = basename(url)
00061     svn("co","-N", url, root).wait()
00062     old_dir = os.getcwd()
00063     os.chdir(root)
00064     svn("up", "-N", proj).wait()
00065     br = [proj] + branch.split("/")
00066     for base in [ "/".join(br[:n+1]) for n in range(len(br))]:
00067         checkout_level(base)
00068     checkout_level(proj + "/tags")
00069     os.chdir(old_dir)
00070     return root

def tag_release::dirname (   url )

Definition at line 45 of file tag_release.py.

00046                 :
00047     return url.rsplit("/", 1)[1]

def tag_release::extract_version (   f )
Find the version number in a requirements file.

Definition at line 14 of file tag_release.py.

00015                       :
00016     """
00017     Find the version number in a requirements file.
00018     """
00019     global _req_version_pattern
00020     for l in open(f):
00021         m = _req_version_pattern.match(l)
00022         if m:
00023             return m.group(1)
00024     return None

def tag_release::gather_new_versions (   f )

Definition at line 26 of file tag_release.py.

00027                           :
00028     global _use_pattern
00029     versions = {}
00030     for l in open(f):
00031         m = _use_pattern.match(l)
00032         if m:
00033             versions[m.group(1)] = m.group(2)
00034     return versions

def tag_release::main (  )

Definition at line 71 of file tag_release.py.

00072           :
00073     from optparse import OptionParser
00074     parser = OptionParser()
00075     parser.add_option("--pre", action = "store_true",
00076                       help = "Create -pre tags instead of final tags.")
00077     parser.add_option("-b", "--branch",
00078                       help = "Use the given (global) branch as source for the tags instead of the trunk")
00079     opts, args = parser.parse_args()
00080     if opts.branch:
00081         opts.branch = "/".join(["branches", "GAUDI", opts.branch])
00082     else:
00083         opts.branch = "trunk"
00084 
00085     url = "svn+ssh://svn.cern.ch/reps/gaudi"
00086     proj = "Gaudi"
00087     container = "GaudiRelease"
00088     packages = gather_new_versions("requirements")
00089     packages[container] = extract_version("requirements")
00090     tempdir = tempfile.mkdtemp()
00091     try:
00092         os.chdir(tempdir)
00093         # prepare repository structure (and move to its top level)
00094         os.chdir(checkout_structure(url, proj, opts.branch))
00095 
00096         # note that the project does not have "-pre"
00097         pvers = "%s_%s" % (proj.upper(), packages[container])
00098 
00099         # prepare project tag
00100         ptagdir = "%s/tags/%s/%s" % (proj, proj.upper(), pvers)
00101         if not svn_exists(ptagdir):
00102             svn("mkdir", ptagdir).wait()
00103             svn("cp", "/".join([proj, opts.branch, "cmt"]), ptagdir + "/cmt").wait()
00104             svn("cp", "/".join([proj, opts.branch, "Makefile.cmt"]), ptagdir + "/Makefile.cmt").wait()
00105 
00106         # prepare package tags
00107         tag_re = re.compile(r"^v(\d+)r(\d+)(?:p(\d+))?$")
00108         for p in packages:
00109             tag = packages[p]
00110             pktagdir = "%s/tags/%s/%s" % (proj, p, tag)
00111             # I have to make the tag if it doesn't exist and (if we use -pre tags)
00112             # neither the -pre tag exists.
00113             no_tag = not svn_exists(pktagdir)
00114             make_tag = no_tag or (opts.pre and no_tag and not svn_exists(pktagdir + "-pre"))
00115             if make_tag:
00116                 if opts.pre:
00117                     pktagdir += "-pre"
00118                 svn("cp", "/".join([proj, opts.branch, p]), pktagdir).wait()
00119                 # Atlas type of tag
00120                 tagElements = tag_re.match(tag)
00121                 if tagElements:
00122                     tagElements = "-".join([ "%02d" % int(el or "0") for el in tagElements.groups() ])
00123                     pktagdir = "%s/tags/%s/%s-%s" % (proj, p, p, tagElements)
00124                     svn("cp", "/".join([proj, opts.branch, p]), pktagdir).wait()
00125             else:
00126                 if not no_tag:
00127                     svn("up", "-N", pktagdir).wait() # needed for the copy in the global tag
00128 
00129         if not opts.pre:
00130             # prepare the full global tag too
00131             for p in packages:
00132                 tag = packages[p]
00133                 pktagdir = "%s/tags/%s/%s" % (proj, p, tag)
00134                 svn("cp", pktagdir, "%s/%s" % (ptagdir, p)).wait()
00135 
00136         svn("ci").wait()
00137 
00138     finally:
00139         shutil.rmtree(tempdir, ignore_errors = True)
00140 
00141     return 0

def tag_release::svn (   args,
  kwargs 
)

Definition at line 35 of file tag_release.py.

00036                         :
00037     print "> svn", " ".join(args)
00038     return apply(Popen, (["svn"] + list(args),), kwargs)

def tag_release::svn_exists (   url )

Definition at line 48 of file tag_release.py.

00049                    :
00050     d,b = url.rsplit("/", 1)
00051     l = [x.rstrip("/") for x in svn_ls(d)]
00052     return b in l

def tag_release::svn_ls (   url )

Definition at line 39 of file tag_release.py.

00040                :
00041     return svn("ls", url, stdout = PIPE).communicate()[0].splitlines()


Variable Documentation

string tag_release::__author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"

Definition at line 8 of file tag_release.py.

tuple tag_release::_req_version_pattern = re.compile(r"^\s*version\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*$")

Definition at line 13 of file tag_release.py.

tuple tag_release::_use_pattern = re.compile(r"^\s*use\s*(\w+)\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*(\w+)?\s*$")

Definition at line 25 of file tag_release.py.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Fri Sep 2 2011 16:26:11 for Gaudi Framework, version v22r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004