hgext/histedit.py
changeset 24767 477e76936b1d
parent 24766 cfb8f5e3ca49
child 24768 342671704344
equal deleted inserted replaced
24766:cfb8f5e3ca49 24767:477e76936b1d
   485                          date=date,
   485                          date=date,
   486                          extra=extra,
   486                          extra=extra,
   487                          editor=editor)
   487                          editor=editor)
   488     return repo.commitctx(new)
   488     return repo.commitctx(new)
   489 
   489 
   490 def pick(ui, state, ha, opts):
   490 class pick(histeditaction):
   491     repo, ctxnode = state.repo, state.parentctxnode
   491     def run(self):
   492     ctx = repo[ctxnode]
   492         rulectx = self.repo[self.node]
   493     oldctx = repo[ha]
   493         if rulectx.parents()[0].node() == self.state.parentctxnode:
   494     if oldctx.parents()[0] == ctx:
   494             self.repo.ui.debug('node %s unchanged\n' % node.short(self.node))
   495         ui.debug('node %s unchanged\n' % ha[:12])
   495             return rulectx, []
   496         return oldctx, []
   496 
   497     hg.update(repo, ctx.node())
   497         return super(pick, self).run()
   498     stats = applychanges(ui, repo, oldctx, opts)
       
   499     if stats and stats[3] > 0:
       
   500         raise error.InterventionRequired(_('Fix up the change and run '
       
   501                                            'hg histedit --continue'))
       
   502     # drop the second merge parent
       
   503     commit = commitfuncfor(repo, oldctx)
       
   504     n = commit(text=oldctx.description(), user=oldctx.user(),
       
   505                date=oldctx.date(), extra=oldctx.extra())
       
   506     if n is None:
       
   507         ui.warn(_('%s: empty changeset\n') % ha[:12])
       
   508         return ctx, []
       
   509     new = repo[n]
       
   510     return new, [(oldctx.node(), (n,))]
       
   511 
       
   512 
   498 
   513 def edit(ui, state, ha, opts):
   499 def edit(ui, state, ha, opts):
   514     repo, ctxnode = state.repo, state.parentctxnode
   500     repo, ctxnode = state.repo, state.parentctxnode
   515     ctx = repo[ctxnode]
   501     ctx = repo[ctxnode]
   516     oldctx = repo[ha]
   502     oldctx = repo[ha]
   937             if action in ('f', 'fold', 'r', 'roll'):
   923             if action in ('f', 'fold', 'r', 'roll'):
   938                 message = 'fold-temp-revision %s' % currentnode[:12]
   924                 message = 'fold-temp-revision %s' % currentnode[:12]
   939             else:
   925             else:
   940                 message = ctx.description()
   926                 message = ctx.description()
   941             editopt = action in ('e', 'edit', 'm', 'mess')
   927             editopt = action in ('e', 'edit', 'm', 'mess')
   942             canonaction = {'e': 'edit', 'm': 'mess', 'p': 'pick'}
   928             canonaction = {'e': 'edit', 'm': 'mess'}
   943             editform = 'histedit.%s' % canonaction.get(action, action)
   929             editform = 'histedit.%s' % canonaction.get(action, action)
   944             editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
   930             editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
   945             commit = commitfuncfor(repo, ctx)
   931             commit = commitfuncfor(repo, ctx)
   946             new = commit(text=message, user=ctx.user(), date=ctx.date(),
   932             new = commit(text=message, user=ctx.user(), date=ctx.date(),
   947                          extra=ctx.extra(), editor=editor)
   933                          extra=ctx.extra(), editor=editor)