hgext/evolution.py
changeset 118 06fe05256a79
parent 117 438fe133b068
child 119 22f2b700bd59
equal deleted inserted replaced
117:438fe133b068 118:06fe05256a79
    88         elif commitopts.get('message'):
    88         elif commitopts.get('message'):
    89             message = commitopts['message']
    89             message = commitopts['message']
    90         else:
    90         else:
    91             message = old.description()
    91             message = old.description()
    92 
    92 
       
    93 
       
    94 
    93         new = context.memctx(repo,
    95         new = context.memctx(repo,
    94                              parents=newbases,
    96                              parents=newbases,
    95                              text=message,
    97                              text=message,
    96                              files=files,
    98                              files=files,
    97                              filectxfn=filectxfn,
    99                              filectxfn=filectxfn,
    98                              user=commitopts.get('user') or None,
   100                              user=commitopts.get('user') or None,
    99                              date=commitopts.get('date') or None,
   101                              date=commitopts.get('date') or None,
   100                              extra=commitopts.get('extra') or None)
   102                              extra=commitopts.get('extra') or None)
       
   103 
       
   104         if commitopts.get('edit'):
       
   105             new._text = cmdutil.commitforceeditor(repo, new, [])
   101         newid = repo.commitctx(new)
   106         newid = repo.commitctx(new)
   102         new = repo[newid]
   107         new = repo[newid]
   103 
   108 
   104         # update the bookmark
   109         # update the bookmark
   105         if bm:
   110         if bm:
   274         ciopts = dict(opts)
   279         ciopts = dict(opts)
   275         ciopts.pop('message', None)
   280         ciopts.pop('message', None)
   276         ciopts.pop('logfile', None)
   281         ciopts.pop('logfile', None)
   277         ciopts['message'] = opts.get('note') or ('amends %s' % old.hex())
   282         ciopts['message'] = opts.get('note') or ('amends %s' % old.hex())
   278         e = cmdutil.commiteditor
   283         e = cmdutil.commiteditor
   279         if ciopts.get('edit'):
       
   280             e = cmdutil.commitforceeditor
       
   281         def commitfunc(ui, repo, message, match, opts):
   284         def commitfunc(ui, repo, message, match, opts):
   282             return repo.commit(message, opts.get('user'), opts.get('date'), match,
   285             return repo.commit(message, opts.get('user'), opts.get('date'), match,
   283                                editor=e)
   286                                editor=e)
   284         cmdutil.commit(ui, repo, commitfunc, pats, ciopts)
   287         cmdutil.commit(ui, repo, commitfunc, pats, ciopts)
   285 
   288 
   287         cl = repo.changelog
   290         cl = repo.changelog
   288         head = repo['.']
   291         head = repo['.']
   289         updatenodes = set(cl.nodesbetween(roots=[old.node()],
   292         updatenodes = set(cl.nodesbetween(roots=[old.node()],
   290                                           heads=[head.node()])[0])
   293                                           heads=[head.node()])[0])
   291         updatenodes.remove(old.node())
   294         updatenodes.remove(old.node())
   292         if not updatenodes and not (opts.get('message') or opts.get('logfile')):
   295         if not updatenodes and not (opts.get('message') or opts.get('logfile') or opts.get('edit')):
   293             raise error.Abort(_('no updates found'))
   296             raise error.Abort(_('no updates found'))
   294         updates = [repo[n] for n in updatenodes]
   297         updates = [repo[n] for n in updatenodes]
   295 
   298 
   296         # perform amend
   299         # perform amend
       
   300         if opts.get('edit'):
       
   301             opts['force_editor'] = True
   297         newid = rewrite(repo, old, updates, head,
   302         newid = rewrite(repo, old, updates, head,
   298                         [old.p1().node(), old.p2().node()], opts)
   303                         [old.p1().node(), old.p2().node()], opts)
   299 
   304 
   300         # reroute the working copy parent to the new changeset
   305         # reroute the working copy parent to the new changeset
   301         phases.retractboundary(repo, old.phase(), [newid])
   306         phases.retractboundary(repo, old.phase(), [newid])