svn_tag_release Namespace Reference

Functions

def svn (args, kwargs)
 
def svn_ls (url)
 
def basename (url)
 
def dirname (url)
 
def svn_exists (url)
 
def checkout_structure (url, proj, branch)
 
def main ()
 

Variables

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

Function Documentation

def svn_tag_release.basename (   url)

Definition at line 21 of file svn_tag_release.py.

21 def basename(url):
22  return url.rsplit("/", 1)[-1]
23 
def svn_tag_release.checkout_structure (   url,
  proj,
  branch 
)

Definition at line 32 of file svn_tag_release.py.

32 def checkout_structure(url, proj, branch):
33  def checkout_level(base):
34  dirs = ["%s/%s" % (base, d) for d in svn_ls(base) if d.endswith("/")]
35  apply(svn, ["up", "-N"] + dirs).wait()
36  return dirs
37 
38  root = basename(url)
39  svn("co","-N", url, root).wait()
40  old_dir = os.getcwd()
41  os.chdir(root)
42  svn("up", "-N", proj).wait()
43  br = [proj] + branch.split("/")
44  for base in [ "/".join(br[:n+1]) for n in range(len(br))]:
45  checkout_level(base)
46  checkout_level(proj + "/tags")
47  os.chdir(old_dir)
48  return root
49 
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:130
def svn(args, kwargs)
def checkout_structure(url, proj, branch)
def svn_tag_release.dirname (   url)

Definition at line 24 of file svn_tag_release.py.

24 def dirname(url):
25  return url.rsplit("/", 1)[1]
26 
def svn_tag_release.main ( )

Definition at line 50 of file svn_tag_release.py.

50 def main():
51  from optparse import OptionParser
52  parser = OptionParser()
53  parser.add_option("--pre", action = "store_true",
54  help = "Create -pre tags instead of final tags.")
55  parser.add_option("-b", "--branch",
56  help = "Use the given (global) branch as source for the tags instead of the trunk")
57  opts, args = parser.parse_args()
58  if opts.branch:
59  opts.branch = "/".join(["branches", "GAUDI", opts.branch])
60  else:
61  opts.branch = "trunk"
62 
63  url = "svn+ssh://svn.cern.ch/reps/gaudi"
64  proj = "Gaudi"
65  container = "GaudiRelease"
66  project_info = ConfigParser()
67  project_info.optionxform = str # make options case sensitive
68  project_info.read('project.info')
69  packages = dict(project_info.items('Packages'))
70  tempdir = tempfile.mkdtemp()
71  try:
72  os.chdir(tempdir)
73  # prepare repository structure (and move to its top level)
74  os.chdir(checkout_structure(url, proj, opts.branch))
75 
76  # note that the project does not have "-pre"
77  pvers = "%s_%s" % (proj.upper(), packages[container])
78 
79  # prepare project tag
80  ptagdir = "%s/tags/%s/%s" % (proj, proj.upper(), pvers)
81  if not svn_exists(ptagdir):
82  svn('cp', '/'.join([proj, opts.branch]), ptagdir).wait()
83 
84  # prepare package tags
85  tag_re = re.compile(r"^v(\d+)r(\d+)(?:p(\d+))?$")
86  for p in packages:
87  tag = packages[p]
88  pktagdir = "%s/tags/%s/%s" % (proj, p, tag)
89  # I have to make the tag if it doesn't exist and (if we use -pre tags)
90  # neither the -pre tag exists.
91  no_tag = not svn_exists(pktagdir)
92  make_tag = no_tag or (opts.pre and no_tag and not svn_exists(pktagdir + "-pre"))
93  if make_tag:
94  if opts.pre:
95  pktagdir += "-pre"
96  svn("cp", "/".join([proj, opts.branch, p]), pktagdir).wait()
97  # Atlas type of tag
98  tagElements = tag_re.match(tag)
99  if tagElements:
100  tagElements = "-".join([ "%02d" % int(el or "0") for el in tagElements.groups() ])
101  pktagdir = "%s/tags/%s/%s-%s" % (proj, p, p, tagElements)
102  svn("cp", "/".join([proj, opts.branch, p]), pktagdir).wait()
103  else:
104  if not no_tag:
105  svn("up", "--depth=empty", pktagdir).wait() # needed for the copy in the global tag
106 
107  svn("ci").wait()
108 
109  finally:
110  shutil.rmtree(tempdir, ignore_errors = True)
111 
112  return 0
113 
def svn(args, kwargs)
def checkout_structure(url, proj, branch)
def svn_tag_release.svn (   args,
  kwargs 
)

Definition at line 14 of file svn_tag_release.py.

14 def svn(*args, **kwargs):
15  print "> svn", " ".join(args)
16  return apply(Popen, (["svn"] + list(args),), kwargs)
17 
def svn(args, kwargs)
def svn_tag_release.svn_exists (   url)

Definition at line 27 of file svn_tag_release.py.

27 def svn_exists(url):
28  d,b = url.rsplit("/", 1)
29  l = [x.rstrip("/") for x in svn_ls(d)]
30  return b in l
31 
def svn_tag_release.svn_ls (   url)

Definition at line 18 of file svn_tag_release.py.

18 def svn_ls(url):
19  return svn("ls", url, stdout = PIPE).communicate()[0].splitlines()
20 
def svn(args, kwargs)

Variable Documentation

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

Definition at line 8 of file svn_tag_release.py.