##// END OF EJS Templates
transaction: only delete journal on successful abort/commit...
Henrik Stuart -
r8071:9f14b668 default
parent child Browse files
Show More
@@ -34,8 +34,6 b' class transaction(object):'
34 if self.journal:
34 if self.journal:
35 if self.entries: self.abort()
35 if self.entries: self.abort()
36 self.file.close()
36 self.file.close()
37 try: os.unlink(self.journal)
38 except: pass
39
37
40 def add(self, file, offset, data=None):
38 def add(self, file, offset, data=None):
41 if file in self.map: return
39 if file in self.map: return
@@ -82,15 +80,23 b' class transaction(object):'
82
80
83 self.report(_("transaction abort!\n"))
81 self.report(_("transaction abort!\n"))
84
82
83 failed = False
85 for f, o, ignore in self.entries:
84 for f, o, ignore in self.entries:
86 try:
85 try:
87 self.opener(f, "a").truncate(o)
86 self.opener(f, "a").truncate(o)
88 except:
87 except:
88 failed = True
89 self.report(_("failed to truncate %s\n") % f)
89 self.report(_("failed to truncate %s\n") % f)
90
90
91 self.entries = []
91 self.entries = []
92
92
93 if not failed:
94 self.file.close()
95 os.unlink(self.journal)
96 self.journal = None
93 self.report(_("rollback completed\n"))
97 self.report(_("rollback completed\n"))
98 else:
99 self.report(_("rollback failed - please run hg recover\n"))
94
100
95 def rollback(opener, file):
101 def rollback(opener, file):
96 files = {}
102 files = {}
General Comments 0
You need to be logged in to leave comments. Login now