LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Functions
lsst.sconsUtils.vcs.svn Namespace Reference

Functions

def isSvnFile
 
def getInfo
 
def isTrunk
 
def revision
 
def guessVersionName
 
def parseVersionName
 

Function Documentation

def lsst.sconsUtils.vcs.svn.getInfo (   file = ".")
Return a dictionary of all the information returned by "svn info" for the specified file

Definition at line 18 of file svn.py.

18 
19 def getInfo(file="."):
20  """Return a dictionary of all the information returned by "svn info" for the specified file"""
21 
22  if not isSvnFile(file):
23  raise RuntimeError("%s is not under svn control" % file)
24 
25  infoList = os.popen("svn info %s" % file).readlines()
26 
27  info = {}
28  for line in infoList:
29  mat = re.search(r"^([^:]+)\s*:\s*(.*)", line)
30  if mat:
31  info[mat.group(1)] = mat.group(2)
32 
33  return info
def lsst.sconsUtils.vcs.svn.guessVersionName (   HeadURL)
Guess a version name given a HeadURL

Definition at line 85 of file svn.py.

85 
86 def guessVersionName(HeadURL):
87  """Guess a version name given a HeadURL"""
88 
89  if re.search(r"/trunk$", HeadURL):
90  versionName = ""
91  elif re.search(r"/branches/(.+)$", HeadURL):
92  versionName = "branch_%s+" % re.search(r"/branches/(.+)$", HeadURL).group(1)
93  elif re.search(r"/tags/(.+)$", HeadURL):
94  versionName = "%s" % re.search(r"/tags/(.*)$", HeadURL).group(1)
95 
96  return versionName # no need for a "+svnXXXX"
97  elif re.search(r"/tickets/(\d+)$", HeadURL):
98  versionName = "ticket_%s+" % re.search(r"/tickets/(\d+)$", HeadURL).group(1)
99  else:
100  print("Unable to guess versionName name from %s" % HeadURL, file=sys.stderr)
101  versionName = "unknown+"
102 
103  try: # Try to lookup the svn versionName
104  (oldest, youngest, flags) = revision()
105 
106  okVersion = True
107  if "M" in flags:
108  msg = "You are installing, but have unchecked in files"
109  okVersion = False
110  if "S" in flags:
111  msg = "You are installing, but have switched SVN URLs"
112  okVersion = False
113  if oldest != youngest:
114  msg = "You have a range of revisions in your tree (%s:%s); adopting %s" % \
115  (oldest, youngest, youngest)
116  okVersion = False
117 
118  if not okVersion:
119  raise RuntimeError("Problem with determining svn revision: %s" % msg)
120 
121  versionName += "svn" + youngest
122  except IOError:
123  return "unknown"
124 
125  return versionName
def lsst.sconsUtils.vcs.svn.isSvnFile (   file)
Is file under svn control?

Definition at line 12 of file svn.py.

12 
13 def isSvnFile(file):
14  """Is file under svn control?"""
15 
16  return re.search(r"is not a working copy",
17  "".join(os.popen("svn info %s 2>&1" % file).readlines())) == None
def lsst.sconsUtils.vcs.svn.isTrunk (   file = ".")
Is file on the trunk?

Definition at line 34 of file svn.py.

34 
35 def isTrunk(file="."):
36  """Is file on the trunk?"""
37 
38  info = getInfo(file)
39 
40  return re.search(r"/trunk($|/)", info["URL"]) != None
def lsst.sconsUtils.vcs.svn.parseVersionName (   versionName)
A callback that knows about the LSST convention that a tagname such as
ticket_374
means the top of ticket 374, and
ticket_374+svn6021
means revision 6021 on ticket 374.  You may replace "ticket" with "branch" if you wish

The "versionName" may actually be the directory part of a URL, and ".../(branches|tags|tickets)/tagname"
is also supported

Definition at line 126 of file svn.py.

127 def parseVersionName(versionName):
128  """A callback that knows about the LSST convention that a tagname such as
129  ticket_374
130  means the top of ticket 374, and
131  ticket_374+svn6021
132  means revision 6021 on ticket 374. You may replace "ticket" with "branch" if you wish
133 
134  The "versionName" may actually be the directory part of a URL, and ".../(branches|tags|tickets)/tagname"
135  is also supported
136  """
137 
138  mat = re.search(r"/(branche|tag|ticket)s/(\d+(?:\.\d+)*)(?:([-+])((svn)?(\d+)))?$", versionName)
139  if not mat:
140  mat = re.search(r"/(branch|ticket)_(\d+)(?:([-+])svn(\d+))?$", versionName)
141  if mat:
142  type = mat.group(1)
143  if type == "branches":
144  type = "branch"
145  ticket = mat.group(2)
146  pm = mat.group(3) # + or -
147  revision = mat.group(4)
148  if revision:
149  revision = re.sub("^svn", "", revision)
150 
151  return (type, ticket, revision, pm)
152 
153  return (None, None, None, None)
def lsst.sconsUtils.vcs.svn.revision (   file = None,
  lastChanged = False 
)
Return file's Revision as a string; if file is None return
a tuple (oldestRevision, youngestRevision, flags) as reported
by svnversion; e.g. (4123, 4168, ("M", "S")) (oldestRevision
and youngestRevision may be equal)

Definition at line 41 of file svn.py.

41 
42 def revision(file=None, lastChanged=False):
43  """Return file's Revision as a string; if file is None return
44  a tuple (oldestRevision, youngestRevision, flags) as reported
45  by svnversion; e.g. (4123, 4168, ("M", "S")) (oldestRevision
46  and youngestRevision may be equal)
47  """
48 
49  if file:
50  info = getInfo(file)
51 
52  if lastChanged:
53  return info["Last Changed Rev"]
54  else:
55  return info["Revision"]
56 
57  if lastChanged:
58  raise RuntimeError("lastChanged makes no sense if file is None")
59 
60  res = os.popen("svnversion . 2>&1").readline()
61 
62  if res == "exported\n":
63  raise RuntimeError("No svn revision information is available")
64 
65  versionRe = r"^(?P<oldest>\d+)(:(?P<youngest>\d+))?(?P<flags>[MS]*)"
66  mat = re.search(versionRe, res)
67  if mat:
68  matches = mat.groupdict()
69  if not matches["youngest"]:
70  matches["youngest"] = matches["oldest"]
71  # OK, we have only one revision present. Find the newest revision
72  # that actually changed anything in this product and ignore "oldest" (#522)
73  res = os.popen("svnversion --committed . 2>&1").readline()
74  mat = re.search(versionRe, res)
75  if mat:
76  matches = mat.groupdict()
77  return matches["youngest"], matches["youngest"], tuple(matches["flags"])
78 
79  return matches["oldest"], matches["youngest"], tuple(matches["flags"])
80 
81  raise RuntimeError("svnversion returned unexpected result \"%s\"" % res[:-1])
82 
83 #
84 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#