The Gaudi Framework  v33r0 (d5ea422b)
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

◆ basename()

def svn_tag_release.basename (   url)

Definition at line 39 of file svn_tag_release.py.

39 def basename(url):
40  return url.rsplit("/", 1)[-1]
41 
42 

◆ checkout_structure()

def svn_tag_release.checkout_structure (   url,
  proj,
  branch 
)

Definition at line 53 of file svn_tag_release.py.

53 def checkout_structure(url, proj, branch):
54  def checkout_level(base):
55  dirs = ["%s/%s" % (base, d) for d in svn_ls(base) if d.endswith("/")]
56  svn("up", "-N", *args).wait()
57  return dirs
58 
59  root = basename(url)
60  svn("co", "-N", url, root).wait()
61  old_dir = os.getcwd()
62  os.chdir(root)
63  svn("up", "-N", proj).wait()
64  br = [proj] + branch.split("/")
65  for base in ["/".join(br[:n + 1]) for n in range(len(br))]:
66  checkout_level(base)
67  checkout_level(proj + "/tags")
68  os.chdir(old_dir)
69  return root
70 
71 
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 43 of file svn_tag_release.py.

43 def dirname(url):
44  return url.rsplit("/", 1)[1]
45 
46 

◆ main()

def svn_tag_release.main ( )

Definition at line 72 of file svn_tag_release.py.

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

◆ svn()

def svn_tag_release.svn ( args,
**  kwargs 
)

Definition at line 30 of file svn_tag_release.py.

30 def svn(*args, **kwargs):
31  print("> svn", " ".join(args))
32  return Popen(["svn"] + list(args), **kwargs)
33 
34 
def svn(*args, **kwargs)

◆ svn_exists()

def svn_tag_release.svn_exists (   url)

Definition at line 47 of file svn_tag_release.py.

47 def svn_exists(url):
48  d, b = url.rsplit("/", 1)
49  l = [x.rstrip("/") for x in svn_ls(d)]
50  return b in l
51 
52 

◆ svn_ls()

def svn_tag_release.svn_ls (   url)

Definition at line 35 of file svn_tag_release.py.

35 def svn_ls(url):
36  return svn("ls", url, stdout=PIPE).communicate()[0].splitlines()
37 
38 
def svn(*args, **kwargs)

Variable Documentation

◆ __author__

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

Definition at line 19 of file svn_tag_release.py.