Mercurial > hg
comparison mercurial/destutil.py @ 26714:9903261dcc81
destutil: move default merge destination into a function
Function in destutil are much simpler to wrap and more flexible than revset.
This also help consistency as 'destupdate' live here and cannot become a pure
revset anyway.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 15 Oct 2015 01:11:00 +0100 |
parents | 634666c48b7d |
children | 6c22a17faa18 |
comparison
equal
deleted
inserted
replaced
26713:a271925699d6 | 26714:9903261dcc81 |
---|---|
89 msg = _("not a linear update") | 89 msg = _("not a linear update") |
90 hint = _("merge or update --check to force update") | 90 hint = _("merge or update --check to force update") |
91 raise error.UpdateAbort(msg, hint=hint) | 91 raise error.UpdateAbort(msg, hint=hint) |
92 | 92 |
93 return rev, movemark, activemark | 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() |