##// END OF EJS Templates
histedit: move all arguments checks to the beginning of the command...
Pierre-Yves David -
r19020:12c06686 default
parent child Browse files
Show More
@@ -428,7 +428,7 b" actiontable = {'p': pick,"
428 _('force outgoing even for unrelated repositories')),
428 _('force outgoing even for unrelated repositories')),
429 ('r', 'rev', [], _('first revision to be edited'))],
429 ('r', 'rev', [], _('first revision to be edited'))],
430 _("[PARENT]"))
430 _("[PARENT]"))
431 def histedit(ui, repo, *parent, **opts):
431 def histedit(ui, repo, *freeargs, **opts):
432 """interactively edit changeset history
432 """interactively edit changeset history
433 """
433 """
434 # TODO only abort if we try and histedit mq patches, not just
434 # TODO only abort if we try and histedit mq patches, not just
@@ -437,13 +437,43 b' def histedit(ui, repo, *parent, **opts):'
437 if mq and mq.applied:
437 if mq and mq.applied:
438 raise util.Abort(_('source has mq patches applied'))
438 raise util.Abort(_('source has mq patches applied'))
439
439
440 parent = list(parent) + opts.get('rev', [])
440 # basic argument incompatibility processing
441 outg = opts.get('outgoing')
442 cont = opts.get('continue')
443 abort = opts.get('abort')
444 force = opts.get('force')
445 rules = opts.get('commands', '')
446 revs = opts.get('rev', [])
447 goal = 'new' # This invocation goal, in new, continue, abort
448 if force and not outg:
449 raise util.Abort(_('--force only allowed with --outgoing'))
450 if cont:
451 if util.any((outg, abort, revs, freeargs, rules)):
452 raise util.Abort(_('no arguments allowed with --continue'))
453 goal = 'continue'
454 elif abort:
455 if util.any((outg, revs, freeargs, rules)):
456 raise util.Abort(_('no arguments allowed with --abort'))
457 goal = 'abort'
458 else:
459 if os.path.exists(os.path.join(repo.path, 'histedit-state')):
460 raise util.Abort(_('history edit already in progress, try '
461 '--continue or --abort'))
462 if outg:
463 if revs:
464 raise util.Abort(_('no revisions allowed with --outgoing'))
465 if len(freeargs) > 1:
466 raise util.Abort(
467 _('only one repo argument allowed with --outgoing'))
468 else:
469 parent = list(freeargs) + opts.get('rev', [])
470 if len(parent) != 1:
471 raise util.Abort(
472 _('histedit requires exactly one parent revision'))
473
441 if opts.get('outgoing'):
474 if opts.get('outgoing'):
442 if len(parent) > 1:
475 if freeargs:
443 raise util.Abort(
476 parent = freeargs[0]
444 _('only one repo argument allowed with --outgoing'))
445 elif parent:
446 parent = parent[0]
447
477
448 dest = ui.expandpath(parent or 'default-push', parent or 'default')
478 dest = ui.expandpath(parent or 'default-push', parent or 'default')
449 dest, revs = hg.parseurl(dest, None)[:2]
479 dest, revs = hg.parseurl(dest, None)[:2]
@@ -460,22 +490,17 b' def histedit(ui, repo, *parent, **opts):'
460 # contains special revset characters like ":" the revset
490 # contains special revset characters like ":" the revset
461 # parser can choke.
491 # parser can choke.
462 parent = [node.hex(n) for n in discovery.findcommonoutgoing(
492 parent = [node.hex(n) for n in discovery.findcommonoutgoing(
463 repo, other, revs, force=opts.get('force')).missing[0:1]]
493 repo, other, revs, force=force).missing[0:1]]
464 else:
494 if not parent:
465 if opts.get('force'):
495 raise util.Abort(_('no outgoing ancestors'))
466 raise util.Abort(_('--force only allowed with --outgoing'))
467
496
468 if opts.get('continue', False):
497 if goal == 'continue':
469 if len(parent) != 0:
470 raise util.Abort(_('no arguments allowed with --continue'))
471 (parentctxnode, rules, keep, topmost, replacements) = readstate(repo)
498 (parentctxnode, rules, keep, topmost, replacements) = readstate(repo)
472 currentparent, wantnull = repo.dirstate.parents()
499 currentparent, wantnull = repo.dirstate.parents()
473 parentctx = repo[parentctxnode]
500 parentctx = repo[parentctxnode]
474 parentctx, repl = bootstrapcontinue(ui, repo, parentctx, rules, opts)
501 parentctx, repl = bootstrapcontinue(ui, repo, parentctx, rules, opts)
475 replacements.extend(repl)
502 replacements.extend(repl)
476 elif opts.get('abort', False):
503 elif goal == 'abort':
477 if len(parent) != 0:
478 raise util.Abort(_('no arguments allowed with --abort'))
479 (parentctxnode, rules, keep, topmost, replacements) = readstate(repo)
504 (parentctxnode, rules, keep, topmost, replacements) = readstate(repo)
480 mapping, tmpnodes, leafs, _ntm = processreplacement(repo, replacements)
505 mapping, tmpnodes, leafs, _ntm = processreplacement(repo, replacements)
481 ui.debug('restore wc to old parent %s\n' % node.short(topmost))
506 ui.debug('restore wc to old parent %s\n' % node.short(topmost))
@@ -486,14 +511,9 b' def histedit(ui, repo, *parent, **opts):'
486 return
511 return
487 else:
512 else:
488 cmdutil.bailifchanged(repo)
513 cmdutil.bailifchanged(repo)
489 if os.path.exists(os.path.join(repo.path, 'histedit-state')):
490 raise util.Abort(_('history edit already in progress, try '
491 '--continue or --abort'))
492
514
493 topmost, empty = repo.dirstate.parents()
515 topmost, empty = repo.dirstate.parents()
494
516
495 if len(parent) != 1:
496 raise util.Abort(_('histedit requires exactly one parent revision'))
497 parent = scmutil.revsingle(repo, parent[0]).node()
517 parent = scmutil.revsingle(repo, parent[0]).node()
498
518
499 keep = opts.get('keep', False)
519 keep = opts.get('keep', False)
@@ -503,7 +523,6 b' def histedit(ui, repo, *parent, **opts):'
503 node.short(parent))
523 node.short(parent))
504
524
505 ctxs = [repo[r] for r in revs]
525 ctxs = [repo[r] for r in revs]
506 rules = opts.get('commands', '')
507 if not rules:
526 if not rules:
508 rules = '\n'.join([makedesc(c) for c in ctxs])
527 rules = '\n'.join([makedesc(c) for c in ctxs])
509 rules += '\n\n'
528 rules += '\n\n'
@@ -240,7 +240,7 b' edit the history, this time with a fold '
240
240
241 $ echo 'I can haz no commute' > e
241 $ echo 'I can haz no commute' > e
242 $ hg resolve --mark e
242 $ hg resolve --mark e
243 $ hg histedit --commands $EDITED --continue 2>&1 | fixbundle
243 $ hg histedit --continue 2>&1 | fixbundle
244 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
244 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
245 merging e
245 merging e
246 warning: conflicts during merge.
246 warning: conflicts during merge.
General Comments 0
You need to be logged in to leave comments. Login now