obsolete: factorise troubles detection during push
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 21 Dec 2012 22:58:59 +0100
changeset 18162 df1b37c8ae67
parent 18161 5b117f82cbdb
child 18163 c5bd753c5bc6
obsolete: factorise troubles detection during push The use of the two methods introduced earlier allows a factorisation of the push code preventing push of troubled changeset.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon Dec 17 15:17:54 2012 +0100
+++ b/mercurial/localrepo.py	Fri Dec 21 22:58:59 2012 +0100
@@ -1816,9 +1816,11 @@
                         if unfi.obsstore:
                             # this message are here for 80 char limit reason
                             mso = _("push includes obsolete changeset: %s!")
-                            msu = _("push includes unstable changeset: %s!")
-                            msb = _("push includes bumped changeset: %s!")
-                            msd = _("push includes divergent changeset: %s!")
+                            mst = "push includes %s changeset: %s!"
+                            # plain versions for i18n tool to detect them
+                            _("push includes unstable changeset: %s!")
+                            _("push includes bumped changeset: %s!")
+                            _("push includes divergent changeset: %s!")
                             # If we are to push if there is at least one
                             # obsolete or unstable changeset in missing, at
                             # least one of the missinghead will be obsolete or
@@ -1827,12 +1829,10 @@
                                 ctx = unfi[node]
                                 if ctx.obsolete():
                                     raise util.Abort(mso % ctx)
-                                elif ctx.unstable():
-                                    raise util.Abort(msu % ctx)
-                                elif ctx.bumped():
-                                    raise util.Abort(msb % ctx)
-                                elif ctx.divergent():
-                                    raise util.Abort(msd % ctx)
+                                elif ctx.troubled():
+                                    raise util.Abort(_(mst)
+                                                     % (ctx.troubles()[0],
+                                                        ctx))
                         discovery.checkheads(unfi, remote, outgoing,
                                              remoteheads, newbranch,
                                              bool(inc))