##// END OF EJS Templates
histedit: convert fold/roll actions into a class...
Durham Goode -
r24771:3133e246 default
parent child Browse files
Show More
@@ -510,26 +510,47 b' class edit(histeditaction):'
510 def commiteditor(self):
510 def commiteditor(self):
511 return cmdutil.getcommiteditor(edit=True, editform='histedit.edit')
511 return cmdutil.getcommiteditor(edit=True, editform='histedit.edit')
512
512
513 def rollup(ui, state, ha, opts):
513 class fold(histeditaction):
514 rollupopts = opts.copy()
514 def continuedirty(self):
515 rollupopts['rollup'] = True
515 repo = self.repo
516 return fold(ui, state, ha, rollupopts)
516 rulectx = repo[self.node]
517
518 commit = commitfuncfor(repo, rulectx)
519 commit(text='fold-temp-revision %s' % node.short(self.node),
520 user=rulectx.user(), date=rulectx.date(),
521 extra=rulectx.extra())
522
523 def continueclean(self):
524 repo = self.repo
525 ctx = repo['.']
526 rulectx = repo[self.node]
527 parentctxnode = self.state.parentctxnode
528 if ctx.node() == parentctxnode:
529 repo.ui.warn(_('%s: empty changeset\n') %
530 node.short(self.node))
531 return ctx, [(self.node, (parentctxnode,))]
517
532
518 def fold(ui, state, ha, opts):
533 parentctx = repo[parentctxnode]
519 repo, ctxnode = state.repo, state.parentctxnode
534 newcommits = set(c.node() for c in repo.set('(%d::. - %d)', parentctx,
520 ctx = repo[ctxnode]
535 parentctx))
521 oldctx = repo[ha]
536 if not newcommits:
522 hg.update(repo, ctx.node())
537 repo.ui.warn(_('%s: cannot fold - working copy is not a '
523 stats = applychanges(ui, repo, oldctx, opts)
538 'descendant of previous commit %s\n') %
524 if stats and stats[3] > 0:
539 (node.short(self.node), node.short(parentctxnode)))
525 raise error.InterventionRequired(
540 return ctx, [(self.node, (ctx.node(),))]
526 _('Fix up the change and run hg histedit --continue'))
541
527 n = repo.commit(text='fold-temp-revision %s' % ha[:12], user=oldctx.user(),
542 middlecommits = newcommits.copy()
528 date=oldctx.date(), extra=oldctx.extra())
543 middlecommits.discard(ctx.node())
529 if n is None:
544
530 ui.warn(_('%s: empty changeset') % ha[:12])
545 foldopts = {}
531 return ctx, []
546 if isinstance(self, rollup):
532 return finishfold(ui, repo, ctx, oldctx, n, opts, [])
547 foldopts['rollup'] = True
548
549 return finishfold(repo.ui, repo, parentctx, rulectx, ctx.node(),
550 foldopts, middlecommits)
551
552 class rollup(fold):
553 pass
533
554
534 def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
555 def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
535 parent = ctx.parents()[0].node()
556 parent = ctx.parents()[0].node()
@@ -907,10 +928,7 b' def bootstrapcontinue(ui, state, opts):'
907 new = None
928 new = None
908 if s.modified or s.added or s.removed or s.deleted:
929 if s.modified or s.added or s.removed or s.deleted:
909 # prepare the message for the commit to comes
930 # prepare the message for the commit to comes
910 if action in ('f', 'fold', 'r', 'roll'):
931 message = ctx.description()
911 message = 'fold-temp-revision %s' % currentnode[:12]
912 else:
913 message = ctx.description()
914 editor = cmdutil.getcommiteditor()
932 editor = cmdutil.getcommiteditor()
915 commit = commitfuncfor(repo, ctx)
933 commit = commitfuncfor(repo, ctx)
916 new = commit(text=message, user=ctx.user(), date=ctx.date(),
934 new = commit(text=message, user=ctx.user(), date=ctx.date(),
@@ -925,26 +943,7 b' def bootstrapcontinue(ui, state, opts):'
925 # to parent.
943 # to parent.
926 replacements.append((ctx.node(), tuple(newchildren)))
944 replacements.append((ctx.node(), tuple(newchildren)))
927
945
928 if action in ('f', 'fold', 'r', 'roll'):
946 if newchildren:
929 if newchildren:
930 # finalize fold operation if applicable
931 if new is None:
932 new = newchildren[-1]
933 else:
934 newchildren.pop() # remove new from internal changes
935 foldopts = opts
936 if action in ('r', 'roll'):
937 foldopts = foldopts.copy()
938 foldopts['rollup'] = True
939 parentctx, repl = finishfold(ui, repo, parentctx, ctx, new,
940 foldopts, newchildren)
941 replacements.extend(repl)
942 else:
943 # newchildren is empty if the fold did not result in any commit
944 # this happen when all folded change are discarded during the
945 # merge.
946 replacements.append((ctx.node(), (parentctx.node(),)))
947 elif newchildren:
948 # otherwise update "parentctx" before proceeding further
947 # otherwise update "parentctx" before proceeding further
949 parentctx = repo[newchildren[-1]]
948 parentctx = repo[newchildren[-1]]
950
949
@@ -92,7 +92,7 b''
92 histedit: moving bookmarks two from 177f92b77385 to b346ab9a313d
92 histedit: moving bookmarks two from 177f92b77385 to b346ab9a313d
93 histedit: moving bookmarks will-move-backwards from d2ae7f538514 to cb9a9f314b8b
93 histedit: moving bookmarks will-move-backwards from d2ae7f538514 to cb9a9f314b8b
94 saved backup bundle to $TESTTMP/r/.hg/strip-backup/d2ae7f538514-48787b8d-backup.hg (glob)
94 saved backup bundle to $TESTTMP/r/.hg/strip-backup/d2ae7f538514-48787b8d-backup.hg (glob)
95 saved backup bundle to $TESTTMP/r/.hg/strip-backup/96e494a2d553-60cea58b-backup.hg (glob)
95 saved backup bundle to $TESTTMP/r/.hg/strip-backup/96e494a2d553-3c6c5d92-backup.hg (glob)
96 $ hg log --graph
96 $ hg log --graph
97 @ changeset: 3:cacdfd884a93
97 @ changeset: 3:cacdfd884a93
98 | bookmark: five
98 | bookmark: five
@@ -307,6 +307,7 b' should effectively drop the changes from'
307 $ hg resolve --mark file
307 $ hg resolve --mark file
308 (no more unresolved files)
308 (no more unresolved files)
309 $ hg histedit --continue
309 $ hg histedit --continue
310 251d831eeec5: empty changeset
310 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
311 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
311 saved backup bundle to $TESTTMP/*-backup.hg (glob)
312 saved backup bundle to $TESTTMP/*-backup.hg (glob)
312 $ hg logt --graph
313 $ hg logt --graph
@@ -64,7 +64,7 b' Enable obsolete'
64 > fold e860deea161a 4 e
64 > fold e860deea161a 4 e
65 > pick 652413bf663e 5 f
65 > pick 652413bf663e 5 f
66 > EOF
66 > EOF
67 saved backup bundle to $TESTTMP/base/.hg/strip-backup/96e494a2d553-60cea58b-backup.hg (glob)
67 saved backup bundle to $TESTTMP/base/.hg/strip-backup/96e494a2d553-3c6c5d92-backup.hg (glob)
68 $ hg log --graph --hidden
68 $ hg log --graph --hidden
69 @ 8:cacdfd884a93 f
69 @ 8:cacdfd884a93 f
70 |
70 |
@@ -427,9 +427,9 b' Note that there is a few reordering in t'
427 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
427 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
428 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
428 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
429 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
429 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
430 saved backup bundle to $TESTTMP/folding/.hg/strip-backup/58019c66f35f-be4b3835-backup.hg (glob)
430 saved backup bundle to $TESTTMP/folding/.hg/strip-backup/58019c66f35f-96092fce-backup.hg (glob)
431 saved backup bundle to $TESTTMP/folding/.hg/strip-backup/83d1858e070b-08306a6b-backup.hg (glob)
431 saved backup bundle to $TESTTMP/folding/.hg/strip-backup/83d1858e070b-f3469cf8-backup.hg (glob)
432 saved backup bundle to $TESTTMP/folding/.hg/strip-backup/859969f5ed7e-86c99c41-backup.hg (glob)
432 saved backup bundle to $TESTTMP/folding/.hg/strip-backup/859969f5ed7e-d89a19d7-backup.hg (glob)
433 $ hg log -G
433 $ hg log -G
434 @ 19:f9daec13fb98 (secret) i
434 @ 19:f9daec13fb98 (secret) i
435 |
435 |
General Comments 0
You need to be logged in to leave comments. Login now