All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
svn_tag_release Namespace Reference

Functions

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>"
 

Function Documentation

def svn_tag_release.basename (   url)

Definition at line 21 of file svn_tag_release.py.

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

Definition at line 32 of file svn_tag_release.py.

32 
33 def checkout_structure(url, proj, branch):
34  def checkout_level(base):
35  dirs = ["%s/%s" % (base, d) for d in svn_ls(base) if d.endswith("/")]
36  apply(svn, ["up", "-N"] + dirs).wait()
37  return dirs
38 
39  root = basename(url)
40  svn("co","-N", url, root).wait()
41  old_dir = os.getcwd()
42  os.chdir(root)
43  svn("up", "-N", proj).wait()
44  br = [proj] + branch.split("/")
45  for base in [ "/".join(br[:n+1]) for n in range(len(br))]:
46  checkout_level(base)
47  checkout_level(proj + "/tags")
48  os.chdir(old_dir)
49  return root
def svn_tag_release.dirname (   url)

Definition at line 24 of file svn_tag_release.py.

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

Definition at line 50 of file svn_tag_release.py.

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

Definition at line 14 of file svn_tag_release.py.

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

Definition at line 27 of file svn_tag_release.py.

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

Definition at line 18 of file svn_tag_release.py.

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

Variable Documentation

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

Definition at line 8 of file svn_tag_release.py.