##// END OF EJS Templates
destutil: move default merge destination into a function...
Pierre-Yves David -
r26714:9903261d default
parent child Browse files
Show More
@@ -91,3 +91,57 b' def destupdate(repo, clean=False, check='
91 91 raise error.UpdateAbort(msg, hint=hint)
92 92
93 93 return rev, movemark, activemark
94
95 def destmerge(repo):
96 if repo._activebookmark:
97 bmheads = repo.bookmarkheads(repo._activebookmark)
98 curhead = repo[repo._activebookmark].node()
99 if len(bmheads) == 2:
100 if curhead == bmheads[0]:
101 node = bmheads[1]
102 else:
103 node = bmheads[0]
104 elif len(bmheads) > 2:
105 raise error.Abort(_("multiple matching bookmarks to merge - "
106 "please merge with an explicit rev or bookmark"),
107 hint=_("run 'hg heads' to see all heads"))
108 elif len(bmheads) <= 1:
109 raise error.Abort(_("no matching bookmark to merge - "
110 "please merge with an explicit rev or bookmark"),
111 hint=_("run 'hg heads' to see all heads"))
112 else:
113 branch = repo[None].branch()
114 bheads = repo.branchheads(branch)
115 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
116
117 if len(nbhs) > 2:
118 raise error.Abort(_("branch '%s' has %d heads - "
119 "please merge with an explicit rev")
120 % (branch, len(bheads)),
121 hint=_("run 'hg heads .' to see heads"))
122
123 parent = repo.dirstate.p1()
124 if len(nbhs) <= 1:
125 if len(bheads) > 1:
126 raise error.Abort(_("heads are bookmarked - "
127 "please merge with an explicit rev"),
128 hint=_("run 'hg heads' to see all heads"))
129 if len(repo.heads()) > 1:
130 raise error.Abort(_("branch '%s' has one head - "
131 "please merge with an explicit rev")
132 % branch,
133 hint=_("run 'hg heads' to see all heads"))
134 msg, hint = _('nothing to merge'), None
135 if parent != repo.lookup(branch):
136 hint = _("use 'hg update' instead")
137 raise error.Abort(msg, hint=hint)
138
139 if parent not in bheads:
140 raise error.Abort(_('working directory not at a head revision'),
141 hint=_("use 'hg update' or merge with an "
142 "explicit revision"))
143 if parent == nbhs[0]:
144 node = nbhs[-1]
145 else:
146 node = nbhs[0]
147 return repo[node].rev()
@@ -477,58 +477,7 b' def _mergedefaultdest(repo, subset, x):'
477 477 # # XXX: - taking rev as arguments,
478 478 # # XXX: - bailing out in case of ambiguity vs returning all data.
479 479 getargs(x, 0, 0, _("_mergedefaultdest takes no arguments"))
480 if repo._activebookmark:
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()])
480 return subset & baseset([destutil.destmerge(repo)])
532 481
533 482 def adds(repo, subset, x):
534 483 """``adds(pattern)``
General Comments 0
You need to be logged in to leave comments. Login now