Show More
@@ -839,16 +839,21 b' def restorestatus(repo):' | |||||
839 | raise |
|
839 | raise | |
840 | raise util.Abort(_('no rebase in progress')) |
|
840 | raise util.Abort(_('no rebase in progress')) | |
841 |
|
841 | |||
842 |
def |
|
842 | def needupdate(repo, state): | |
843 | '''check whether the working dir is in an interrupted rebase''' |
|
843 | '''check whether we should `update --clean` away from a merge, or if | |
|
844 | somehow the working dir got forcibly updated, e.g. by older hg''' | |||
844 | parents = [p.rev() for p in repo.parents()] |
|
845 | parents = [p.rev() for p in repo.parents()] | |
845 | if originalwd in parents: |
|
846 | ||
|
847 | # Are we in a merge state at all? | |||
|
848 | if len(parents) < 2: | |||
|
849 | return False | |||
|
850 | ||||
|
851 | # We should be standing on the first as-of-yet unrebased commit. | |||
|
852 | firstunrebased = min([old for old, new in state.iteritems() | |||
|
853 | if new == nullrev]) | |||
|
854 | if firstunrebased in parents: | |||
846 | return True |
|
855 | return True | |
847 |
|
856 | |||
848 | for newrev in state.itervalues(): |
|
|||
849 | if newrev in parents: |
|
|||
850 | return True |
|
|||
851 |
|
||||
852 | return False |
|
857 | return False | |
853 |
|
858 | |||
854 | def abort(repo, originalwd, target, state, activebookmark=None): |
|
859 | def abort(repo, originalwd, target, state, activebookmark=None): | |
@@ -875,7 +880,7 b' def abort(repo, originalwd, target, stat' | |||||
875 |
|
880 | |||
876 | if cleanup: |
|
881 | if cleanup: | |
877 | # Update away from the rebase if necessary |
|
882 | # Update away from the rebase if necessary | |
878 |
if |
|
883 | if needupdate(repo, state): | |
879 | merge.update(repo, originalwd, False, True, False) |
|
884 | merge.update(repo, originalwd, False, True, False) | |
880 |
|
885 | |||
881 | # Strip from the first rebased revision |
|
886 | # Strip from the first rebased revision |
@@ -241,3 +241,83 b' rebase abort should not leave working co' | |||||
241 | o 0 a |
|
241 | o 0 a | |
242 |
|
242 | |||
243 | $ cd .. |
|
243 | $ cd .. | |
|
244 | ||||
|
245 | Make sure we don't clobber changes in the working directory when the | |||
|
246 | user has somehow managed to update to a different revision (issue4009) | |||
|
247 | ||||
|
248 | $ hg init noupdate | |||
|
249 | $ cd noupdate | |||
|
250 | $ hg book @ | |||
|
251 | $ echo original > a | |||
|
252 | $ hg add a | |||
|
253 | $ hg commit -m a | |||
|
254 | $ echo x > b | |||
|
255 | $ hg add b | |||
|
256 | $ hg commit -m b1 | |||
|
257 | $ hg up 0 | |||
|
258 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
259 | (leaving bookmark @) | |||
|
260 | $ hg book foo | |||
|
261 | $ echo y > b | |||
|
262 | $ hg add b | |||
|
263 | $ hg commit -m b2 | |||
|
264 | created new head | |||
|
265 | ||||
|
266 | $ hg rebase -d @ -b foo --tool=internal:fail | |||
|
267 | rebasing 2:070cf4580bb5 "b2" (tip foo) | |||
|
268 | unresolved conflicts (see hg resolve, then hg rebase --continue) | |||
|
269 | [1] | |||
|
270 | ||||
|
271 | $ mv .hg/rebasestate ./ # so we're allowed to hg up like in mercurial <2.6.3 | |||
|
272 | $ hg up -C 0 # user does other stuff in the repo | |||
|
273 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
274 | ||||
|
275 | $ mv rebasestate .hg/ # user upgrades to 2.7 | |||
|
276 | ||||
|
277 | $ echo new > a | |||
|
278 | $ hg up 1 # user gets an error saying to run hg rebase --abort | |||
|
279 | abort: rebase in progress | |||
|
280 | (use 'hg rebase --continue' or 'hg rebase --abort') | |||
|
281 | [255] | |||
|
282 | ||||
|
283 | $ cat a | |||
|
284 | new | |||
|
285 | $ hg rebase --abort | |||
|
286 | rebase aborted | |||
|
287 | $ cat a | |||
|
288 | new | |||
|
289 | ||||
|
290 | $ cd .. | |||
|
291 | ||||
|
292 | On the other hand, make sure we *do* clobber changes whenever we | |||
|
293 | haven't somehow managed to update the repo to a different revision | |||
|
294 | during a rebase (issue4661) | |||
|
295 | ||||
|
296 | $ hg ini yesupdate | |||
|
297 | $ cd yesupdate | |||
|
298 | $ echo "initial data" > foo.txt | |||
|
299 | $ hg add | |||
|
300 | adding foo.txt | |||
|
301 | $ hg ci -m "initial checkin" | |||
|
302 | $ echo "change 1" > foo.txt | |||
|
303 | $ hg ci -m "change 1" | |||
|
304 | $ hg up 0 | |||
|
305 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
306 | $ echo "conflicting change 1" > foo.txt | |||
|
307 | $ hg ci -m "conflicting 1" | |||
|
308 | created new head | |||
|
309 | $ echo "conflicting change 2" > foo.txt | |||
|
310 | $ hg ci -m "conflicting 2" | |||
|
311 | ||||
|
312 | $ hg rebase -d 1 --tool 'internal:fail' | |||
|
313 | rebasing 2:e4ea5cdc9789 "conflicting 1" | |||
|
314 | unresolved conflicts (see hg resolve, then hg rebase --continue) | |||
|
315 | [1] | |||
|
316 | $ hg rebase --abort | |||
|
317 | rebase aborted | |||
|
318 | $ hg summary | |||
|
319 | parent: 3:b16646383533 tip | |||
|
320 | conflicting 2 | |||
|
321 | branch: default | |||
|
322 | commit: (clean) | |||
|
323 | update: 1 new changesets, 2 branch heads (merge) |
General Comments 0
You need to be logged in to leave comments.
Login now