Show More
@@ -1064,41 +1064,7 def _histedit(ui, repo, state, *freeargs | |||||
1064 | state.write() |
|
1064 | state.write() | |
1065 | return |
|
1065 | return | |
1066 | elif goal == 'abort': |
|
1066 | elif goal == 'abort': | |
1067 | try: |
|
1067 | _abortaction(ui, repo, state) | |
1068 | state.read() |
|
|||
1069 | tmpnodes, leafs = newnodestoabort(state) |
|
|||
1070 | ui.debug('restore wc to old parent %s\n' |
|
|||
1071 | % node.short(state.topmost)) |
|
|||
1072 |
|
||||
1073 | # Recover our old commits if necessary |
|
|||
1074 | if not state.topmost in repo and state.backupfile: |
|
|||
1075 | backupfile = repo.join(state.backupfile) |
|
|||
1076 | f = hg.openpath(ui, backupfile) |
|
|||
1077 | gen = exchange.readbundle(ui, f, backupfile) |
|
|||
1078 | with repo.transaction('histedit.abort') as tr: |
|
|||
1079 | if not isinstance(gen, bundle2.unbundle20): |
|
|||
1080 | gen.apply(repo, 'histedit', 'bundle:' + backupfile) |
|
|||
1081 | if isinstance(gen, bundle2.unbundle20): |
|
|||
1082 | bundle2.applybundle(repo, gen, tr, |
|
|||
1083 | source='histedit', |
|
|||
1084 | url='bundle:' + backupfile) |
|
|||
1085 |
|
||||
1086 | os.remove(backupfile) |
|
|||
1087 |
|
||||
1088 | # check whether we should update away |
|
|||
1089 | if repo.unfiltered().revs('parents() and (%n or %ln::)', |
|
|||
1090 | state.parentctxnode, leafs | tmpnodes): |
|
|||
1091 | hg.clean(repo, state.topmost, show_stats=True, quietempty=True) |
|
|||
1092 | cleanupnode(ui, repo, 'created', tmpnodes) |
|
|||
1093 | cleanupnode(ui, repo, 'temp', leafs) |
|
|||
1094 | except Exception: |
|
|||
1095 | if state.inprogress(): |
|
|||
1096 | ui.warn(_('warning: encountered an exception during histedit ' |
|
|||
1097 | '--abort; the repository may not have been completely ' |
|
|||
1098 | 'cleaned up\n')) |
|
|||
1099 | raise |
|
|||
1100 | finally: |
|
|||
1101 | state.clear() |
|
|||
1102 | return |
|
1068 | return | |
1103 | else: |
|
1069 | else: | |
1104 | cmdutil.checkunfinished(repo) |
|
1070 | cmdutil.checkunfinished(repo) | |
@@ -1222,6 +1188,43 def _histedit(ui, repo, state, *freeargs | |||||
1222 | if repo.vfs.exists('histedit-last-edit.txt'): |
|
1188 | if repo.vfs.exists('histedit-last-edit.txt'): | |
1223 | repo.vfs.unlink('histedit-last-edit.txt') |
|
1189 | repo.vfs.unlink('histedit-last-edit.txt') | |
1224 |
|
1190 | |||
|
1191 | def _abortaction(ui, repo, state): | |||
|
1192 | try: | |||
|
1193 | state.read() | |||
|
1194 | tmpnodes, leafs = newnodestoabort(state) | |||
|
1195 | ui.debug('restore wc to old parent %s\n' | |||
|
1196 | % node.short(state.topmost)) | |||
|
1197 | ||||
|
1198 | # Recover our old commits if necessary | |||
|
1199 | if not state.topmost in repo and state.backupfile: | |||
|
1200 | backupfile = repo.join(state.backupfile) | |||
|
1201 | f = hg.openpath(ui, backupfile) | |||
|
1202 | gen = exchange.readbundle(ui, f, backupfile) | |||
|
1203 | with repo.transaction('histedit.abort') as tr: | |||
|
1204 | if not isinstance(gen, bundle2.unbundle20): | |||
|
1205 | gen.apply(repo, 'histedit', 'bundle:' + backupfile) | |||
|
1206 | if isinstance(gen, bundle2.unbundle20): | |||
|
1207 | bundle2.applybundle(repo, gen, tr, | |||
|
1208 | source='histedit', | |||
|
1209 | url='bundle:' + backupfile) | |||
|
1210 | ||||
|
1211 | os.remove(backupfile) | |||
|
1212 | ||||
|
1213 | # check whether we should update away | |||
|
1214 | if repo.unfiltered().revs('parents() and (%n or %ln::)', | |||
|
1215 | state.parentctxnode, leafs | tmpnodes): | |||
|
1216 | hg.clean(repo, state.topmost, show_stats=True, quietempty=True) | |||
|
1217 | cleanupnode(ui, repo, 'created', tmpnodes) | |||
|
1218 | cleanupnode(ui, repo, 'temp', leafs) | |||
|
1219 | except Exception: | |||
|
1220 | if state.inprogress(): | |||
|
1221 | ui.warn(_('warning: encountered an exception during histedit ' | |||
|
1222 | '--abort; the repository may not have been completely ' | |||
|
1223 | 'cleaned up\n')) | |||
|
1224 | raise | |||
|
1225 | finally: | |||
|
1226 | state.clear() | |||
|
1227 | ||||
1225 | def bootstrapcontinue(ui, state, opts): |
|
1228 | def bootstrapcontinue(ui, state, opts): | |
1226 | repo = state.repo |
|
1229 | repo = state.repo | |
1227 | if state.actions: |
|
1230 | if state.actions: |
General Comments 0
You need to be logged in to leave comments.
Login now