Show More
@@ -624,7 +624,7 class localrepository(repo.repository): | |||||
624 | try: |
|
624 | try: | |
625 | if os.path.exists(self.sjoin("journal")): |
|
625 | if os.path.exists(self.sjoin("journal")): | |
626 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
626 | self.ui.status(_("rolling back interrupted transaction\n")) | |
627 | transaction.rollback(self.sopener, self.sjoin("journal")) |
|
627 | transaction.rollback(self.sopener, self.sjoin("journal"), self.ui.warn) | |
628 | self.invalidate() |
|
628 | self.invalidate() | |
629 | return True |
|
629 | return True | |
630 | else: |
|
630 | else: | |
@@ -640,7 +640,7 class localrepository(repo.repository): | |||||
640 | lock = self.lock() |
|
640 | lock = self.lock() | |
641 | if os.path.exists(self.sjoin("undo")): |
|
641 | if os.path.exists(self.sjoin("undo")): | |
642 | self.ui.status(_("rolling back last transaction\n")) |
|
642 | self.ui.status(_("rolling back last transaction\n")) | |
643 | transaction.rollback(self.sopener, self.sjoin("undo")) |
|
643 | transaction.rollback(self.sopener, self.sjoin("undo"), self.ui.warn) | |
644 | util.rename(self.join("undo.dirstate"), self.join("dirstate")) |
|
644 | util.rename(self.join("undo.dirstate"), self.join("dirstate")) | |
645 | try: |
|
645 | try: | |
646 | branch = self.opener("undo.branch").read() |
|
646 | branch = self.opener("undo.branch").read() |
@@ -23,6 +23,23 def active(func): | |||||
23 | return func(self, *args, **kwds) |
|
23 | return func(self, *args, **kwds) | |
24 | return _active |
|
24 | return _active | |
25 |
|
25 | |||
|
26 | def _playback(journal, report, opener, entries, unlink=True): | |||
|
27 | for f, o, ignore in entries: | |||
|
28 | if o or not unlink: | |||
|
29 | try: | |||
|
30 | opener(f, 'a').truncate(o) | |||
|
31 | except: | |||
|
32 | report(_("failed to truncate %s\n") % f) | |||
|
33 | raise | |||
|
34 | else: | |||
|
35 | try: | |||
|
36 | fn = opener(f).name | |||
|
37 | os.unlink(fn) | |||
|
38 | except OSError, inst: | |||
|
39 | if inst.errno != errno.ENOENT: | |||
|
40 | raise | |||
|
41 | os.unlink(journal) | |||
|
42 | ||||
26 | class transaction(object): |
|
43 | class transaction(object): | |
27 | def __init__(self, report, opener, journal, after=None, createmode=None): |
|
44 | def __init__(self, report, opener, journal, after=None, createmode=None): | |
28 | self.journal = None |
|
45 | self.journal = None | |
@@ -101,40 +118,21 class transaction(object): | |||||
101 |
|
118 | |||
102 | self.report(_("transaction abort!\n")) |
|
119 | self.report(_("transaction abort!\n")) | |
103 |
|
120 | |||
104 | failed = False |
|
121 | try: | |
105 | for f, o, ignore in self.entries: |
|
|||
106 | try: |
|
122 | try: | |
107 | self.opener(f, "a").truncate(o) |
|
123 | _playback(self.journal, self.report, self.opener, self.entries, False) | |
|
124 | self.report(_("rollback completed\n")) | |||
108 | except: |
|
125 | except: | |
109 | failed = True |
|
|||
110 | self.report(_("failed to truncate %s\n") % f) |
|
|||
111 |
|
||||
112 | self.entries = [] |
|
|||
113 |
|
||||
114 | if not failed: |
|
|||
115 | os.unlink(self.journal) |
|
|||
116 | self.report(_("rollback completed\n")) |
|
|||
117 | else: |
|
|||
118 | self.report(_("rollback failed - please run hg recover\n")) |
|
126 | self.report(_("rollback failed - please run hg recover\n")) | |
119 |
|
127 | finally: | ||
120 | self.journal = None |
|
128 | self.journal = None | |
121 |
|
129 | |||
122 |
|
130 | |||
123 | def rollback(opener, file): |
|
131 | def rollback(opener, file, report): | |
124 |
|
|
132 | entries = [] | |
|
133 | ||||
125 | for l in open(file).readlines(): |
|
134 | for l in open(file).readlines(): | |
126 | f, o = l.split('\0') |
|
135 | f, o = l.split('\0') | |
127 | files[f] = int(o) |
|
136 | entries.append((f, int(o), None)) | |
128 | for f in files: |
|
|||
129 | o = files[f] |
|
|||
130 | if o: |
|
|||
131 | opener(f, "a").truncate(int(o)) |
|
|||
132 | else: |
|
|||
133 | try: |
|
|||
134 | fn = opener(f).name |
|
|||
135 | os.unlink(fn) |
|
|||
136 | except OSError, inst: |
|
|||
137 | if inst.errno != errno.ENOENT: |
|
|||
138 | raise |
|
|||
139 | os.unlink(file) |
|
|||
140 |
|
137 | |||
|
138 | _playback(file, report, opener, entries) |
@@ -17,8 +17,9 checking files | |||||
17 | b@?: rev 1 points to nonexistent changeset 2 |
|
17 | b@?: rev 1 points to nonexistent changeset 2 | |
18 | (expected 1) |
|
18 | (expected 1) | |
19 | b@?: 736c29771fba not in manifests |
|
19 | b@?: 736c29771fba not in manifests | |
|
20 | warning: orphan revlog 'data/c.i' | |||
20 | 2 files, 2 changesets, 3 total revisions |
|
21 | 2 files, 2 changesets, 3 total revisions | |
21 |
|
|
22 | 2 warnings encountered! | |
22 | 2 integrity errors encountered! |
|
23 | 2 integrity errors encountered! | |
23 | % journal contents |
|
24 | % journal contents | |
24 | 00changelog.i |
|
25 | 00changelog.i | |
@@ -63,15 +64,15 checking manifests | |||||
63 | manifest@?: rev 2 points to nonexistent changeset 2 |
|
64 | manifest@?: rev 2 points to nonexistent changeset 2 | |
64 | manifest@?: rev 3 points to nonexistent changeset 3 |
|
65 | manifest@?: rev 3 points to nonexistent changeset 3 | |
65 | crosschecking files in changesets and manifests |
|
66 | crosschecking files in changesets and manifests | |
66 |
c@ |
|
67 | c@3: in manifest but not in changeset | |
67 | checking files |
|
68 | checking files | |
68 | b@2: 736c29771fba in manifests not found |
|
69 | b@?: rev 1 points to nonexistent changeset 2 | |
69 | data/c.i@?: missing revlog! |
|
70 | (expected 1) | |
70 | ?: empty or missing c |
|
71 | c@?: rev 0 points to nonexistent changeset 3 | |
71 | c@3: 149da44f2a4e in manifests not found |
|
72 | 3 files, 2 changesets, 4 total revisions | |
72 | 3 files, 2 changesets, 2 total revisions |
|
73 | 1 warnings encountered! | |
73 |
|
|
74 | 5 integrity errors encountered! | |
74 |
(first damaged changeset appears to be |
|
75 | (first damaged changeset appears to be 3) | |
75 | % journal contents |
|
76 | % journal contents | |
76 | 00changelog.i |
|
77 | 00changelog.i | |
77 | 00manifest.i |
|
78 | 00manifest.i |
General Comments 0
You need to be logged in to leave comments.
Login now