[PATCH V2] obsolete: factorise troubles detection during push

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Dec 23 09:49:24 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1356127139 -3600
# Node ID 3cf84ea7a35e7809ee9219bb842ff4a8592a9f47
# Parent  e759e80ace410627dd817b54474fe72dedf68802
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.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1817,27 +1817,27 @@ class localrepository(object):
                         # if self.obsstore == False --> no obsolete
                         # then, save the iteration
                         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
                             # unstable. So checking heads only is ok
                             for node in outgoing.missingheads:
                                 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))
 
                     # create a changegroup from local


More information about the Mercurial-devel mailing list