##// END OF EJS Templates
rollback: only restore dirstate and branch when appropriate....
Greg Ward -
r15131:7c26ce9e default
parent child Browse files
Show More
@@ -789,28 +789,35 b' class localrepository(repo.repository):'
789 ui.status(msg)
789 ui.status(msg)
790 if dryrun:
790 if dryrun:
791 return 0
791 return 0
792
793 parents = self.dirstate.parents()
792 transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
794 transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
793 util.rename(self.join('undo.dirstate'), self.join('dirstate'))
794 if os.path.exists(self.join('undo.bookmarks')):
795 if os.path.exists(self.join('undo.bookmarks')):
795 util.rename(self.join('undo.bookmarks'),
796 util.rename(self.join('undo.bookmarks'),
796 self.join('bookmarks'))
797 self.join('bookmarks'))
797 try:
798 branch = self.opener.read('undo.branch')
799 self.dirstate.setbranch(branch)
800 except IOError:
801 ui.warn(_('named branch could not be reset: '
802 'current branch is still \'%s\'\n')
803 % self.dirstate.branch())
804 self.invalidate()
798 self.invalidate()
805 self.dirstate.invalidate()
799
806 self.destroyed()
800 parentgone = (parents[0] not in self.changelog.nodemap or
807 parents = tuple([p.rev() for p in self.parents()])
801 parents[1] not in self.changelog.nodemap)
808 if len(parents) > 1:
802 if parentgone:
809 ui.status(_('working directory now based on '
803 util.rename(self.join('undo.dirstate'), self.join('dirstate'))
810 'revisions %d and %d\n') % parents)
804 try:
811 else:
805 branch = self.opener.read('undo.branch')
812 ui.status(_('working directory now based on '
806 self.dirstate.setbranch(branch)
813 'revision %d\n') % parents)
807 except IOError:
808 ui.warn(_('named branch could not be reset: '
809 'current branch is still \'%s\'\n')
810 % self.dirstate.branch())
811
812 self.dirstate.invalidate()
813 self.destroyed()
814 parents = tuple([p.rev() for p in self.parents()])
815 if len(parents) > 1:
816 ui.status(_('working directory now based on '
817 'revisions %d and %d\n') % parents)
818 else:
819 ui.status(_('working directory now based on '
820 'revision %d\n') % parents)
814 return 0
821 return 0
815
822
816 def invalidatecaches(self):
823 def invalidatecaches(self):
@@ -121,7 +121,6 b' Extension disabled for lack of a hook'
121 updating the branch cache
121 updating the branch cache
122 checking for updated bookmarks
122 checking for updated bookmarks
123 repository tip rolled back to revision 0 (undo push)
123 repository tip rolled back to revision 0 (undo push)
124 working directory now based on revision 0
125 0:6675d58eff77
124 0:6675d58eff77
126
125
127
126
@@ -179,7 +178,6 b' Extension disabled for lack of acl.sourc'
179 updating the branch cache
178 updating the branch cache
180 checking for updated bookmarks
179 checking for updated bookmarks
181 repository tip rolled back to revision 0 (undo push)
180 repository tip rolled back to revision 0 (undo push)
182 working directory now based on revision 0
183 0:6675d58eff77
181 0:6675d58eff77
184
182
185
183
@@ -247,7 +245,6 b' No [acl.allow]/[acl.deny]'
247 updating the branch cache
245 updating the branch cache
248 checking for updated bookmarks
246 checking for updated bookmarks
249 repository tip rolled back to revision 0 (undo push)
247 repository tip rolled back to revision 0 (undo push)
250 working directory now based on revision 0
251 0:6675d58eff77
248 0:6675d58eff77
252
249
253
250
@@ -729,7 +726,6 b' barney is allowed everywhere'
729 updating the branch cache
726 updating the branch cache
730 checking for updated bookmarks
727 checking for updated bookmarks
731 repository tip rolled back to revision 0 (undo push)
728 repository tip rolled back to revision 0 (undo push)
732 working directory now based on revision 0
733 0:6675d58eff77
729 0:6675d58eff77
734
730
735
731
@@ -1038,7 +1034,6 b' acl.config can set only [acl.allow]/[acl'
1038 updating the branch cache
1034 updating the branch cache
1039 checking for updated bookmarks
1035 checking for updated bookmarks
1040 repository tip rolled back to revision 0 (undo push)
1036 repository tip rolled back to revision 0 (undo push)
1041 working directory now based on revision 0
1042 0:6675d58eff77
1037 0:6675d58eff77
1043
1038
1044
1039
@@ -1114,7 +1109,6 b' fred is always allowed'
1114 updating the branch cache
1109 updating the branch cache
1115 checking for updated bookmarks
1110 checking for updated bookmarks
1116 repository tip rolled back to revision 0 (undo push)
1111 repository tip rolled back to revision 0 (undo push)
1117 working directory now based on revision 0
1118 0:6675d58eff77
1112 0:6675d58eff77
1119
1113
1120
1114
@@ -1261,7 +1255,6 b' OS-level groups'
1261 updating the branch cache
1255 updating the branch cache
1262 checking for updated bookmarks
1256 checking for updated bookmarks
1263 repository tip rolled back to revision 0 (undo push)
1257 repository tip rolled back to revision 0 (undo push)
1264 working directory now based on revision 0
1265 0:6675d58eff77
1258 0:6675d58eff77
1266
1259
1267
1260
@@ -1456,7 +1449,6 b' No branch acls specified'
1456 updating the branch cache
1449 updating the branch cache
1457 checking for updated bookmarks
1450 checking for updated bookmarks
1458 repository tip rolled back to revision 2 (undo push)
1451 repository tip rolled back to revision 2 (undo push)
1459 working directory now based on revision 2
1460 2:fb35475503ef
1452 2:fb35475503ef
1461
1453
1462
1454
@@ -1753,7 +1745,6 b' Branch acl allow other'
1753 updating the branch cache
1745 updating the branch cache
1754 checking for updated bookmarks
1746 checking for updated bookmarks
1755 repository tip rolled back to revision 2 (undo push)
1747 repository tip rolled back to revision 2 (undo push)
1756 working directory now based on revision 2
1757 2:fb35475503ef
1748 2:fb35475503ef
1758
1749
1759
1750
@@ -1838,7 +1829,6 b' push foobar into the remote'
1838 updating the branch cache
1829 updating the branch cache
1839 checking for updated bookmarks
1830 checking for updated bookmarks
1840 repository tip rolled back to revision 2 (undo push)
1831 repository tip rolled back to revision 2 (undo push)
1841 working directory now based on revision 2
1842 2:fb35475503ef
1832 2:fb35475503ef
1843
1833
1844 Branch acl conflicting deny
1834 Branch acl conflicting deny
@@ -154,7 +154,6 b''
154 4 files, 9 changesets, 7 total revisions
154 4 files, 9 changesets, 7 total revisions
155 $ hg rollback
155 $ hg rollback
156 repository tip rolled back to revision 4 (undo pull)
156 repository tip rolled back to revision 4 (undo pull)
157 working directory now based on revision -1
158 $ cd ..
157 $ cd ..
159
158
160 should fail
159 should fail
@@ -232,7 +231,6 b' revision 8'
232 4 files, 9 changesets, 7 total revisions
231 4 files, 9 changesets, 7 total revisions
233 $ hg rollback
232 $ hg rollback
234 repository tip rolled back to revision 2 (undo unbundle)
233 repository tip rolled back to revision 2 (undo unbundle)
235 working directory now based on revision 2
236
234
237 revision 2
235 revision 2
238
236
@@ -257,7 +255,6 b' revision 4'
257 2 files, 5 changesets, 5 total revisions
255 2 files, 5 changesets, 5 total revisions
258 $ hg rollback
256 $ hg rollback
259 repository tip rolled back to revision 2 (undo unbundle)
257 repository tip rolled back to revision 2 (undo unbundle)
260 working directory now based on revision 2
261 $ hg unbundle ../test-bundle-branch2.hg
258 $ hg unbundle ../test-bundle-branch2.hg
262 adding changesets
259 adding changesets
263 adding manifests
260 adding manifests
@@ -277,7 +274,6 b' revision 6'
277 3 files, 7 changesets, 6 total revisions
274 3 files, 7 changesets, 6 total revisions
278 $ hg rollback
275 $ hg rollback
279 repository tip rolled back to revision 2 (undo unbundle)
276 repository tip rolled back to revision 2 (undo unbundle)
280 working directory now based on revision 2
281 $ hg unbundle ../test-bundle-cset-7.hg
277 $ hg unbundle ../test-bundle-cset-7.hg
282 adding changesets
278 adding changesets
283 adding manifests
279 adding manifests
@@ -90,7 +90,6 b' Rollback empty'
90
90
91 $ hg -R empty rollback
91 $ hg -R empty rollback
92 repository tip rolled back to revision -1 (undo pull)
92 repository tip rolled back to revision -1 (undo pull)
93 working directory now based on revision -1
94
93
95 Pull full.hg into empty again (using --cwd)
94 Pull full.hg into empty again (using --cwd)
96
95
@@ -121,7 +120,6 b' Rollback empty'
121
120
122 $ hg -R empty rollback
121 $ hg -R empty rollback
123 repository tip rolled back to revision -1 (undo pull)
122 repository tip rolled back to revision -1 (undo pull)
124 working directory now based on revision -1
125
123
126 Pull full.hg into empty again (using -R)
124 Pull full.hg into empty again (using -R)
127
125
@@ -219,7 +217,6 b' Rollback empty'
219
217
220 $ hg rollback
218 $ hg rollback
221 repository tip rolled back to revision -1 (undo pull)
219 repository tip rolled back to revision -1 (undo pull)
222 working directory now based on revision -1
223 $ cd ..
220 $ cd ..
224
221
225 Log -R bundle:empty+full.hg
222 Log -R bundle:empty+full.hg
@@ -112,7 +112,6 b' convert fresh repo with --filemap'
112 1 import
112 1 import
113 filtering out empty revision
113 filtering out empty revision
114 repository tip rolled back to revision 0 (undo commit)
114 repository tip rolled back to revision 0 (undo commit)
115 working directory now based on revision -1
116 0 ci0
115 0 ci0
117 updating tags
116 updating tags
118 $ hgcat b/c
117 $ hgcat b/c
@@ -161,7 +161,6 b' We can fix the head and push again'
161 added 3 changesets with 3 changes to 2 files (+1 heads)
161 added 3 changesets with 3 changes to 2 files (+1 heads)
162 $ hg -R ../main rollback
162 $ hg -R ../main rollback
163 repository tip rolled back to revision 5 (undo push)
163 repository tip rolled back to revision 5 (undo push)
164 working directory now based on revision -1
165
164
166 Test it still fails with checkallhook
165 Test it still fails with checkallhook
167
166
@@ -277,7 +277,6 b' outgoing hooks can see env vars'
277 (run 'hg update' to get a working copy)
277 (run 'hg update' to get a working copy)
278 $ hg rollback
278 $ hg rollback
279 repository tip rolled back to revision 3 (undo pull)
279 repository tip rolled back to revision 3 (undo pull)
280 working directory now based on revision 0
281
280
282 preoutgoing hook can prevent outgoing changes
281 preoutgoing hook can prevent outgoing changes
283
282
@@ -62,7 +62,6 b' Test --user, --date and --message'
62
62
63 $ hg rollback
63 $ hg rollback
64 repository tip rolled back to revision 1 (undo commit)
64 repository tip rolled back to revision 1 (undo commit)
65 working directory now based on revision 0
66
65
67 Test --import-branch
66 Test --import-branch
68
67
@@ -75,7 +74,6 b' Test --import-branch'
75
74
76 $ hg rollback
75 $ hg rollback
77 repository tip rolled back to revision 1 (undo commit)
76 repository tip rolled back to revision 1 (undo commit)
78 working directory now based on revision 0
79
77
80 Test --strip
78 Test --strip
81
79
@@ -98,7 +96,6 b' Test --strip'
98 applying patch from stdin
96 applying patch from stdin
99 $ hg rollback
97 $ hg rollback
100 repository tip rolled back to revision 1 (undo commit)
98 repository tip rolled back to revision 1 (undo commit)
101 working directory now based on revision 0
102
99
103 Test unsupported combinations
100 Test unsupported combinations
104
101
@@ -74,7 +74,6 b' push'
74 +a
74 +a
75 $ hg --cwd a rollback
75 $ hg --cwd a rollback
76 repository tip rolled back to revision -1 (undo push)
76 repository tip rolled back to revision -1 (undo push)
77 working directory now based on revision -1
78
77
79 unbundle with unrelated source
78 unbundle with unrelated source
80
79
@@ -89,7 +88,6 b' unbundle with unrelated source'
89 (run 'hg update' to get a working copy)
88 (run 'hg update' to get a working copy)
90 $ hg --cwd a rollback
89 $ hg --cwd a rollback
91 repository tip rolled back to revision -1 (undo unbundle)
90 repository tip rolled back to revision -1 (undo unbundle)
92 working directory now based on revision -1
93
91
94 unbundle with correct source
92 unbundle with correct source
95
93
@@ -200,7 +200,6 b' fail for config file is missing'
200
200
201 $ hg --cwd b rollback
201 $ hg --cwd b rollback
202 repository tip rolled back to revision 0 (undo pull)
202 repository tip rolled back to revision 0 (undo pull)
203 working directory now based on revision 0
204 $ hg --cwd b pull ../a 2>&1 | grep 'error.*\.notify\.conf' > /dev/null && echo pull failed
203 $ hg --cwd b pull ../a 2>&1 | grep 'error.*\.notify\.conf' > /dev/null && echo pull failed
205 pull failed
204 pull failed
206 $ touch ".notify.conf"
205 $ touch ".notify.conf"
@@ -209,7 +208,6 b' pull'
209
208
210 $ hg --cwd b rollback
209 $ hg --cwd b rollback
211 repository tip rolled back to revision 0 (undo pull)
210 repository tip rolled back to revision 0 (undo pull)
212 working directory now based on revision 0
213 $ hg --traceback --cwd b pull ../a | \
211 $ hg --traceback --cwd b pull ../a | \
214 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
212 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
215 pulling from ../a
213 pulling from ../a
@@ -254,7 +252,6 b' pull'
254
252
255 $ hg --cwd b rollback
253 $ hg --cwd b rollback
256 repository tip rolled back to revision 0 (undo pull)
254 repository tip rolled back to revision 0 (undo pull)
257 working directory now based on revision 0
258 $ hg --traceback --cwd b pull ../a | \
255 $ hg --traceback --cwd b pull ../a | \
259 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
256 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
260 pulling from ../a
257 pulling from ../a
@@ -64,7 +64,6 b' expect success'
64 % serve errors
64 % serve errors
65 $ hg rollback
65 $ hg rollback
66 repository tip rolled back to revision 0 (undo serve)
66 repository tip rolled back to revision 0 (undo serve)
67 working directory now based on revision 0
68
67
69 expect success, server lacks the httpheader capability
68 expect success, server lacks the httpheader capability
70
69
@@ -81,7 +80,6 b' expect success, server lacks the httphea'
81 % serve errors
80 % serve errors
82 $ hg rollback
81 $ hg rollback
83 repository tip rolled back to revision 0 (undo serve)
82 repository tip rolled back to revision 0 (undo serve)
84 working directory now based on revision 0
85
83
86 expect success, server lacks the unbundlehash capability
84 expect success, server lacks the unbundlehash capability
87
85
@@ -98,7 +96,6 b' expect success, server lacks the unbundl'
98 % serve errors
96 % serve errors
99 $ hg rollback
97 $ hg rollback
100 repository tip rolled back to revision 0 (undo serve)
98 repository tip rolled back to revision 0 (undo serve)
101 working directory now based on revision 0
102
99
103 expect authorization error: all users denied
100 expect authorization error: all users denied
104
101
@@ -64,6 +64,35 b' Test rollback of hg before issue 902 was'
64 $ hg branch
64 $ hg branch
65 test
65 test
66
66
67 working dir unaffected by rollback: do not restore dirstate et. al.
68 $ hg log --template '{rev} {branch} {desc|firstline}\n'
69 0 default add a again
70 $ hg status
71 M a
72 $ hg bookmark foo
73 $ hg commit -m'modify a again'
74 $ echo b > b
75 $ hg commit -Am'add b'
76 adding b
77 $ hg log --template '{rev} {branch} {desc|firstline}\n'
78 2 test add b
79 1 test modify a again
80 0 default add a again
81 $ hg update default
82 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
83 $ hg bookmark bar
84 $ cat .hg/undo.branch ; echo
85 test
86 $ hg rollback
87 repository tip rolled back to revision 1 (undo commit)
88 $ hg id -n
89 0
90 $ hg branch
91 default
92 $ cat .hg/bookmarks.current ; echo
93 bar
94 $ hg bookmark --delete foo
95
67 rollback by pretxncommit saves commit message (issue 1635)
96 rollback by pretxncommit saves commit message (issue 1635)
68
97
69 $ echo a >> a
98 $ echo a >> a
@@ -102,18 +131,18 b' test rollback on served repository'
102 adding changesets
131 adding changesets
103 adding manifests
132 adding manifests
104 adding file changes
133 adding file changes
105 added 2 changesets with 2 changes to 1 files
134 added 3 changesets with 2 changes to 1 files (+1 heads)
106 updating to branch default
135 updating to branch default
107 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
136 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 $ cd u
137 $ cd u
109 $ hg id default
138 $ hg id default
110 8902593132ae
139 068774709090
111
140
112 now rollback and observe that 'hg serve' reloads the repository and
141 now rollback and observe that 'hg serve' reloads the repository and
113 presents the correct tip changeset:
142 presents the correct tip changeset:
114
143
115 $ hg -R ../t rollback
144 $ hg -R ../t rollback
116 repository tip rolled back to revision 0 (undo commit)
145 repository tip rolled back to revision 1 (undo commit)
117 working directory now based on revision 0
146 working directory now based on revision 0
118 $ hg id default
147 $ hg id default
119 23b0221f3370
148 791dd2169706
@@ -102,7 +102,6 b' Changing original repo:'
102 $ cd clone
102 $ cd clone
103 $ hg rollback
103 $ hg rollback
104 repository tip rolled back to revision 1 (undo push)
104 repository tip rolled back to revision 1 (undo push)
105 working directory now based on revision 1
106
105
107 $ hg -q incoming
106 $ hg -q incoming
108 2:faba9097cad4
107 2:faba9097cad4
@@ -147,10 +146,6 b' No new revs, no update:'
147
146
148 $ hg rollback
147 $ hg rollback
149 repository tip rolled back to revision 1 (undo pull)
148 repository tip rolled back to revision 1 (undo pull)
150 working directory now based on revision 1
151
152 $ hg up -C 0
153 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
154
149
155 $ hg parents -q
150 $ hg parents -q
156 0:1f0dee641bb7
151 0:1f0dee641bb7
General Comments 0
You need to be logged in to leave comments. Login now