Show More
@@ -71,14 +71,6 b' def write(repo):' | |||||
71 | ''' |
|
71 | ''' | |
72 | refs = repo._bookmarks |
|
72 | refs = repo._bookmarks | |
73 |
|
73 | |||
74 | try: |
|
|||
75 | bms = repo.opener.read('bookmarks') |
|
|||
76 | except IOError, inst: |
|
|||
77 | if inst.errno != errno.ENOENT: |
|
|||
78 | raise |
|
|||
79 | bms = '' |
|
|||
80 | repo.opener.write('undo.bookmarks', bms) |
|
|||
81 |
|
||||
82 | if repo._bookmarkcurrent not in refs: |
|
74 | if repo._bookmarkcurrent not in refs: | |
83 | setcurrent(repo, None) |
|
75 | setcurrent(repo, None) | |
84 | for mark in refs.keys(): |
|
76 | for mark in refs.keys(): |
@@ -674,6 +674,17 b' class localrepository(repo.repository):' | |||||
674 | raise error.RepoError( |
|
674 | raise error.RepoError( | |
675 | _("abandoned transaction found - run hg recover")) |
|
675 | _("abandoned transaction found - run hg recover")) | |
676 |
|
676 | |||
|
677 | journalfiles = self._writejournal(desc) | |||
|
678 | renames = [(x, undoname(x)) for x in journalfiles] | |||
|
679 | ||||
|
680 | tr = transaction.transaction(self.ui.warn, self.sopener, | |||
|
681 | self.sjoin("journal"), | |||
|
682 | aftertrans(renames), | |||
|
683 | self.store.createmode) | |||
|
684 | self._transref = weakref.ref(tr) | |||
|
685 | return tr | |||
|
686 | ||||
|
687 | def _writejournal(self, desc): | |||
677 | # save dirstate for rollback |
|
688 | # save dirstate for rollback | |
678 | try: |
|
689 | try: | |
679 | ds = self.opener.read("dirstate") |
|
690 | ds = self.opener.read("dirstate") | |
@@ -685,16 +696,15 b' class localrepository(repo.repository):' | |||||
685 | self.opener.write("journal.desc", |
|
696 | self.opener.write("journal.desc", | |
686 | "%d\n%s\n" % (len(self), desc)) |
|
697 | "%d\n%s\n" % (len(self), desc)) | |
687 |
|
698 | |||
688 | renames = [(self.sjoin("journal"), self.sjoin("undo")), |
|
699 | bkname = self.join('bookmarks') | |
689 | (self.join("journal.dirstate"), self.join("undo.dirstate")), |
|
700 | if os.path.exists(bkname): | |
690 | (self.join("journal.branch"), self.join("undo.branch")), |
|
701 | util.copyfile(bkname, self.join('journal.bookmarks')) | |
691 | (self.join("journal.desc"), self.join("undo.desc"))] |
|
702 | else: | |
692 | tr = transaction.transaction(self.ui.warn, self.sopener, |
|
703 | self.opener('journal.bookmarks', 'w').write('') | |
693 | self.sjoin("journal"), |
|
704 | ||
694 | aftertrans(renames), |
|
705 | return (self.sjoin('journal'), self.join('journal.dirstate'), | |
695 | self.store.createmode) |
|
706 | self.join('journal.branch'), self.join('journal.desc'), | |
696 | self._transref = weakref.ref(tr) |
|
707 | self.join('journal.bookmarks')) | |
697 | return tr |
|
|||
698 |
|
708 | |||
699 | def recover(self): |
|
709 | def recover(self): | |
700 | lock = self.lock() |
|
710 | lock = self.lock() | |
@@ -1950,6 +1960,11 b' def aftertrans(files):' | |||||
1950 | util.rename(src, dest) |
|
1960 | util.rename(src, dest) | |
1951 | return a |
|
1961 | return a | |
1952 |
|
1962 | |||
|
1963 | def undoname(fn): | |||
|
1964 | base, name = os.path.split(fn) | |||
|
1965 | assert name.startswith('journal') | |||
|
1966 | return os.path.join(base, name.replace('journal', 'undo', 1)) | |||
|
1967 | ||||
1953 | def instance(ui, path, create): |
|
1968 | def instance(ui, path, create): | |
1954 | return localrepository(ui, util.localpath(path), create) |
|
1969 | return localrepository(ui, util.localpath(path), create) | |
1955 |
|
1970 |
@@ -235,6 +235,7 b' the bookmark extension should be ignored' | |||||
235 | Y 2:db815d6d32e6 |
|
235 | Y 2:db815d6d32e6 | |
236 | * Z 2:db815d6d32e6 |
|
236 | * Z 2:db815d6d32e6 | |
237 | x y 2:db815d6d32e6 |
|
237 | x y 2:db815d6d32e6 | |
|
238 | ||||
238 | test summary |
|
239 | test summary | |
239 |
|
240 | |||
240 | $ hg summary |
|
241 | $ hg summary | |
@@ -249,6 +250,22 b' test id' | |||||
249 | $ hg id |
|
250 | $ hg id | |
250 | db815d6d32e6 tip Y/Z/x y |
|
251 | db815d6d32e6 tip Y/Z/x y | |
251 |
|
252 | |||
|
253 | test rollback | |||
|
254 | ||||
|
255 | $ echo foo > f1 | |||
|
256 | $ hg ci -Amr | |||
|
257 | adding f1 | |||
|
258 | $ hg bookmark -f Y -r 1 | |||
|
259 | $ hg bookmark -f Z -r 1 | |||
|
260 | $ hg rollback | |||
|
261 | repository tip rolled back to revision 2 (undo commit) | |||
|
262 | working directory now based on revision 2 | |||
|
263 | $ hg bookmarks | |||
|
264 | X2 1:925d80f479bb | |||
|
265 | Y 2:db815d6d32e6 | |||
|
266 | * Z 2:db815d6d32e6 | |||
|
267 | x y 2:db815d6d32e6 | |||
|
268 | ||||
252 | test clone |
|
269 | test clone | |
253 |
|
270 | |||
254 | $ hg bookmarks |
|
271 | $ hg bookmarks |
@@ -76,6 +76,7 b' Non store repo:' | |||||
76 | .hg/last-message.txt |
|
76 | .hg/last-message.txt | |
77 | .hg/requires |
|
77 | .hg/requires | |
78 | .hg/undo |
|
78 | .hg/undo | |
|
79 | .hg/undo.bookmarks | |||
79 | .hg/undo.branch |
|
80 | .hg/undo.branch | |
80 | .hg/undo.desc |
|
81 | .hg/undo.desc | |
81 | .hg/undo.dirstate |
|
82 | .hg/undo.dirstate | |
@@ -102,6 +103,7 b' Non fncache repo:' | |||||
102 | .hg/store/data/tst.d.hg |
|
103 | .hg/store/data/tst.d.hg | |
103 | .hg/store/data/tst.d.hg/_foo.i |
|
104 | .hg/store/data/tst.d.hg/_foo.i | |
104 | .hg/store/undo |
|
105 | .hg/store/undo | |
|
106 | .hg/undo.bookmarks | |||
105 | .hg/undo.branch |
|
107 | .hg/undo.branch | |
106 | .hg/undo.desc |
|
108 | .hg/undo.desc | |
107 | .hg/undo.dirstate |
|
109 | .hg/undo.dirstate |
@@ -194,6 +194,7 b' r4 has hardlinks in the working dir (not' | |||||
194 | 2 r4/.hg/store/data/f1.i |
|
194 | 2 r4/.hg/store/data/f1.i | |
195 | 2 r4/.hg/store/fncache |
|
195 | 2 r4/.hg/store/fncache | |
196 | 2 r4/.hg/store/undo |
|
196 | 2 r4/.hg/store/undo | |
|
197 | 2 r4/.hg/undo.bookmarks | |||
197 | 2 r4/.hg/undo.branch |
|
198 | 2 r4/.hg/undo.branch | |
198 | 2 r4/.hg/undo.desc |
|
199 | 2 r4/.hg/undo.desc | |
199 | 2 r4/.hg/undo.dirstate |
|
200 | 2 r4/.hg/undo.dirstate | |
@@ -222,6 +223,7 b' Update back to revision 11 in r4 should ' | |||||
222 | 2 r4/.hg/store/data/f1.i |
|
223 | 2 r4/.hg/store/data/f1.i | |
223 | 2 r4/.hg/store/fncache |
|
224 | 2 r4/.hg/store/fncache | |
224 | 2 r4/.hg/store/undo |
|
225 | 2 r4/.hg/store/undo | |
|
226 | 2 r4/.hg/undo.bookmarks | |||
225 | 2 r4/.hg/undo.branch |
|
227 | 2 r4/.hg/undo.branch | |
226 | 2 r4/.hg/undo.desc |
|
228 | 2 r4/.hg/undo.desc | |
227 | 2 r4/.hg/undo.dirstate |
|
229 | 2 r4/.hg/undo.dirstate |
@@ -17,4 +17,4 b' Test hangup signal in the middle of tran' | |||||
17 | rollback completed |
|
17 | rollback completed | |
18 | killed! |
|
18 | killed! | |
19 | $ echo .hg/* .hg/store/* |
|
19 | $ echo .hg/* .hg/store/* | |
20 | .hg/00changelog.i .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a |
|
20 | .hg/00changelog.i .hg/journal.bookmarks .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a |
@@ -77,6 +77,7 b' new directories are setgid' | |||||
77 | 00660 ./.hg/store/data/foo.i |
|
77 | 00660 ./.hg/store/data/foo.i | |
78 | 00660 ./.hg/store/fncache |
|
78 | 00660 ./.hg/store/fncache | |
79 | 00660 ./.hg/store/undo |
|
79 | 00660 ./.hg/store/undo | |
|
80 | 00660 ./.hg/undo.bookmarks | |||
80 | 00660 ./.hg/undo.branch |
|
81 | 00660 ./.hg/undo.branch | |
81 | 00660 ./.hg/undo.desc |
|
82 | 00660 ./.hg/undo.desc | |
82 | 00660 ./.hg/undo.dirstate |
|
83 | 00660 ./.hg/undo.dirstate | |
@@ -117,6 +118,7 b' group can still write everything' | |||||
117 | 00660 ../push/.hg/store/data/foo.i |
|
118 | 00660 ../push/.hg/store/data/foo.i | |
118 | 00660 ../push/.hg/store/fncache |
|
119 | 00660 ../push/.hg/store/fncache | |
119 | 00660 ../push/.hg/store/undo |
|
120 | 00660 ../push/.hg/store/undo | |
|
121 | 00660 ../push/.hg/undo.bookmarks | |||
120 | 00660 ../push/.hg/undo.branch |
|
122 | 00660 ../push/.hg/undo.branch | |
121 | 00660 ../push/.hg/undo.desc |
|
123 | 00660 ../push/.hg/undo.desc | |
122 | 00660 ../push/.hg/undo.dirstate |
|
124 | 00660 ../push/.hg/undo.dirstate |
General Comments 0
You need to be logged in to leave comments.
Login now