Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-03-14 12:14:16 (GMT)
committer Jonas Smedegaard <dr@jones.dk>2008-03-14 12:14:56 (GMT)
commit7f335f697213785ddc68fb94864f612159abcaa7 (patch)
tree583332dc9dbcbab2165049596f3b0bea7538e856
parent07071b630308d76ff1d812aa9c84501d35023535 (diff)
* Use quilt to handle patches.
* Add already applied patch 1001 to use unversioned Python hashbang in getbuildpath.py script. * Add already applied patch 1002 to nest try-except in try-except-finally constructs, for Python < 2.5 compatibility. * Add already applied patch 1003 to avoid fancy locking using "with" statement, for Python < 2.5 compatibility. * Semi-auto-update debian/control to update build-dependencies: DEB_AUTO_UPDATE_DEBIAN_CONTROL=yes fakeroot debian/rules clean
-rw-r--r--debian/changelog13
-rw-r--r--debian/patches/1001_unversioned_hashbang_in_scripts.patch8
-rw-r--r--debian/patches/1002_avoid_try-except-finally.patch0
-rw-r--r--debian/patches/1003_avoid_with_statement.patch104
-rw-r--r--debian/patches/README3
-rw-r--r--debian/patches/series3
-rw-r--r--src/olpc/datastore/xapianindex.py27
7 files changed, 136 insertions, 22 deletions
diff --git a/debian/changelog b/debian/changelog
index f499994..c91287e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,11 +1,20 @@
-sugar-datastore (0.8.0~git.13d354b-5) UNRELEASED; urgency=low
+sugar-datastore (0.8.0~git.13d354b-5) unstable; urgency=low
* Pass over maintenance of the package to the OLPC team: Change
Maintainer, and add myself to Uploaders.
* Fix README.packaging to use "pull; fetch --tags" (not "pull -t").
* Depend on python-sugar (not sugar-base).
+ * Use quilt to handle patches.
+ * Add already applied patch 1001 to use unversioned Python hashbang in
+ getbuildpath.py script.
+ * Add already applied patch 1002 to nest try-except in
+ try-except-finally constructs, for Python < 2.5 compatibility.
+ * Add already applied patch 1003 to avoid fancy locking using "with"
+ statement, for Python < 2.5 compatibility.
+ * Semi-auto-update debian/control to update build-dependencies:
+ DEB_AUTO_UPDATE_DEBIAN_CONTROL=yes fakeroot debian/rules clean
- -- Jonas Smedegaard <dr@jones.dk> Tue, 11 Mar 2008 09:42:46 +0100
+ -- Jonas Smedegaard <dr@jones.dk> Fri, 14 Mar 2008 13:14:12 +0100
sugar-datastore (0.8.0~git.13d354b-4) unstable; urgency=low
diff --git a/debian/patches/1001_unversioned_hashbang_in_scripts.patch b/debian/patches/1001_unversioned_hashbang_in_scripts.patch
new file mode 100644
index 0000000..648e608
--- /dev/null
+++ b/debian/patches/1001_unversioned_hashbang_in_scripts.patch
@@ -0,0 +1,8 @@
+--- sugar-datastore-0.8.0~git.13d354b.orig/docs/getbuildpath.py
++++ sugar-datastore-0.8.0~git.13d354b/docs/getbuildpath.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python2.4
++#!/usr/bin/python
+ import os, sys
+
+ # IF YOU ARE NOT GETTING THE RESULTS YOU EXPECT WHILE TESTING
diff --git a/debian/patches/1002_avoid_try-except-finally.patch b/debian/patches/1002_avoid_try-except-finally.patch
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debian/patches/1002_avoid_try-except-finally.patch
diff --git a/debian/patches/1003_avoid_with_statement.patch b/debian/patches/1003_avoid_with_statement.patch
new file mode 100644
index 0000000..97bfeac
--- /dev/null
+++ b/debian/patches/1003_avoid_with_statement.patch
@@ -0,0 +1,104 @@
+diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py
+index 888bd26..c2506cb 100644
+--- a/src/olpc/datastore/xapianindex.py
++++ b/src/olpc/datastore/xapianindex.py
+@@ -4,8 +4,6 @@ xapianindex
+ maintain indexes on content
+
+ """
+-from __future__ import with_statement
+-
+ __author__ = 'Benjamin Saller <bcsaller@objectrealms.net>'
+ __docformat__ = 'restructuredtext'
+ __copyright__ = 'Copyright ObjectRealms, LLC, 2007'
+@@ -85,7 +83,6 @@ class IndexManager(object):
+ self.backingstore = None
+
+ self.fields = set()
+- self._write_lock = threading.Lock()
+
+ self.deltact = 0 # delta count
+ self._flush_timeout = None
+@@ -173,7 +170,8 @@ class IndexManager(object):
+
+ self.deltact += 1
+ if force or self.deltact > FLUSH_THRESHOLD:
+- with self._write_lock:
++ self._write_lock.acquire()
++ try:
+
+ # TODO: Would be better to check if the device is present and
+ # don't try to flush if it's not.
+@@ -185,6 +183,8 @@ class IndexManager(object):
+
+ #self.read_index.reopen()
+ self.deltact = 0
++ finally:
++ self._write_lock.release()
+ else:
+ self._flush_timeout = gobject.timeout_add(FLUSH_TIMEOUT * 1000,
+ self._flush_timeout_cb)
+@@ -196,13 +196,16 @@ class IndexManager(object):
+ # conversion/fulltext indexing can
+ # happen in the thread
+ if operation in (CREATE, UPDATE):
+- with self._write_lock:
++ self._write_lock.acquire()
++ try:
+ if operation is CREATE:
+ self.write_index.add(doc)
+ logger.info("created %s:%s" % (uid, vid))
+ elif operation is UPDATE:
+ self.write_index.replace(doc)
+ logger.info("updated %s:%s" % (uid, vid))
++ finally:
++ self._write_lock.release()
+ self.flush()
+
+ # Disable content indexing for Trial-3.
+@@ -217,9 +220,12 @@ class IndexManager(object):
+ return
+ elif operation is DELETE:
+ # sync deletes
+- with self._write_lock:
++ self._write_lock.acquire()
++ try:
+ self.write_index.delete(uid)
+ logger.info("deleted content %s:%s" % (uid,vid))
++ finally:
++ self._write_lock.release()
+ self.flush()
+ return
+
+@@ -246,7 +252,8 @@ class IndexManager(object):
+ continue
+
+ try:
+- with self._write_lock:
++ self._write_lock.acquire()
++ try:
+ if operation is UPDATE:
+ # Here we handle the conversion of binary
+ # documents to plain text for indexing. This is
+@@ -276,6 +283,8 @@ class IndexManager(object):
+
+ # tell the queue its complete
+ self.queue.task_done()
++ finally:
++ self._write_lock.release()
+
+ # we do flush on each record now
+ self.flush()
+@@ -336,8 +345,11 @@ class IndexManager(object):
+ d[p.key] = p
+
+ if add_anything:
+- with self._write_lock:
++ self._write_lock.acquire()
++ try:
+ self.datamodel.apply(self)
++ finally:
++ self._write_lock.release()
+
+ return d
+
diff --git a/debian/patches/README b/debian/patches/README
new file mode 100644
index 0000000..80c1584
--- /dev/null
+++ b/debian/patches/README
@@ -0,0 +1,3 @@
+0xxx: Grabbed from upstream development.
+1xxx: Possibly relevant for upstream adoption.
+2xxx: Only relevant for official Debian release.
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..b12f3a6
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,3 @@
+1001_unversioned_hashbang_in_scripts.patch
+1002_avoid_try-except-finally.patch
+1003_avoid_with_statement.patch
diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py
index b3da0cc..888bd26 100644
--- a/src/olpc/datastore/xapianindex.py
+++ b/src/olpc/datastore/xapianindex.py
@@ -4,6 +4,8 @@ xapianindex
maintain indexes on content
"""
+from __future__ import with_statement
+
__author__ = 'Benjamin Saller <bcsaller@objectrealms.net>'
__docformat__ = 'restructuredtext'
__copyright__ = 'Copyright ObjectRealms, LLC, 2007'
@@ -171,8 +173,7 @@ class IndexManager(object):
self.deltact += 1
if force or self.deltact > FLUSH_THRESHOLD:
- self._write_lock.acquire()
- try:
+ with self._write_lock:
# TODO: Would be better to check if the device is present and
# don't try to flush if it's not.
@@ -184,8 +185,6 @@ class IndexManager(object):
#self.read_index.reopen()
self.deltact = 0
- finally:
- self._write_lock.release()
else:
self._flush_timeout = gobject.timeout_add(FLUSH_TIMEOUT * 1000,
self._flush_timeout_cb)
@@ -197,16 +196,13 @@ class IndexManager(object):
# conversion/fulltext indexing can
# happen in the thread
if operation in (CREATE, UPDATE):
- self._write_lock.acquire()
- try:
+ with self._write_lock:
if operation is CREATE:
self.write_index.add(doc)
logger.info("created %s:%s" % (uid, vid))
elif operation is UPDATE:
self.write_index.replace(doc)
logger.info("updated %s:%s" % (uid, vid))
- finally:
- self._write_lock.release()
self.flush()
# Disable content indexing for Trial-3.
@@ -221,12 +217,9 @@ class IndexManager(object):
return
elif operation is DELETE:
# sync deletes
- self._write_lock.acquire()
- try:
+ with self._write_lock:
self.write_index.delete(uid)
logger.info("deleted content %s:%s" % (uid,vid))
- finally:
- self._write_lock.release()
self.flush()
return
@@ -253,8 +246,7 @@ class IndexManager(object):
continue
try:
- self._write_lock.acquire()
- try:
+ with self._write_lock:
if operation is UPDATE:
# Here we handle the conversion of binary
# documents to plain text for indexing. This is
@@ -284,8 +276,6 @@ class IndexManager(object):
# tell the queue its complete
self.queue.task_done()
- finally:
- self._write_lock.release()
# we do flush on each record now
self.flush()
@@ -346,11 +336,8 @@ class IndexManager(object):
d[p.key] = p
if add_anything:
- self._write_lock.acquire()
- try:
+ with self._write_lock:
self.datamodel.apply(self)
- finally:
- self._write_lock.release()
return d