Mercurial > hg
comparison mercurial/commands.py @ 26303:c99b4d6efdd8
merge: move default destination computation in a revset
This is another step toward having "default" destination more clear and unified.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 17 Sep 2015 14:03:15 -0700 |
parents | 5ba3358ebc7f |
children | 8c7d8d5e1e0f |
comparison
equal
deleted
inserted
replaced
26302:5ba3358ebc7f | 26303:c99b4d6efdd8 |
---|---|
4766 node = opts.get('rev') | 4766 node = opts.get('rev') |
4767 | 4767 |
4768 if node: | 4768 if node: |
4769 node = scmutil.revsingle(repo, node).node() | 4769 node = scmutil.revsingle(repo, node).node() |
4770 | 4770 |
4771 if not node and repo._activebookmark: | 4771 if not node: |
4772 bmheads = repo.bookmarkheads(repo._activebookmark) | 4772 node = scmutil.revsingle(repo, '_mergedefaultdest()').node() |
4773 curhead = repo[repo._activebookmark].node() | |
4774 if len(bmheads) == 2: | |
4775 if curhead == bmheads[0]: | |
4776 node = bmheads[1] | |
4777 else: | |
4778 node = bmheads[0] | |
4779 elif len(bmheads) > 2: | |
4780 raise util.Abort(_("multiple matching bookmarks to merge - " | |
4781 "please merge with an explicit rev or bookmark"), | |
4782 hint=_("run 'hg heads' to see all heads")) | |
4783 elif len(bmheads) <= 1: | |
4784 raise util.Abort(_("no matching bookmark to merge - " | |
4785 "please merge with an explicit rev or bookmark"), | |
4786 hint=_("run 'hg heads' to see all heads")) | |
4787 | |
4788 elif not node: | |
4789 branch = repo[None].branch() | |
4790 bheads = repo.branchheads(branch) | |
4791 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] | |
4792 | |
4793 if len(nbhs) > 2: | |
4794 raise util.Abort(_("branch '%s' has %d heads - " | |
4795 "please merge with an explicit rev") | |
4796 % (branch, len(bheads)), | |
4797 hint=_("run 'hg heads .' to see heads")) | |
4798 | |
4799 parent = repo.dirstate.p1() | |
4800 if len(nbhs) <= 1: | |
4801 if len(bheads) > 1: | |
4802 raise util.Abort(_("heads are bookmarked - " | |
4803 "please merge with an explicit rev"), | |
4804 hint=_("run 'hg heads' to see all heads")) | |
4805 if len(repo.heads()) > 1: | |
4806 raise util.Abort(_("branch '%s' has one head - " | |
4807 "please merge with an explicit rev") | |
4808 % branch, | |
4809 hint=_("run 'hg heads' to see all heads")) | |
4810 msg, hint = _('nothing to merge'), None | |
4811 if parent != repo.lookup(branch): | |
4812 hint = _("use 'hg update' instead") | |
4813 raise util.Abort(msg, hint=hint) | |
4814 | |
4815 if parent not in bheads: | |
4816 raise util.Abort(_('working directory not at a head revision'), | |
4817 hint=_("use 'hg update' or merge with an " | |
4818 "explicit revision")) | |
4819 if parent == nbhs[0]: | |
4820 node = nbhs[-1] | |
4821 else: | |
4822 node = nbhs[0] | |
4823 | 4773 |
4824 if opts.get('preview'): | 4774 if opts.get('preview'): |
4825 # find nodes that are ancestors of p2 but not of p1 | 4775 # find nodes that are ancestors of p2 but not of p1 |
4826 p1 = repo.lookup('.') | 4776 p1 = repo.lookup('.') |
4827 p2 = repo.lookup(node) | 4777 p2 = repo.lookup(node) |