hgext/hbisect.py
changeset 5311 5b6e403601d1
parent 5160 c13610d5642c
child 5312 189d82b6962e
equal deleted inserted replaced
5310:ba3dc7883968 5311:5b6e403601d1
    35         self.path = repo.join("bisect")
    35         self.path = repo.join("bisect")
    36         self.opener = util.opener(self.path)
    36         self.opener = util.opener(self.path)
    37         self.ui = ui
    37         self.ui = ui
    38         self.goodrevs = []
    38         self.goodrevs = []
    39         self.badrev = None
    39         self.badrev = None
    40         self.good_dirty = 0
       
    41         self.bad_dirty = 0
       
    42         self.good_path = "good"
    40         self.good_path = "good"
    43         self.bad_path = "bad"
    41         self.bad_path = "bad"
       
    42         self.is_reset = False
    44 
    43 
    45         if os.path.exists(os.path.join(self.path, self.good_path)):
    44         if os.path.exists(os.path.join(self.path, self.good_path)):
    46             self.goodrevs = self.opener(self.good_path).read().splitlines()
    45             self.goodrevs = self.opener(self.good_path).read().splitlines()
    47             self.goodrevs = [hg.bin(x) for x in self.goodrevs]
    46             self.goodrevs = [hg.bin(x) for x in self.goodrevs]
    48         if os.path.exists(os.path.join(self.path, self.bad_path)):
    47         if os.path.exists(os.path.join(self.path, self.bad_path)):
    49             r = self.opener(self.bad_path).read().splitlines()
    48             r = self.opener(self.bad_path).read().splitlines()
    50             if r:
    49             if r:
    51                 self.badrev = hg.bin(r.pop(0))
    50                 self.badrev = hg.bin(r.pop(0))
    52 
    51 
    53     def write(self):
    52     def write(self):
       
    53         if self.is_reset:
       
    54             return
    54         if not os.path.isdir(self.path):
    55         if not os.path.isdir(self.path):
    55             return
    56             os.mkdir(self.path)
    56         f = self.opener(self.good_path, "w")
    57         f = self.opener(self.good_path, "w")
    57         f.write("\n".join([hg.hex(r) for r in  self.goodrevs]))
    58         f.write("\n".join([hg.hex(r) for r in  self.goodrevs]))
    58         if len(self.goodrevs) > 0:
    59         if len(self.goodrevs) > 0:
    59             f.write("\n")
    60             f.write("\n")
    60         f = self.opener(self.bad_path, "w")
    61         f = self.opener(self.bad_path, "w")
    79                     os.unlink(s)
    80                     os.unlink(s)
    80             os.rmdir(self.path)
    81             os.rmdir(self.path)
    81         # Not sure about this
    82         # Not sure about this
    82         #self.ui.write("Going back to tip\n")
    83         #self.ui.write("Going back to tip\n")
    83         #self.repo.update(self.repo.changelog.tip())
    84         #self.repo.update(self.repo.changelog.tip())
       
    85         self.is_reset = True
    84         return 0
    86         return 0
    85 
    87 
    86     def num_ancestors(self, head=None, stop=None):
    88     def num_ancestors(self, head=None, stop=None):
    87         """
    89         """
    88         returns a dict with the mapping:
    90         returns a dict with the mapping: