equal
deleted
inserted
replaced
114 for o in ( |
114 for o in ( |
115 b'date', |
115 b'date', |
116 b'user', |
116 b'user', |
117 b'log', |
117 b'log', |
118 b'no_commit', |
118 b'no_commit', |
|
119 b'dry_run', |
119 ): |
120 ): |
120 v = opts.get(o.decode('ascii')) |
121 v = opts.get(o.decode('ascii')) |
121 # if statedata is already set, it comes from --continue and test says |
122 # if statedata is already set, it comes from --continue and test says |
122 # we should honor them above the options (which seems weird). |
123 # we should honor them above the options (which seems weird). |
123 if v and o not in statedata: |
124 if v and o not in statedata: |
125 |
126 |
126 skipped = set() |
127 skipped = set() |
127 basectx = None |
128 basectx = None |
128 if opts.get('base'): |
129 if opts.get('base'): |
129 basectx = logcmdutil.revsingle(repo, opts['base'], None) |
130 basectx = logcmdutil.revsingle(repo, opts['base'], None) |
|
131 statedata[b'base'] = basectx.hex() |
130 if basectx is None: |
132 if basectx is None: |
131 # check for merges |
133 # check for merges |
132 for rev in repo.revs(b'%ld and merge()', revs): |
134 for rev in repo.revs(b'%ld and merge()', revs): |
133 ui.warn(_(b'skipping ungraftable merge revision %d\n') % rev) |
135 ui.warn(_(b'skipping ungraftable merge revision %d\n') % rev) |
134 skipped.add(rev) |
136 skipped.add(rev) |
215 ) |
217 ) |
216 revs.remove(r) |
218 revs.remove(r) |
217 if not revs: |
219 if not revs: |
218 return None |
220 return None |
219 |
221 |
220 if opts.get('base'): |
222 dry_run = bool(opts.get("dry_run")) |
221 statedata[b'base'] = opts['base'] |
223 return "GRAFT", [graftstate, statedata, revs, editor, cont, dry_run, opts] |
222 |
|
223 return "GRAFT", [graftstate, statedata, revs, editor, basectx, cont, opts] |
|
224 |
224 |
225 |
225 |
226 def _graft_revisions( |
226 def _graft_revisions( |
227 ui, |
227 ui, |
228 repo, |
228 repo, |
229 graftstate, |
229 graftstate, |
230 statedata, |
230 statedata, |
231 revs, |
231 revs, |
232 editor, |
232 editor, |
233 basectx, |
|
234 cont=False, |
233 cont=False, |
|
234 dry_run=False, |
235 opts, |
235 opts, |
236 ): |
236 ): |
237 """actually graft some revisions""" |
237 """actually graft some revisions""" |
238 for pos, ctx in enumerate(repo.set(b"%ld", revs)): |
238 for pos, ctx in enumerate(repo.set(b"%ld", revs)): |
239 desc = b'%d:%s "%s"' % ( |
239 desc = b'%d:%s "%s"' % ( |
243 ) |
243 ) |
244 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
244 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
245 if names: |
245 if names: |
246 desc += b' (%s)' % b' '.join(names) |
246 desc += b' (%s)' % b' '.join(names) |
247 ui.status(_(b'grafting %s\n') % desc) |
247 ui.status(_(b'grafting %s\n') % desc) |
248 if opts.get('dry_run'): |
248 if dry_run: |
249 continue |
249 continue |
250 |
250 |
251 source = ctx.extra().get(b'source') |
251 source = ctx.extra().get(b'source') |
252 extra = {} |
252 extra = {} |
253 if source: |
253 if source: |
263 |
263 |
264 # we don't merge the first commit when continuing |
264 # we don't merge the first commit when continuing |
265 if not cont: |
265 if not cont: |
266 # perform the graft merge with p1(rev) as 'ancestor' |
266 # perform the graft merge with p1(rev) as 'ancestor' |
267 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')} |
267 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')} |
268 base = ctx.p1() if basectx is None else basectx |
268 if b'base' in statedata: |
|
269 base = repo[statedata[b'base']] |
|
270 else: |
|
271 base = ctx.p1() |
269 with ui.configoverride(overrides, b'graft'): |
272 with ui.configoverride(overrides, b'graft'): |
270 stats = mergemod.graft( |
273 stats = mergemod.graft( |
271 repo, ctx, base, [b'local', b'graft', b'parent of graft'] |
274 repo, ctx, base, [b'local', b'graft', b'parent of graft'] |
272 ) |
275 ) |
273 # report any conflicts |
276 # report any conflicts |
298 nn = statedata[b'newnodes'] |
301 nn = statedata[b'newnodes'] |
299 assert isinstance(nn, list) # list of bytes |
302 assert isinstance(nn, list) # list of bytes |
300 nn.append(node) |
303 nn.append(node) |
301 |
304 |
302 # remove state when we complete successfully |
305 # remove state when we complete successfully |
303 if not opts.get('dry_run'): |
306 if not dry_run: |
304 graftstate.delete() |
307 graftstate.delete() |
305 |
308 |
306 return 0 |
309 return 0 |
307 |
310 |
308 |
311 |