summaryrefslogtreecommitdiff
path: root/processors
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 /processors
parent8331236f1ddcd0ac9056dce82f157714e7277f7a (diff)
downloadbzr-fastimport-00998e68def7710ae12f926c0a1aaa0df861f13d.tar.gz
Fix typo, handle bzr-specific locking in GenericProcessor.
Diffstat (limited to 'processors')
-rw-r--r--processors/generic_processor.py25
1 files changed, 25 insertions, 0 deletions
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: