475 # default destination for merge. |
475 # default destination for merge. |
476 # # XXX: Currently private because I expect the signature to change. |
476 # # XXX: Currently private because I expect the signature to change. |
477 # # XXX: - taking rev as arguments, |
477 # # XXX: - taking rev as arguments, |
478 # # XXX: - bailing out in case of ambiguity vs returning all data. |
478 # # XXX: - bailing out in case of ambiguity vs returning all data. |
479 getargs(x, 0, 0, _("_mergedefaultdest takes no arguments")) |
479 getargs(x, 0, 0, _("_mergedefaultdest takes no arguments")) |
480 if repo._activebookmark: |
480 return subset & baseset([destutil.destmerge(repo)]) |
481 bmheads = repo.bookmarkheads(repo._activebookmark) |
|
482 curhead = repo[repo._activebookmark].node() |
|
483 if len(bmheads) == 2: |
|
484 if curhead == bmheads[0]: |
|
485 node = bmheads[1] |
|
486 else: |
|
487 node = bmheads[0] |
|
488 elif len(bmheads) > 2: |
|
489 raise error.Abort(_("multiple matching bookmarks to merge - " |
|
490 "please merge with an explicit rev or bookmark"), |
|
491 hint=_("run 'hg heads' to see all heads")) |
|
492 elif len(bmheads) <= 1: |
|
493 raise error.Abort(_("no matching bookmark to merge - " |
|
494 "please merge with an explicit rev or bookmark"), |
|
495 hint=_("run 'hg heads' to see all heads")) |
|
496 else: |
|
497 branch = repo[None].branch() |
|
498 bheads = repo.branchheads(branch) |
|
499 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] |
|
500 |
|
501 if len(nbhs) > 2: |
|
502 raise error.Abort(_("branch '%s' has %d heads - " |
|
503 "please merge with an explicit rev") |
|
504 % (branch, len(bheads)), |
|
505 hint=_("run 'hg heads .' to see heads")) |
|
506 |
|
507 parent = repo.dirstate.p1() |
|
508 if len(nbhs) <= 1: |
|
509 if len(bheads) > 1: |
|
510 raise error.Abort(_("heads are bookmarked - " |
|
511 "please merge with an explicit rev"), |
|
512 hint=_("run 'hg heads' to see all heads")) |
|
513 if len(repo.heads()) > 1: |
|
514 raise error.Abort(_("branch '%s' has one head - " |
|
515 "please merge with an explicit rev") |
|
516 % branch, |
|
517 hint=_("run 'hg heads' to see all heads")) |
|
518 msg, hint = _('nothing to merge'), None |
|
519 if parent != repo.lookup(branch): |
|
520 hint = _("use 'hg update' instead") |
|
521 raise error.Abort(msg, hint=hint) |
|
522 |
|
523 if parent not in bheads: |
|
524 raise error.Abort(_('working directory not at a head revision'), |
|
525 hint=_("use 'hg update' or merge with an " |
|
526 "explicit revision")) |
|
527 if parent == nbhs[0]: |
|
528 node = nbhs[-1] |
|
529 else: |
|
530 node = nbhs[0] |
|
531 return subset & baseset([repo[node].rev()]) |
|
532 |
481 |
533 def adds(repo, subset, x): |
482 def adds(repo, subset, x): |
534 """``adds(pattern)`` |
483 """``adds(pattern)`` |
535 Changesets that add a file matching pattern. |
484 Changesets that add a file matching pattern. |
536 |
485 |