The Gaudi Framework  v32r2 (46d42edc)
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>"
 

Detailed Description

Small script to prepare the tags and the distribution special directory for a
release of Gaudi.
See https://twiki.cern.ch/twiki/bin/view/Gaudi/GaudiSVNRepository for a
description of the repository structure.

Function Documentation

◆ basename()

def svn_tag_release.basename (   url)

Definition at line 29 of file svn_tag_release.py.

29 def basename(url):
30  return url.rsplit("/", 1)[-1]
31 
32 

◆ checkout_structure()

def svn_tag_release.checkout_structure (   url,
  proj,
  branch 
)

Definition at line 43 of file svn_tag_release.py.

43 def checkout_structure(url, proj, branch):
44  def checkout_level(base):
45  dirs = ["%s/%s" % (base, d) for d in svn_ls(base) if d.endswith("/")]
46  svn("up", "-N", *args).wait()
47  return dirs
48 
49  root = basename(url)
50  svn("co", "-N", url, root).wait()
51  old_dir = os.getcwd()
52  os.chdir(root)
53  svn("up", "-N", proj).wait()
54  br = [proj] + branch.split("/")
55  for base in ["/".join(br[:n + 1]) for n in range(len(br))]:
56  checkout_level(base)
57  checkout_level(proj + "/tags")
58  os.chdir(old_dir)
59  return root
60 
61 
def svn(*args, **kwargs)
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
def checkout_structure(url, proj, branch)

◆ dirname()

def svn_tag_release.dirname (   url)

Definition at line 33 of file svn_tag_release.py.

33 def dirname(url):
34  return url.rsplit("/", 1)[1]
35 
36 

◆ main()

def svn_tag_release.main ( )

Definition at line 62 of file svn_tag_release.py.

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

◆ svn()

def svn_tag_release.svn ( args,
**  kwargs 
)

Definition at line 20 of file svn_tag_release.py.

20 def svn(*args, **kwargs):
21  print("> svn", " ".join(args))
22  return Popen(["svn"] + list(args), **kwargs)
23 
24 
def svn(*args, **kwargs)

◆ svn_exists()

def svn_tag_release.svn_exists (   url)

Definition at line 37 of file svn_tag_release.py.

37 def svn_exists(url):
38  d, b = url.rsplit("/", 1)
39  l = [x.rstrip("/") for x in svn_ls(d)]
40  return b in l
41 
42 

◆ svn_ls()

def svn_tag_release.svn_ls (   url)

Definition at line 25 of file svn_tag_release.py.

25 def svn_ls(url):
26  return svn("ls", url, stdout=PIPE).communicate()[0].splitlines()
27 
28 
def svn(*args, **kwargs)

Variable Documentation

◆ __author__

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

Definition at line 9 of file svn_tag_release.py.