summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-05 23:42:04 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-09-05 23:42:04 +0200
commit00998e68def7710ae12f926c0a1aaa0df861f13d (patch)
tree870f5bf9a58f03a200b8bcb763c3f60dc1610d80
parent8331236f1ddcd0ac9056dce82f157714e7277f7a (diff)
downloadpython-fastimport-00998e68def7710ae12f926c0a1aaa0df861f13d.tar.gz
Fix typo, handle bzr-specific locking in GenericProcessor.
-rw-r--r--cache_manager.py2
-rw-r--r--processors/generic_processor.py25
-rw-r--r--tests/test_filter_processor.py2
3 files changed, 27 insertions, 2 deletions
diff --git a/cache_manager.py b/cache_manager.py
index 59f8911..4b0c369 100644
--- a/cache_manager.py
+++ b/cache_manager.py
@@ -79,7 +79,7 @@ class _Cleanup(object):
self.small_blobs.close()
self.small_blobs = None
if self.tempdir is not None:
- shutils.rmtree(self.tempdir)
+ shutil.rmtree(self.tempdir)
class CacheManager(object):
diff --git a/processors/generic_processor.py b/processors/generic_processor.py
index 394dc06..a2fe03c 100644
--- a/processors/generic_processor.py
+++ b/processors/generic_processor.py
@@ -288,6 +288,31 @@ class GenericProcessor(processor.ImportProcessor):
self.repo, self.inventory_cache_size,
fulltext_when=fulltext_when)
+ def process(self, command_iter):
+ """Import data into Bazaar by processing a stream of commands.
+
+ :param command_iter: an iterator providing commands
+ """
+ if self.working_tree is not None:
+ self.working_tree.lock_write()
+ elif self.branch is not None:
+ self.branch.lock_write()
+ elif self.repo is not None:
+ self.repo.lock_write()
+ try:
+ super(GenericProcessor, self)._process(command_iter)
+ finally:
+ # If an unhandled exception occurred, abort the write group
+ if self.repo is not None and self.repo.is_in_write_group():
+ self.repo.abort_write_group()
+ # Release the locks
+ if self.working_tree is not None:
+ self.working_tree.unlock()
+ elif self.branch is not None:
+ self.branch.unlock()
+ elif self.repo is not None:
+ self.repo.unlock()
+
def _process(self, command_iter):
# if anything goes wrong, abort the write group if any
try:
diff --git a/tests/test_filter_processor.py b/tests/test_filter_processor.py
index 2857873..5bc7d97 100644
--- a/tests/test_filter_processor.py
+++ b/tests/test_filter_processor.py
@@ -109,7 +109,7 @@ class TestCaseWithFiltering(TestCase):
def assertFiltering(self, input, params, expected):
outf = StringIO()
proc = filter_processor.FilterProcessor(
- None, params=params)
+ params=params)
proc.outf = outf
s = StringIO(input)
p = parser.ImportParser(s)