comparison mercurial/cmdutil.py @ 33334:20f533a92eda

amend: use scmutil.cleanupnodes (BC) This is marked as BC because the strip backup file name has changed.
author Jun Wu <quark@fb.com>
date Mon, 26 Jun 2017 15:28:28 -0700
parents 4ecc6047d45f
children e48fb90f80c8
comparison
equal deleted inserted replaced
33333:8bfd10e4c55a 33334:20f533a92eda
35 patch, 35 patch,
36 pathutil, 36 pathutil,
37 phases, 37 phases,
38 pycompat, 38 pycompat,
39 registrar, 39 registrar,
40 repair,
41 revlog, 40 revlog,
42 revset, 41 revset,
43 scmutil, 42 scmutil,
44 smartset, 43 smartset,
45 templatekw, 44 templatekw,
2747 if obsolete.isenabled(repo, obsolete.createmarkersopt): 2746 if obsolete.isenabled(repo, obsolete.createmarkersopt):
2748 ui.username() # raise exception if username not set 2747 ui.username() # raise exception if username not set
2749 2748
2750 ui.note(_('amending changeset %s\n') % old) 2749 ui.note(_('amending changeset %s\n') % old)
2751 base = old.p1() 2750 base = old.p1()
2752 createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
2753 2751
2754 newid = None 2752 newid = None
2755 with repo.wlock(), repo.lock(): 2753 with repo.wlock(), repo.lock():
2756 with repo.transaction('amend') as tr: 2754 with repo.transaction('amend') as tr:
2757 # See if we got a message from -m or -l, if not, open the editor 2755 # See if we got a message from -m or -l, if not, open the editor
2888 finally: 2886 finally:
2889 repo.ui.setconfig('phases', 'new-commit', ph, 'amend') 2887 repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
2890 if newid != old.node(): 2888 if newid != old.node():
2891 # Reroute the working copy parent to the new changeset 2889 # Reroute the working copy parent to the new changeset
2892 repo.setparents(newid, nullid) 2890 repo.setparents(newid, nullid)
2893 2891 mapping = {old.node(): (newid,)}
2894 # Move bookmarks from old parent to amend commit 2892 if node:
2895 bms = repo.nodebookmarks(old.node()) 2893 mapping[node] = ()
2896 if bms: 2894 scmutil.cleanupnodes(repo, mapping, 'amend')
2897 marks = repo._bookmarks
2898 for bm in bms:
2899 ui.debug('moving bookmarks %r from %s to %s\n' %
2900 (marks, old.hex(), hex(newid)))
2901 marks[bm] = newid
2902 marks.recordchange(tr)
2903 #commit the whole amend process
2904 if createmarkers:
2905 # mark the new changeset as successor of the rewritten one
2906 new = repo[newid]
2907 obs = [(old, (new,))]
2908 if node:
2909 obs.append((ctx, ()))
2910
2911 obsolete.createmarkers(repo, obs, operation='amend')
2912 if not createmarkers and newid != old.node():
2913 # Strip the intermediate commit (if there was one) and the amended
2914 # commit
2915 if node:
2916 ui.note(_('stripping intermediate changeset %s\n') % ctx)
2917 ui.note(_('stripping amended changeset %s\n') % old)
2918 repair.strip(ui, repo, old.node(), topic='amend-backup')
2919 return newid 2895 return newid
2920 2896
2921 def commiteditor(repo, ctx, subs, editform=''): 2897 def commiteditor(repo, ctx, subs, editform=''):
2922 if ctx.description(): 2898 if ctx.description():
2923 return ctx.description() 2899 return ctx.description()