mercurial/transaction.py
changeset 43 42177b56b949
parent 42 91f1fa847158
child 95 589f507bb259
equal deleted inserted replaced
42:91f1fa847158 43:42177b56b949
    20         self.map = {}
    20         self.map = {}
    21         self.journal = journal
    21         self.journal = journal
    22 
    22 
    23         # abort here if the journal already exists
    23         # abort here if the journal already exists
    24         if os.path.exists(self.journal):
    24         if os.path.exists(self.journal):
    25             raise "Journal already exists!"
    25             print "journal already exists, recovering"
       
    26             self.recover()
       
    27 
    26         self.file = open(self.journal, "w")
    28         self.file = open(self.journal, "w")
    27 
    29 
    28     def __del__(self):
    30     def __del__(self):
    29         if self.entries: self.abort()
    31         if self.entries: self.abort()
    30         try: os.unlink(self.journal)
    32         try: os.unlink(self.journal)
    57         
    59         
    58     def recover(self):
    60     def recover(self):
    59         for l in open(self.journal).readlines():
    61         for l in open(self.journal).readlines():
    60             f, o = l.split('\0')
    62             f, o = l.split('\0')
    61             self.opener(f, "a").truncate(int(o))
    63             self.opener(f, "a").truncate(int(o))
       
    64         os.unlink(self.journal)
    62 
    65