##// END OF EJS Templates
histedit: integrate action class into flow...
Durham Goode -
r24766:cfb8f5e3 default
parent child Browse files
Show More
@@ -157,6 +157,7 b' try:'
157 except ImportError:
157 except ImportError:
158 import pickle
158 import pickle
159 import errno
159 import errno
160 import inspect
160 import os
161 import os
161 import sys
162 import sys
162
163
@@ -849,8 +850,12 b' def _histedit(ui, repo, state, *freeargs'
849 state.write()
850 state.write()
850 action, ha = state.rules.pop(0)
851 action, ha = state.rules.pop(0)
851 ui.debug('histedit: processing %s %s\n' % (action, ha[:12]))
852 ui.debug('histedit: processing %s %s\n' % (action, ha[:12]))
852 actfunc = actiontable[action]
853 act = actiontable[action]
853 parentctx, replacement_ = actfunc(ui, state, ha, opts)
854 if inspect.isclass(act):
855 actobj = act.fromrule(state, ha)
856 parentctx, replacement_ = actobj.run()
857 else:
858 parentctx, replacement_ = act(ui, state, ha, opts)
854 state.parentctxnode = parentctx.node()
859 state.parentctxnode = parentctx.node()
855 state.replacements.extend(replacement_)
860 state.replacements.extend(replacement_)
856 state.write()
861 state.write()
@@ -905,61 +910,73 b' def gatherchildren(repo, ctx):'
905
910
906 def bootstrapcontinue(ui, state, opts):
911 def bootstrapcontinue(ui, state, opts):
907 repo, parentctxnode = state.repo, state.parentctxnode
912 repo, parentctxnode = state.repo, state.parentctxnode
908 parentctx = repo[parentctxnode]
909 action, currentnode = state.rules.pop(0)
913 action, currentnode = state.rules.pop(0)
910 ctx = repo[currentnode]
911
914
912 newchildren = gatherchildren(repo, parentctx)
913
914 # Commit dirty working directory if necessary
915 new = None
916 s = repo.status()
915 s = repo.status()
917 if s.modified or s.added or s.removed or s.deleted:
918 # prepare the message for the commit to comes
919 if action in ('f', 'fold', 'r', 'roll'):
920 message = 'fold-temp-revision %s' % currentnode[:12]
921 else:
922 message = ctx.description()
923 editopt = action in ('e', 'edit', 'm', 'mess')
924 canonaction = {'e': 'edit', 'm': 'mess', 'p': 'pick'}
925 editform = 'histedit.%s' % canonaction.get(action, action)
926 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
927 commit = commitfuncfor(repo, ctx)
928 new = commit(text=message, user=ctx.user(), date=ctx.date(),
929 extra=ctx.extra(), editor=editor)
930 if new is not None:
931 newchildren.append(new)
932
933 replacements = []
916 replacements = []
934 # track replacements
917
935 if ctx.node() not in newchildren:
918 act = actiontable[action]
936 # note: new children may be empty when the changeset is dropped.
919 if inspect.isclass(act):
937 # this happen e.g during conflicting pick where we revert content
920 actobj = act.fromrule(state, currentnode)
938 # to parent.
921 if s.modified or s.added or s.removed or s.deleted:
939 replacements.append((ctx.node(), tuple(newchildren)))
922 actobj.continuedirty()
923 s = repo.status()
924 if s.modified or s.added or s.removed or s.deleted:
925 raise util.Abort(_("working copy still dirty"))
940
926
941 if action in ('f', 'fold', 'r', 'roll'):
927 parentctx, replacements_ = actobj.continueclean()
942 if newchildren:
928 replacements.extend(replacements_)
943 # finalize fold operation if applicable
929 else:
944 if new is None:
930 parentctx = repo[parentctxnode]
945 new = newchildren[-1]
931 ctx = repo[currentnode]
932 newchildren = gatherchildren(repo, parentctx)
933 # Commit dirty working directory if necessary
934 new = None
935 if s.modified or s.added or s.removed or s.deleted:
936 # prepare the message for the commit to comes
937 if action in ('f', 'fold', 'r', 'roll'):
938 message = 'fold-temp-revision %s' % currentnode[:12]
946 else:
939 else:
947 newchildren.pop() # remove new from internal changes
940 message = ctx.description()
948 foldopts = opts
941 editopt = action in ('e', 'edit', 'm', 'mess')
949 if action in ('r', 'roll'):
942 canonaction = {'e': 'edit', 'm': 'mess', 'p': 'pick'}
950 foldopts = foldopts.copy()
943 editform = 'histedit.%s' % canonaction.get(action, action)
951 foldopts['rollup'] = True
944 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
952 parentctx, repl = finishfold(ui, repo, parentctx, ctx, new,
945 commit = commitfuncfor(repo, ctx)
953 foldopts, newchildren)
946 new = commit(text=message, user=ctx.user(), date=ctx.date(),
954 replacements.extend(repl)
947 extra=ctx.extra(), editor=editor)
955 else:
948 if new is not None:
956 # newchildren is empty if the fold did not result in any commit
949 newchildren.append(new)
957 # this happen when all folded change are discarded during the
950
958 # merge.
951 # track replacements
959 replacements.append((ctx.node(), (parentctx.node(),)))
952 if ctx.node() not in newchildren:
960 elif newchildren:
953 # note: new children may be empty when the changeset is dropped.
961 # otherwise update "parentctx" before proceeding to further operation
954 # this happen e.g during conflicting pick where we revert content
962 parentctx = repo[newchildren[-1]]
955 # to parent.
956 replacements.append((ctx.node(), tuple(newchildren)))
957
958 if action in ('f', 'fold', 'r', 'roll'):
959 if newchildren:
960 # finalize fold operation if applicable
961 if new is None:
962 new = newchildren[-1]
963 else:
964 newchildren.pop() # remove new from internal changes
965 foldopts = opts
966 if action in ('r', 'roll'):
967 foldopts = foldopts.copy()
968 foldopts['rollup'] = True
969 parentctx, repl = finishfold(ui, repo, parentctx, ctx, new,
970 foldopts, newchildren)
971 replacements.extend(repl)
972 else:
973 # newchildren is empty if the fold did not result in any commit
974 # this happen when all folded change are discarded during the
975 # merge.
976 replacements.append((ctx.node(), (parentctx.node(),)))
977 elif newchildren:
978 # otherwise update "parentctx" before proceeding further
979 parentctx = repo[newchildren[-1]]
963
980
964 state.parentctxnode = parentctx.node()
981 state.parentctxnode = parentctx.node()
965 state.replacements.extend(replacements)
982 state.replacements.extend(replacements)
General Comments 0
You need to be logged in to leave comments. Login now