##// END OF EJS Templates
destutil: extract all 'mergedest' abort messages into a dictionary...
Pierre-Yves David -
r28102:bd74b5e0 default
parent child Browse files
Show More
@@ -134,6 +134,43 def destupdate(repo, clean=False, check=
134 134
135 135 return rev, movemark, activemark
136 136
137 msgdestmerge = {
138 # too many matching divergent bookmark
139 'toomanybookmarks':
140 (_("multiple matching bookmarks to merge -"
141 " please merge with an explicit rev or bookmark"),
142 _("run 'hg heads' to see all heads")),
143 # no other matching divergent bookmark
144 'nootherbookmarks':
145 (_("no matching bookmark to merge - "
146 "please merge with an explicit rev or bookmark"),
147 _("run 'hg heads' to see all heads")),
148 # branch have too many unbookmarked heads, no obvious destination
149 'toomanyheads':
150 (_("branch '%s' has %d heads - please merge with an explicit rev"),
151 _("run 'hg heads .' to see heads")),
152 # branch have no other unbookmarked heads
153 'bookmarkedheads':
154 (_("heads are bookmarked - please merge with an explicit rev"),
155 _("run 'hg heads' to see all heads")),
156 # branch have just a single heads, but there is other branches
157 'nootherbranchheads':
158 (_("branch '%s' has one head - please merge with an explicit rev"),
159 _("run 'hg heads' to see all heads")),
160 # repository have a single head
161 'nootherheads':
162 (_('nothing to merge'),
163 None),
164 # repository have a single head and we are not on it
165 'nootherheadsbehind':
166 (_('nothing to merge'),
167 _("use 'hg update' instead")),
168 # We are not on a head
169 'notatheads':
170 (_('working directory not at a head revision'),
171 _("use 'hg update' or merge with an explicit revision"))
172 }
173
137 174 def _destmergebook(repo):
138 175 """find merge destination in the active bookmark case"""
139 176 node = None
@@ -145,13 +182,11 def _destmergebook(repo):
145 182 else:
146 183 node = bmheads[0]
147 184 elif len(bmheads) > 2:
148 raise error.Abort(_("multiple matching bookmarks to merge - "
149 "please merge with an explicit rev or bookmark"),
150 hint=_("run 'hg heads' to see all heads"))
185 msg, hint = msgdestmerge['toomanybookmarks']
186 raise error.Abort(msg, hint=hint)
151 187 elif len(bmheads) <= 1:
152 raise error.Abort(_("no matching bookmark to merge - "
153 "please merge with an explicit rev or bookmark"),
154 hint=_("run 'hg heads' to see all heads"))
188 msg, hint = msgdestmerge['nootherbookmarks']
189 raise error.Abort(msg, hint=hint)
155 190 assert node is not None
156 191 return node
157 192
@@ -163,31 +198,26 def _destmergebranch(repo):
163 198 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
164 199
165 200 if len(nbhs) > 2:
166 raise error.Abort(_("branch '%s' has %d heads - "
167 "please merge with an explicit rev")
168 % (branch, len(bheads)),
169 hint=_("run 'hg heads .' to see heads"))
201 msg, hint = msgdestmerge['toomanyheads']
202 msg %= (branch, len(bheads))
203 raise error.Abort(msg, hint=hint)
170 204
171 205 parent = repo.dirstate.p1()
172 206 if len(nbhs) <= 1:
173 207 if len(bheads) > 1:
174 raise error.Abort(_("heads are bookmarked - "
175 "please merge with an explicit rev"),
176 hint=_("run 'hg heads' to see all heads"))
177 if len(repo.heads()) > 1:
178 raise error.Abort(_("branch '%s' has one head - "
179 "please merge with an explicit rev")
180 % branch,
181 hint=_("run 'hg heads' to see all heads"))
182 msg, hint = _('nothing to merge'), None
183 if parent != repo.lookup(branch):
184 hint = _("use 'hg update' instead")
208 msg, hint = msgdestmerge['bookmarkedheads']
209 elif len(repo.heads()) > 1:
210 msg, hint = msgdestmerge['nootherbranchheads']
211 msg %= branch
212 elif parent != repo.lookup(branch):
213 msg, hint = msgdestmerge['nootherheadsbehind']
214 else:
215 msg, hint = msgdestmerge['nootherheads']
185 216 raise error.Abort(msg, hint=hint)
186 217
187 218 if parent not in bheads:
188 raise error.Abort(_('working directory not at a head revision'),
189 hint=_("use 'hg update' or merge with an "
190 "explicit revision"))
219 msg, hint = msgdestmerge['notatheads']
220 raise error.Abort(msg, hint=hint)
191 221 if parent == nbhs[0]:
192 222 node = nbhs[-1]
193 223 else:
General Comments 0
You need to be logged in to leave comments. Login now