##// END OF EJS Templates
rebase: restore active bookmark after rebase --continue...
Durham Goode -
r18755:72412afe stable
parent child Browse files
Show More
@@ -112,6 +112,7 def rebase(ui, repo, **opts):
112 Returns 0 on success, 1 if nothing to rebase.
112 Returns 0 on success, 1 if nothing to rebase.
113 """
113 """
114 originalwd = target = None
114 originalwd = target = None
115 activebookmark = None
115 external = nullrev
116 external = nullrev
116 state = {}
117 state = {}
117 skipped = set()
118 skipped = set()
@@ -159,7 +160,7 def rebase(ui, repo, **opts):
159 ui.warn(_('tool option will be ignored\n'))
160 ui.warn(_('tool option will be ignored\n'))
160
161
161 (originalwd, target, state, skipped, collapsef, keepf,
162 (originalwd, target, state, skipped, collapsef, keepf,
162 keepbranchesf, external) = restorestatus(repo)
163 keepbranchesf, external, activebookmark) = restorestatus(repo)
163 if abortf:
164 if abortf:
164 return abort(repo, originalwd, target, state)
165 return abort(repo, originalwd, target, state)
165 else:
166 else:
@@ -245,7 +246,7 def rebase(ui, repo, **opts):
245
246
246 # Keep track of the current bookmarks in order to reset them later
247 # Keep track of the current bookmarks in order to reset them later
247 currentbookmarks = repo._bookmarks.copy()
248 currentbookmarks = repo._bookmarks.copy()
248 activebookmark = repo._bookmarkcurrent
249 activebookmark = activebookmark or repo._bookmarkcurrent
249 if activebookmark:
250 if activebookmark:
250 bookmarks.unsetcurrent(repo)
251 bookmarks.unsetcurrent(repo)
251
252
@@ -258,7 +259,7 def rebase(ui, repo, **opts):
258 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, repo[rev])),
259 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, repo[rev])),
259 _('changesets'), total)
260 _('changesets'), total)
260 storestatus(repo, originalwd, target, state, collapsef, keepf,
261 storestatus(repo, originalwd, target, state, collapsef, keepf,
261 keepbranchesf, external)
262 keepbranchesf, external, activebookmark)
262 p1, p2 = defineparents(repo, rev, target, state,
263 p1, p2 = defineparents(repo, rev, target, state,
263 targetancestors)
264 targetancestors)
264 if len(repo.parents()) == 2:
265 if len(repo.parents()) == 2:
@@ -516,7 +517,7 def updatebookmarks(repo, targetnode, ns
516 marks.write()
517 marks.write()
517
518
518 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
519 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
519 external):
520 external, activebookmark):
520 'Store the current status to allow recovery'
521 'Store the current status to allow recovery'
521 f = repo.opener("rebasestate", "w")
522 f = repo.opener("rebasestate", "w")
522 f.write(repo[originalwd].hex() + '\n')
523 f.write(repo[originalwd].hex() + '\n')
@@ -525,6 +526,7 def storestatus(repo, originalwd, target
525 f.write('%d\n' % int(collapse))
526 f.write('%d\n' % int(collapse))
526 f.write('%d\n' % int(keep))
527 f.write('%d\n' % int(keep))
527 f.write('%d\n' % int(keepbranches))
528 f.write('%d\n' % int(keepbranches))
529 f.write('%s\n' % (activebookmark or ''))
528 for d, v in state.iteritems():
530 for d, v in state.iteritems():
529 oldrev = repo[d].hex()
531 oldrev = repo[d].hex()
530 if v > nullmerge:
532 if v > nullmerge:
@@ -545,6 +547,7 def restorestatus(repo):
545 target = None
547 target = None
546 collapse = False
548 collapse = False
547 external = nullrev
549 external = nullrev
550 activebookmark = None
548 state = {}
551 state = {}
549 f = repo.opener("rebasestate")
552 f = repo.opener("rebasestate")
550 for i, l in enumerate(f.read().splitlines()):
553 for i, l in enumerate(f.read().splitlines()):
@@ -560,6 +563,10 def restorestatus(repo):
560 keep = bool(int(l))
563 keep = bool(int(l))
561 elif i == 5:
564 elif i == 5:
562 keepbranches = bool(int(l))
565 keepbranches = bool(int(l))
566 elif i == 6 and not (len(l) == 81 and ':' in l):
567 # line 6 is a recent addition, so for backwards compatibility
568 # check that the line doesn't look like the oldrev:newrev lines
569 activebookmark = l
563 else:
570 else:
564 oldrev, newrev = l.split(':')
571 oldrev, newrev = l.split(':')
565 if newrev in (str(nullmerge), str(revignored)):
572 if newrev in (str(nullmerge), str(revignored)):
@@ -577,7 +584,7 def restorestatus(repo):
577 repo.ui.debug('computed skipped revs: %s\n' % skipped)
584 repo.ui.debug('computed skipped revs: %s\n' % skipped)
578 repo.ui.debug('rebase status resumed\n')
585 repo.ui.debug('rebase status resumed\n')
579 return (originalwd, target, state, skipped,
586 return (originalwd, target, state, skipped,
580 collapse, keep, keepbranches, external)
587 collapse, keep, keepbranches, external, activebookmark)
581 except IOError, err:
588 except IOError, err:
582 if err.errno != errno.ENOENT:
589 if err.errno != errno.ENOENT:
583 raise
590 raise
@@ -7,7 +7,7
7 > publish=False
7 > publish=False
8 >
8 >
9 > [alias]
9 > [alias]
10 > tglog = log -G --template "{rev}:{phase} '{desc}' {branches}\n"
10 > tglog = log -G --template "{rev}:{phase} '{desc}' {branches} {bookmarks}\n"
11 > EOF
11 > EOF
12
12
13 $ hg init a
13 $ hg init a
@@ -36,11 +36,12
36 $ echo l3 >> extra2
36 $ echo l3 >> extra2
37 $ hg add extra2
37 $ hg add extra2
38 $ hg ci -m L3
38 $ hg ci -m L3
39 $ hg bookmark mybook
39
40
40 $ hg phase --force --secret 4
41 $ hg phase --force --secret 4
41
42
42 $ hg tglog
43 $ hg tglog
43 @ 5:secret 'L3'
44 @ 5:secret 'L3' mybook
44 |
45 |
45 o 4:secret 'L2'
46 o 4:secret 'L2'
46 |
47 |
@@ -81,7 +82,7 Conclude rebase:
81 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
82 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
82
83
83 $ hg tglog
84 $ hg tglog
84 @ 5:secret 'L3'
85 @ 5:secret 'L3' mybook
85 |
86 |
86 o 4:secret 'L2'
87 o 4:secret 'L2'
87 |
88 |
@@ -118,4 +119,8 Check correctness:
118 $ hg cat -r 5 common
119 $ hg cat -r 5 common
119 resolved merge
120 resolved merge
120
121
122 Bookmark stays active after --continue
123 $ hg bookmarks
124 * mybook 5:d67b21408fc0
125
121 $ cd ..
126 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now