bisect: do silent init if necessary
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 22 Sep 2007 18:23:56 +0200
changeset 5319 5b6e403601d1
parent 5310 ba3dc7883968
child 5320 189d82b6962e
bisect: do silent init if necessary
hgext/hbisect.py
--- a/hgext/hbisect.py	Sat Sep 15 16:07:05 2007 +0200
+++ b/hgext/hbisect.py	Sat Sep 22 18:23:56 2007 +0200
@@ -37,10 +37,9 @@
         self.ui = ui
         self.goodrevs = []
         self.badrev = None
-        self.good_dirty = 0
-        self.bad_dirty = 0
         self.good_path = "good"
         self.bad_path = "bad"
+        self.is_reset = False
 
         if os.path.exists(os.path.join(self.path, self.good_path)):
             self.goodrevs = self.opener(self.good_path).read().splitlines()
@@ -51,8 +50,10 @@
                 self.badrev = hg.bin(r.pop(0))
 
     def write(self):
+        if self.is_reset:
+            return
         if not os.path.isdir(self.path):
-            return
+            os.mkdir(self.path)
         f = self.opener(self.good_path, "w")
         f.write("\n".join([hg.hex(r) for r in  self.goodrevs]))
         if len(self.goodrevs) > 0:
@@ -81,6 +82,7 @@
         # Not sure about this
         #self.ui.write("Going back to tip\n")
         #self.repo.update(self.repo.changelog.tip())
+        self.is_reset = True
         return 0
 
     def num_ancestors(self, head=None, stop=None):