LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
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 15 of file svn.py.

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

Definition at line 82 of file svn.py.

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

Definition at line 9 of file svn.py.

9 
10 def isSvnFile(file):
11  """Is file under svn control?"""
12 
13  return re.search(r"is not a working copy",
14  "".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 31 of file svn.py.

31 
32 def isTrunk(file="."):
33  """Is file on the trunk?"""
34 
35  info = getInfo(file)
36 
37  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 123 of file svn.py.

124 def parseVersionName(versionName):
125  """A callback that knows about the LSST convention that a tagname such as
126  ticket_374
127  means the top of ticket 374, and
128  ticket_374+svn6021
129  means revision 6021 on ticket 374. You may replace "ticket" with "branch" if you wish
130 
131  The "versionName" may actually be the directory part of a URL, and ".../(branches|tags|tickets)/tagname"
132  is also supported
133  """
134 
135  mat = re.search(r"/(branche|tag|ticket)s/(\d+(?:\.\d+)*)(?:([-+])((svn)?(\d+)))?$", versionName)
136  if not mat:
137  mat = re.search(r"/(branch|ticket)_(\d+)(?:([-+])svn(\d+))?$", versionName)
138  if mat:
139  type = mat.group(1)
140  if type == "branches":
141  type = "branch"
142  ticket = mat.group(2)
143  pm = mat.group(3) # + or -
144  revision = mat.group(4)
145  if revision:
146  revision = re.sub("^svn", "", revision)
147 
148  return (type, ticket, revision, pm)
149 
150  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 38 of file svn.py.

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