mercurial/cmdutil.py
changeset 17473 9732473aa24b
parent 17472 965fbe04fd96
child 17475 63e45aee46d4
equal deleted inserted replaced
17472:965fbe04fd96 17473:9732473aa24b
  1580     try:
  1580     try:
  1581         wlock = repo.wlock()
  1581         wlock = repo.wlock()
  1582         lock = repo.lock()
  1582         lock = repo.lock()
  1583         tr = repo.transaction('amend')
  1583         tr = repo.transaction('amend')
  1584         try:
  1584         try:
       
  1585             # See if we got a message from -m or -l, if not, open the editor
       
  1586             # with the message of the changeset to amend
       
  1587             message = logmessage(ui, opts)
  1585             # First, do a regular commit to record all changes in the working
  1588             # First, do a regular commit to record all changes in the working
  1586             # directory (if there are any)
  1589             # directory (if there are any)
  1587             ui.callhooks = False
  1590             ui.callhooks = False
  1588             try:
  1591             try:
       
  1592                 opts['message'] = 'temporary amend commit for %s' % old
  1589                 node = commit(ui, repo, commitfunc, pats, opts)
  1593                 node = commit(ui, repo, commitfunc, pats, opts)
  1590             finally:
  1594             finally:
  1591                 ui.callhooks = True
  1595                 ui.callhooks = True
  1592             ctx = repo[node]
  1596             ctx = repo[node]
  1593 
  1597 
  1616             if node:
  1620             if node:
  1617                 ui.note(_('copying changeset %s to %s\n') % (ctx, base))
  1621                 ui.note(_('copying changeset %s to %s\n') % (ctx, base))
  1618 
  1622 
  1619                 user = ctx.user()
  1623                 user = ctx.user()
  1620                 date = ctx.date()
  1624                 date = ctx.date()
  1621                 message = ctx.description()
       
  1622                 # Recompute copies (avoid recording a -> b -> a)
  1625                 # Recompute copies (avoid recording a -> b -> a)
  1623                 copied = copies.pathcopies(base, ctx)
  1626                 copied = copies.pathcopies(base, ctx)
  1624 
  1627 
  1625                 # Prune files which were reverted by the updates: if old
  1628                 # Prune files which were reverted by the updates: if old
  1626                 # introduced file X and our intermediate commit, node,
  1629                 # introduced file X and our intermediate commit, node,
  1661                     try:
  1664                     try:
  1662                         return old.filectx(path)
  1665                         return old.filectx(path)
  1663                     except KeyError:
  1666                     except KeyError:
  1664                         raise IOError
  1667                         raise IOError
  1665 
  1668 
  1666                 # See if we got a message from -m or -l, if not, open the editor
       
  1667                 # with the message of the changeset to amend
       
  1668                 user = opts.get('user') or old.user()
  1669                 user = opts.get('user') or old.user()
  1669                 date = opts.get('date') or old.date()
  1670                 date = opts.get('date') or old.date()
  1670                 message = logmessage(ui, opts)
  1671             if not message:
  1671                 if not message:
  1672                 message = old.description()
  1672                     cctx = context.workingctx(repo, old.description(),
       
  1673                                               user, date, extra,
       
  1674                                               repo.status(base.node(),
       
  1675                                               old.node()))
       
  1676                     message = commitforceeditor(repo, cctx, [])
       
  1677 
  1673 
  1678             new = context.memctx(repo,
  1674             new = context.memctx(repo,
  1679                                  parents=[base.node(), nullid],
  1675                                  parents=[base.node(), nullid],
  1680                                  text=message,
  1676                                  text=message,
  1681                                  files=files,
  1677                                  files=files,
  1682                                  filectxfn=filectxfn,
  1678                                  filectxfn=filectxfn,
  1683                                  user=user,
  1679                                  user=user,
  1684                                  date=date,
  1680                                  date=date,
  1685                                  extra=extra)
  1681                                  extra=extra)
       
  1682             new._text = commitforceeditor(repo, new, [])
  1686             ph = repo.ui.config('phases', 'new-commit', phases.draft)
  1683             ph = repo.ui.config('phases', 'new-commit', phases.draft)
  1687             try:
  1684             try:
  1688                 repo.ui.setconfig('phases', 'new-commit', old.phase())
  1685                 repo.ui.setconfig('phases', 'new-commit', old.phase())
  1689                 newid = repo.commitctx(new)
  1686                 newid = repo.commitctx(new)
  1690             finally:
  1687             finally: