[CalendarServer-changes] [11496] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 8 17:28:25 PDT 2013


Revision: 11496
          http://trac.calendarserver.org//changeset/11496
Author:   wsanchez at apple.com
Date:     2013-07-08 17:28:25 -0700 (Mon, 08 Jul 2013)
Log Message:
-----------
Fix version logic to deal with changed output from svnversion when not in a WC.
Use new-style string formatting.

Modified Paths:
--------------
    CalendarServer/trunk/setup.py
    CalendarServer/trunk/support/version.py

Modified: CalendarServer/trunk/setup.py
===================================================================
--- CalendarServer/trunk/setup.py	2013-07-08 23:55:49 UTC (rev 11495)
+++ CalendarServer/trunk/setup.py	2013-07-09 00:28:25 UTC (rev 11496)
@@ -63,9 +63,11 @@
 # Write version file
 #
 
-version_string = "%s (%s)" % version()
+version_number, version_info = version()
+
+version_string = "{number} ({info})".format(number=version_number, info=version_info)
 version_file = file(os.path.join("calendarserver", "version.py"), "w")
-version_file.write('version = "%s"\n' % version_string)
+version_file.write('version = "{version}"\n'.format(version=version_string))
 version_file.close()
 
 #
@@ -178,7 +180,7 @@
         for script in dist.scripts:
             scriptPath = os.path.join(install_scripts, os.path.basename(script))
 
-            print("rewriting %s" % (scriptPath,))
+            print("rewriting {0}".format(scriptPath))
 
             script = []
 
@@ -195,17 +197,17 @@
                 line = line.rstrip("\n")
                 if fileType == "sh":
                     if line == "#PYTHONPATH":
-                        script.append('PYTHONPATH="%s:$PYTHONPATH"' % (install_lib,))
+                        script.append('PYTHONPATH="{add}:$PYTHONPATH"'.format(add=install_lib))
                     elif line == "#PATH":
-                        script.append('PATH="%s:$PATH"' % (os.path.join(base, "usr", "bin"),))
+                        script.append('PATH="{add}:$PATH"'.format(add=os.path.join(base, "usr", "bin")))
                     else:
                         script.append(line)
 
                 elif fileType == "python":
                     if line == "#PYTHONPATH":
-                        script.append('PYTHONPATH="%s"' % (install_lib,))
+                        script.append('PYTHONPATH="{path}"'.format(path=install_lib))
                     elif line == "#PATH":
-                        script.append('PATH="%s"' % (os.path.join(base, "usr", "bin"),))
+                        script.append('PATH="{path}"'.format(path=os.path.join(base, "usr", "bin")))
                     else:
                         script.append(line)
 

Modified: CalendarServer/trunk/support/version.py
===================================================================
--- CalendarServer/trunk/support/version.py	2013-07-08 23:55:49 UTC (rev 11495)
+++ CalendarServer/trunk/support/version.py	2013-07-09 00:28:25 UTC (rev 11496)
@@ -18,7 +18,8 @@
 from __future__ import print_function
 
 import os
-from os.path import dirname, basename
+from os.path import dirname
+import subprocess
 
 def version():
     #
@@ -27,19 +28,19 @@
 
     base_version = "5.1"
 
-    branches = (
-        "tags/release/CalendarServer-" + base_version,
-        "branches/release/CalendarServer-" + base_version + "-dev",
-        "trunk",
+    branches = tuple(
+        branch.format(version=base_version)
+        for branch in (
+            "tags/release/CalendarServer-{version}",
+            "branches/release/CalendarServer-{version}-dev",
+            "trunk",
+        )
     )
-
+    
     source_root = dirname(dirname(__file__))
 
     for branch in branches:
-        cmd = "svnversion -n %r %s" % (source_root, branch)
-        svnversion = os.popen(cmd)
-        svn_revision = svnversion.read()
-        svnversion.close()
+        svn_revision = subprocess.check_output(["svnversion", "-n", source_root, branch])
 
         if "S" in svn_revision:
             continue
@@ -49,31 +50,22 @@
         elif branch.endswith("-dev"):
             base_version += "-dev"
 
-        if svn_revision == "exported":
-            if "RC_XBS" in os.environ and os.environ["RC_XBS"] == "YES":
-                project_name = basename(os.environ["SRCROOT"])
-
-                prefix = "CalendarServer-"
-
-                if project_name.startswith(prefix):
-                    rc_version = project_name[len(prefix):]
-                    if "." in rc_version:
-                        comment = "Calendar Server v%s" % (rc_version,)
-                    else:
-                        comment = "Calendar Server [dev] r%s" % (rc_version,)
-                    break
-
-            comment = "unknown"
+        if svn_revision in ("exported", "Unversioned directory"):
+            if os.environ.get("RC_XBS", None) == "YES":
+                xbs_version = os.environ.get("RC_ProjectSourceVersion", "?")
+                comment = "Apple Calendar Server {version}".format(version=xbs_version)
+            else:
+                comment = "unknown"
         else:
-            comment = "r%s" % (svn_revision,)
+            comment = "r{revision}".format(revision=svn_revision)
 
         break
     else:
         base_version += "-unknown"
-        comment = "r%s" % (svn_revision,)
+        comment = "r{revision}".format(revision=svn_revision)
 
     return (base_version, comment)
 
 if __name__ == "__main__":
     base_version, comment = version()
-    print("%s (%s)" % (base_version, comment))
+    print("{version} ({comment})".format(version=base_version, comment=comment))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130708/25d7def2/attachment-0001.html>


More information about the calendarserver-changes mailing list