Show More
@@ -826,7 +826,15 b' class revlog(object):' | |||||
826 | size = fp.tell() |
|
826 | size = fp.tell() | |
827 | if size < 131072: |
|
827 | if size < 131072: | |
828 | return |
|
828 | return | |
829 |
tr. |
|
829 | trinfo = tr.find(self.indexfile) | |
|
830 | if trinfo == None: | |||
|
831 | raise RevlogError(_("%s not found in the transaction" % | |||
|
832 | self.indexfile)) | |||
|
833 | ||||
|
834 | trindex = trinfo[2] | |||
|
835 | dataoff = self.start(trindex) | |||
|
836 | ||||
|
837 | tr.add(self.datafile, dataoff) | |||
830 | df = self.opener(self.datafile, 'w') |
|
838 | df = self.opener(self.datafile, 'w') | |
831 | calc = struct.calcsize(self.indexformat) |
|
839 | calc = struct.calcsize(self.indexformat) | |
832 | for r in xrange(self.count()): |
|
840 | for r in xrange(self.count()): | |
@@ -854,6 +862,8 b' class revlog(object):' | |||||
854 | # if we don't call rename, the temp file will never replace the |
|
862 | # if we don't call rename, the temp file will never replace the | |
855 | # real index |
|
863 | # real index | |
856 | fp.rename() |
|
864 | fp.rename() | |
|
865 | ||||
|
866 | tr.replace(self.indexfile, trindex * calc) | |||
857 | self.chunkcache = None |
|
867 | self.chunkcache = None | |
858 |
|
868 | |||
859 | def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): |
|
869 | def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): | |
@@ -922,7 +932,7 b' class revlog(object):' | |||||
922 | else: |
|
932 | else: | |
923 | f = self.opener(self.indexfile, "a+") |
|
933 | f = self.opener(self.indexfile, "a+") | |
924 | f.seek(0, 2) |
|
934 | f.seek(0, 2) | |
925 | transaction.add(self.indexfile, f.tell()) |
|
935 | transaction.add(self.indexfile, f.tell(), self.count() - 1) | |
926 |
|
936 | |||
927 | if len(self.index) == 1 and self.version != 0: |
|
937 | if len(self.index) == 1 and self.version != 0: | |
928 | l = struct.pack(versionformat, self.version) |
|
938 | l = struct.pack(versionformat, self.version) | |
@@ -1071,7 +1081,7 b' class revlog(object):' | |||||
1071 |
|
1081 | |||
1072 | ifh = self.opener(self.indexfile, "a+") |
|
1082 | ifh = self.opener(self.indexfile, "a+") | |
1073 | ifh.seek(0, 2) |
|
1083 | ifh.seek(0, 2) | |
1074 | transaction.add(self.indexfile, ifh.tell()) |
|
1084 | transaction.add(self.indexfile, ifh.tell(), self.count()) | |
1075 | if self.inlinedata(): |
|
1085 | if self.inlinedata(): | |
1076 | dfh = None |
|
1086 | dfh = None | |
1077 | else: |
|
1087 | else: |
@@ -39,14 +39,27 b' class transaction(object):' | |||||
39 | try: os.unlink(self.journal) |
|
39 | try: os.unlink(self.journal) | |
40 | except: pass |
|
40 | except: pass | |
41 |
|
41 | |||
42 | def add(self, file, offset): |
|
42 | def add(self, file, offset, data=None): | |
43 | if file in self.map: return |
|
43 | if file in self.map: return | |
44 | self.entries.append((file, offset)) |
|
44 | self.entries.append((file, offset, data)) | |
45 | self.map[file] = 1 |
|
45 | self.map[file] = len(self.entries) - 1 | |
46 | # add enough data to the journal to do the truncate |
|
46 | # add enough data to the journal to do the truncate | |
47 | self.file.write("%s\0%d\n" % (file, offset)) |
|
47 | self.file.write("%s\0%d\n" % (file, offset)) | |
48 | self.file.flush() |
|
48 | self.file.flush() | |
49 |
|
49 | |||
|
50 | def find(self, file): | |||
|
51 | if file in self.map: | |||
|
52 | return self.entries[self.map[file]] | |||
|
53 | return None | |||
|
54 | ||||
|
55 | def replace(self, file, offset, data=None): | |||
|
56 | if file not in self.map: | |||
|
57 | raise KeyError(file) | |||
|
58 | index = self.map[file] | |||
|
59 | self.entries[index] = (file, offset, data) | |||
|
60 | self.file.write("%s\0%d\n" % (file, offset)) | |||
|
61 | self.file.flush() | |||
|
62 | ||||
50 | def nest(self): |
|
63 | def nest(self): | |
51 | self.count += 1 |
|
64 | self.count += 1 | |
52 | return self |
|
65 | return self | |
@@ -71,7 +84,7 b' class transaction(object):' | |||||
71 |
|
84 | |||
72 | self.report(_("transaction abort!\n")) |
|
85 | self.report(_("transaction abort!\n")) | |
73 |
|
86 | |||
74 | for f, o in self.entries: |
|
87 | for f, o, ignore in self.entries: | |
75 | try: |
|
88 | try: | |
76 | self.opener(f, "a").truncate(o) |
|
89 | self.opener(f, "a").truncate(o) | |
77 | except: |
|
90 | except: | |
@@ -82,8 +95,12 b' class transaction(object):' | |||||
82 | self.report(_("rollback completed\n")) |
|
95 | self.report(_("rollback completed\n")) | |
83 |
|
96 | |||
84 | def rollback(opener, file): |
|
97 | def rollback(opener, file): | |
|
98 | files = {} | |||
85 | for l in open(file).readlines(): |
|
99 | for l in open(file).readlines(): | |
86 | f, o = l.split('\0') |
|
100 | f, o = l.split('\0') | |
|
101 | files[f] = o | |||
|
102 | for f in files: | |||
|
103 | o = files[f] | |||
87 | opener(f, "a").truncate(int(o)) |
|
104 | opener(f, "a").truncate(int(o)) | |
88 | os.unlink(file) |
|
105 | os.unlink(file) | |
89 |
|
106 |
General Comments 0
You need to be logged in to leave comments.
Login now