convert: add before/after hooks for converter sources
authorBryan O'Sullivan <bos@serpentine.com>
Tue, 02 Oct 2007 13:46:17 -0700
changeset 5356 f0931c0240b4
parent 5352 cc34be74eeec
child 5357 c6adf2be6069
convert: add before/after hooks for converter sources
hgext/convert/__init__.py
hgext/convert/common.py
--- a/hgext/convert/__init__.py	Sat Sep 29 21:10:54 2007 -0700
+++ b/hgext/convert/__init__.py	Tue Oct 02 13:46:17 2007 -0700
@@ -235,6 +235,7 @@
 
     def convert(self):
         try:
+            self.source.before()
             self.dest.before()
             self.source.setrevmap(self.map)
             self.ui.status("scanning source...\n")
@@ -273,7 +274,10 @@
             self.cleanup()
 
     def cleanup(self):
-        self.dest.after()
+        try:
+            self.dest.after()
+        finally:
+            self.source.after()
         if self.revmapfilefd:
             self.revmapfilefd.close()
 
--- a/hgext/convert/common.py	Sat Sep 29 21:10:54 2007 -0700
+++ b/hgext/convert/common.py	Tue Oct 02 13:46:17 2007 -0700
@@ -38,6 +38,12 @@
 
         self.encoding = 'utf-8'
 
+    def before(self):
+        pass
+
+    def after(self):
+        pass
+
     def setrevmap(self, revmap):
         """set the map of already-converted revisions"""
         pass