| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

# 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 |
| ) |  |  |

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     for base in [proj, proj + "/trunk"]:
    00066         checkout_level(base)
    00067     checkout_level(proj + "/tags")
    00068     os.chdir(old_dir)
    00069     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 70 of file tag_release.py.

    00071           :
    00072     use_pre = len(sys.argv) > 1 and 'pre' in  sys.argv
    00073     url = "svn+ssh://svn.cern.ch/reps/gaudi"
    00074     proj = "Gaudi"
    00075     container = "GaudiRelease"
    00076     packages = gather_new_versions("requirements")
    00077     packages[container] = extract_version("requirements")
    00078     tempdir = tempfile.mkdtemp()
    00079     try:
    00080         os.chdir(tempdir)
    00081         # prepare repository structure (and move to its top level)
    00082         os.chdir(checkout_structure(url, proj))
    00083
    00084         # note that the project does not have "-pre"
    00085         pvers = "%s_%s" % (proj.upper(), packages[container])
    00086
    00087         # prepare project tag
    00088         ptagdir = "%s/tags/%s/%s" % (proj, proj.upper(), pvers)
    00089         if not svn_exists(ptagdir):
    00090             svn("mkdir", ptagdir).wait()
    00091             svn("cp", "%s/trunk/cmt" % proj, ptagdir + "/cmt").wait()
    00092
    00093         # prepare package tags
    00094         tag_re = re.compile(r"^v(\d+)r(\d+)(?:p(\d+))?$")
    00095         for p in packages:
    00096             tag = packages[p]
    00097             pktagdir = "%s/tags/%s/%s" % (proj, p, tag)
    00098             # I have to make the tag if it doesn't exist and (if we use -pre tags)
    00099             # neither the -pre tag exists.
    00100             no_tag = not svn_exists(pktagdir)
    00101             make_tag = no_tag or (use_pre and no_tag and not svn_exists(pktagdir + "-pre"))
    00102             if make_tag:
    00103                 if use_pre:
    00104                     pktagdir += "-pre"
    00105                 svn("cp", "%s/trunk/%s" % (proj, p), pktagdir).wait()
    00106                 # Atlas type of tag
    00107                 tagElements = tag_re.match(tag)
    00108                 if tagElements:
    00109                     tagElements = "-".join([ "%02d" % int(el or "0") for el in tagElements.groups() ])
    00110                     pktagdir = "%s/tags/%s/%s-%s" % (proj, p, p, tagElements)
    00111                     svn("cp", "%s/trunk/%s" % (proj, p), pktagdir).wait()
    00112             else:
    00113                 if not no_tag:
    00114                     svn("up", "-N", pktagdir).wait() # needed for the copy in the global tag
    00115
    00116         if not use_pre:
    00117             # prepare the full global tag too
    00118             for p in packages:
    00119                 tag = packages[p]
    00120                 pktagdir = "%s/tags/%s/%s" % (proj, p, tag)
    00121                 svn("cp", pktagdir, "%s/%s" % (ptagdir, p)).wait()
    00122
    00123         svn("ci").wait()
    00124
    00125     finally:
    00126         shutil.rmtree(tempdir, ignore_errors = True)
    00127
    00128     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