[Zope3-checkins] SVN: Zope3/branches/3.3/ Fixed issue 730:
Subversion 1.4 breaks mkzopeinstance.py
Dmitry Vasiliev
dima at hlabs.spb.ru
Thu Nov 9 06:39:50 EST 2006
Log message for revision 71099:
Fixed issue 730: Subversion 1.4 breaks mkzopeinstance.py
Merged revision 70397 from the trunk.
Changed:
U Zope3/branches/3.3/doc/CHANGES.txt
U Zope3/branches/3.3/src/zope/app/applicationcontrol/tests/test_zopeversion.py
U Zope3/branches/3.3/src/zope/app/applicationcontrol/zopeversion.py
-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt 2006-11-08 22:20:19 UTC (rev 71098)
+++ Zope3/branches/3.3/doc/CHANGES.txt 2006-11-09 11:39:48 UTC (rev 71099)
@@ -10,6 +10,8 @@
Bugfixes
+ - Fixed issue 730: Subversion 1.4 breaks mkzopeinstance.py
+
- Fixed zope.annotation.factory to correctly setup containment for
objects that do not implement IContained.
Modified: Zope3/branches/3.3/src/zope/app/applicationcontrol/tests/test_zopeversion.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/applicationcontrol/tests/test_zopeversion.py 2006-11-08 22:20:19 UTC (rev 71098)
+++ Zope3/branches/3.3/src/zope/app/applicationcontrol/tests/test_zopeversion.py 2006-11-09 11:39:48 UTC (rev 71099)
@@ -19,17 +19,25 @@
import shutil
import tempfile
import unittest
-from xml.sax.saxutils import quoteattr
from zope.interface.verify import verifyObject
from zope.app.applicationcontrol.interfaces import IZopeVersion
from zope.app.applicationcontrol.zopeversion import ZopeVersion
+class MockZopeVersion(ZopeVersion):
+
+ def setSVNInfoOutput(self, lines):
+ self.__lines = lines
+
+ def _getSVNInfoOutput(self):
+ return self.__lines
+
class Test(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix="test-zopeversion-")
+ self.zopeVersion = MockZopeVersion(self.tmpdir)
def tearDown(self):
shutil.rmtree(self.tmpdir)
@@ -37,94 +45,72 @@
def prepare(self, version, fields):
if version:
f = open(os.path.join(self.tmpdir, "version.txt"), "w")
- f.write(version)
- if not version.endswith("\n"):
- f.write("\n")
- f.close()
+ try:
+ f.write(version)
+ if not version.endswith("\n"):
+ f.write("\n")
+ finally:
+ f.close()
if fields:
os.mkdir(os.path.join(self.tmpdir, ".svn"))
- f = open(os.path.join(self.tmpdir, ".svn", "entries"), "w")
- fields = ["%s=%s" % (key, quoteattr(val))
- for key, val in fields.items()]
- text = ('<?xml version="1.0" encoding="utf-8"?>\n'
- '<wc-entries\n'
- ' xmlns="svn:">\n'
- '<entry\n'
- ' name=""\n'
- ' kind="dir"\n'
- ' %s/>\n'
- '</wc-entries>\n' % "\n ".join(fields))
- f.write(text)
- f.close()
+ self.zopeVersion.setSVNInfoOutput(fields)
- def _Test__new(self):
- return ZopeVersion(self.tmpdir)
-
def test_IVerify(self):
- verifyObject(IZopeVersion, self._Test__new())
+ verifyObject(IZopeVersion, self.zopeVersion)
- # In .svn/entries we check only two attributes:
- # 'url' - repository path
- # 'revision' - checked out revision number
-
def test_ZopeVersion(self):
self.prepare(None, None)
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(), "Development/Unknown")
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Development/Unknown")
def test_ZopeVersion_svntrunk(self):
- self.prepare(None, {
- "url": "svn+ssh://svn.zope.org/repos/main/Zope3/trunk/src/zope",
- "revision": "10000"
- })
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(),
- "Development/Revision: 10000")
+ self.prepare(None, [
+ "URL: svn+ssh://svn.zope.org/repos/main/Zope3/trunk/src/zope",
+ "Revision: 10000"
+ ])
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Development/Revision: 10000")
def test_ZopeVersion_svnbranch(self):
- self.prepare(None, {
- "url": "svn+ssh://svn.zope.org/repos/main/Zope3/branches/Zope3-1.0/src/zope",
- "revision": "10000"
- })
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(),
- "Development/Revision: 10000/Branch: Zope3-1.0")
+ self.prepare(None, [
+ "URL: svn+ssh://svn.zope.org/repos/main/Zope3/branches/Zope3-1.0/src/zope",
+ "Revision: 10000"
+ ])
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Development/Revision: 10000/Branch: Zope3-1.0")
def test_ZopeVersion_svntag(self):
- self.prepare(None, {
- "url": "svn+ssh://svn.zope.org/repos/main/Zope3/tags/Zope3-1.0/src/zope",
- "revision": "10000"
- })
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(),
- "Development/Revision: 10000/Tag: Zope3-1.0")
+ self.prepare(None, [
+ "URL: svn+ssh://svn.zope.org/repos/main/Zope3/tags/Zope3-1.0/src/zope",
+ "Revision: 10000"
+ ])
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Development/Revision: 10000/Tag: Zope3-1.0")
def test_ZopeVersion_svn_unknown(self):
- self.prepare(None, {"uuid": ""})
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(), "Development/Unknown")
+ self.prepare(None, ["Nope: "])
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Development/Unknown")
def test_ZopeVersion_release(self):
self.prepare("Zope 3 1.0.0", None)
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(),
- "Zope 3 1.0.0")
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Zope 3 1.0.0")
def test_ZopeVersion_release_empty(self):
self.prepare(" ", None)
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(), "Development/Unknown")
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Development/Unknown")
def test_ZopeVersion_release_svntrunk(self):
# demonstrate that the version.txt data is discarded if
# there's revision-control metadata:
- self.prepare("Zope 3 1.0.0", {
- "url": "svn+ssh://svn.zope.org/repos/main/Zope3/trunk/src/zope",
- "revision": "10000"
- })
- zope_version = self._Test__new()
- self.assertEqual(zope_version.getZopeVersion(),
- "Development/Revision: 10000")
+ self.prepare("Zope 3 1.0.0", [
+ "URL: svn+ssh://svn.zope.org/repos/main/Zope3/trunk/src/zope",
+ "Revision: 10000"
+ ])
+ self.assertEqual(self.zopeVersion.getZopeVersion(),
+ "Development/Revision: 10000")
def test_suite():
Modified: Zope3/branches/3.3/src/zope/app/applicationcontrol/zopeversion.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/applicationcontrol/zopeversion.py 2006-11-08 22:20:19 UTC (rev 71098)
+++ Zope3/branches/3.3/src/zope/app/applicationcontrol/zopeversion.py 2006-11-09 11:39:48 UTC (rev 71099)
@@ -19,7 +19,7 @@
import os
import re
-from xml.dom.minidom import parse
+import subprocess
import zope.app
from zope.app.applicationcontrol.interfaces import IZopeVersion
@@ -60,28 +60,43 @@
f.close()
return self.result
+ def _getSVNInfoOutput(self):
+ try:
+ proc = subprocess.Popen('svn info "%s"' % self.path,
+ shell=True, stdout=subprocess.PIPE)
+ except OSError:
+ pass
+ else:
+ if proc.wait() == 0:
+ return proc.stdout
+ return None
+
def __setSVNVersion(self, svndir):
- entriesfile = os.path.join(svndir, "entries")
+ output = self._getSVNInfoOutput()
+ if not output:
+ return
- # get the version information
- if os.path.isfile(entriesfile):
- doc = parse(entriesfile)
- here = doc.getElementsByTagNameNS("svn:", "entry").item(0)
- if here:
- url = here.getAttribute("url")
- revision = here.getAttribute("revision")
+ info = {}
+ for line in output:
+ parts = line.rstrip().split(": ", 1)
+ if len(parts) == 2:
+ key, value = parts
+ info[key] = value
- if revision and url:
- match = self.__tags.search(url)
- if match is None:
- tag = ""
- else:
- type, value = match.groups()
- if type == "tags":
- tag = "/Tag: %s" % value
- elif type == "branches":
- tag = "/Branch: %s" % value
- self.result = ("Development/Revision: %s%s"
- % (revision, tag))
+ revision = info.get("Revision", "")
+ url = info.get("URL", "")
+ if revision and url:
+ match = self.__tags.search(url)
+ if match is None:
+ tag = ""
+ else:
+ type, value = match.groups()
+ if type == "tags":
+ tag = "/Tag: %s" % value
+ elif type == "branches":
+ tag = "/Branch: %s" % value
+ self.result = ("Development/Revision: %s%s"
+ % (revision, tag))
+
ZopeVersionUtility = ZopeVersion()
More information about the Zope3-Checkins
mailing list