##// END OF EJS Templates
histedit: move outgoing processing to its own function...
Pierre-Yves David -
r19021:26b41a90 default
parent child Browse files
Show More
@@ -404,6 +404,29 b' def message(ui, repo, ctx, ha, opts):'
404 404 # We didn't make an edit, so just indicate no replaced nodes
405 405 return newctx, []
406 406
407 def findoutgoing(ui, repo, remote=None, force=False, opts={}):
408 """utility function to find the first outgoing changeset
409
410 Used by initialisation code"""
411 dest = ui.expandpath(remote or 'default-push', remote or 'default')
412 dest, revs = hg.parseurl(dest, None)[:2]
413 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
414
415 revs, checkout = hg.addbranchrevs(repo, repo, revs, None)
416 other = hg.peer(repo, opts, dest)
417
418 if revs:
419 revs = [repo.lookup(rev) for rev in revs]
420
421 # hexlify nodes from outgoing, because we're going to parse
422 # parent[0] using revsingle below, and if the binary hash
423 # contains special revset characters like ":" the revset
424 # parser can choke.
425 outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
426 if not outgoing.missing:
427 raise util.Abort(_('no outgoing ancestors'))
428 return outgoing.missing[0]
429
407 430 actiontable = {'p': pick,
408 431 'pick': pick,
409 432 'e': edit,
@@ -466,33 +489,11 b' def histedit(ui, repo, *freeargs, **opts'
466 489 raise util.Abort(
467 490 _('only one repo argument allowed with --outgoing'))
468 491 else:
469 parent = list(freeargs) + opts.get('rev', [])
470 if len(parent) != 1:
492 revs.extend(freeargs)
493 if len(revs) != 1:
471 494 raise util.Abort(
472 495 _('histedit requires exactly one parent revision'))
473 496
474 if opts.get('outgoing'):
475 if freeargs:
476 parent = freeargs[0]
477
478 dest = ui.expandpath(parent or 'default-push', parent or 'default')
479 dest, revs = hg.parseurl(dest, None)[:2]
480 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
481
482 revs, checkout = hg.addbranchrevs(repo, repo, revs, None)
483 other = hg.peer(repo, opts, dest)
484
485 if revs:
486 revs = [repo.lookup(rev) for rev in revs]
487
488 # hexlify nodes from outgoing, because we're going to parse
489 # parent[0] using revsingle below, and if the binary hash
490 # contains special revset characters like ":" the revset
491 # parser can choke.
492 parent = [node.hex(n) for n in discovery.findcommonoutgoing(
493 repo, other, revs, force=force).missing[0:1]]
494 if not parent:
495 raise util.Abort(_('no outgoing ancestors'))
496 497
497 498 if goal == 'continue':
498 499 (parentctxnode, rules, keep, topmost, replacements) = readstate(repo)
@@ -513,20 +514,27 b' def histedit(ui, repo, *freeargs, **opts'
513 514 cmdutil.bailifchanged(repo)
514 515
515 516 topmost, empty = repo.dirstate.parents()
516
517 parent = scmutil.revsingle(repo, parent[0]).node()
517 if outg:
518 if freeargs:
519 remote = freeargs[0]
520 else:
521 remote = None
522 root = findoutgoing(ui, repo, remote, force, opts)
523 else:
524 root = revs[0]
525 root = scmutil.revsingle(repo, root).node()
518 526
519 527 keep = opts.get('keep', False)
520 revs = between(repo, parent, topmost, keep)
528 revs = between(repo, root, topmost, keep)
521 529 if not revs:
522 530 raise util.Abort(_('%s is not an ancestor of working directory') %
523 node.short(parent))
531 node.short(root))
524 532
525 533 ctxs = [repo[r] for r in revs]
526 534 if not rules:
527 535 rules = '\n'.join([makedesc(c) for c in ctxs])
528 536 rules += '\n\n'
529 rules += editcomment % (node.short(parent), node.short(topmost))
537 rules += editcomment % (node.short(root), node.short(topmost))
530 538 rules = ui.edit(rules, ui.username())
531 539 # Save edit rules in .hg/histedit-last-edit.txt in case
532 540 # the user needs to ask for help after something
@@ -545,7 +553,7 b' def histedit(ui, repo, *freeargs, **opts'
545 553 if l and not l[0] == '#']
546 554 rules = verifyrules(rules, repo, ctxs)
547 555
548 parentctx = repo[parent].parents()[0]
556 parentctx = repo[root].parents()[0]
549 557 keep = opts.get('keep', False)
550 558 replacements = []
551 559
General Comments 0
You need to be logged in to leave comments. Login now