[CalendarServer-changes] [3923] CalendarServer/trunk/support/version.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 26 16:30:32 PDT 2009


Revision: 3923
          http://trac.macosforge.org/projects/calendarserver/changeset/3923
Author:   wsanchez at apple.com
Date:     2009-03-26 16:30:32 -0700 (Thu, 26 Mar 2009)
Log Message:
-----------
move version logic into a module

Added Paths:
-----------
    CalendarServer/trunk/support/version.py

Added: CalendarServer/trunk/support/version.py
===================================================================
--- CalendarServer/trunk/support/version.py	                        (rev 0)
+++ CalendarServer/trunk/support/version.py	2009-03-26 23:30:32 UTC (rev 3923)
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+##
+# Copyright (c) 2006-2007 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+import os
+from os.path import dirname, basename
+
+def version():
+    #
+    # Compute the version number.
+    #
+
+    base_version = "2.2"
+
+    branches = (
+        "tags/release/CalendarServer-" + base_version,
+        "branches/release/CalendarServer-" + base_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()
+
+        if "S" in svn_revision:
+            continue
+
+        if branch == "trunk":
+            base_version = "trunk"
+        elif branch.endswith("-dev"):
+            base_version += "-dev"
+
+        if svn_revision == "exported":
+            if "RC_JASPER" in os.environ:
+                # Weird Apple thing: Get the B&I version number from the path
+                if source_root.startswith(os.path.sep):
+                    project_name = basename(source_root)
+                else:
+                    wd = source_root
+                    if wd:
+                        os.chdir(wd)
+                    project_name = basename(os.getcwd())
+
+                prefix = "CalendarServer-"
+
+                if project_name.startswith(prefix):
+                    comment = "iCal Server v%s" % (project_name[len(prefix):],)
+                    break
+
+            comment = "unknown"
+        else:
+            comment = "r%s" % (svn_revision,)
+
+        break
+    else:
+        base_version += "-unknown"
+        comment = "r%s" % (svn_revision,)
+
+    return (base_version, comment)
+
+if __name__ == "__main__":
+    base_version, comment = version()
+    print "%s (%s)" % (base_version, comment)


Property changes on: CalendarServer/trunk/support/version.py
___________________________________________________________________
Added: svn:executable
   + *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090326/83c44ab1/attachment.html>


More information about the calendarserver-changes mailing list