Patchwork [V2] obsolete: factorise troubles detection during push

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 23, 2012, 3:49 p.m.
Message ID <3cf84ea7a35e7809ee92.1356277764@yamac.lan>
Download mbox | patch
Permalink /patch/278/
State Accepted
Commit df1b37c8ae679693a0829e231d359f1dc20bb78e
Headers show

Comments

Pierre-Yves David - Dec. 23, 2012, 3:49 p.m.
# 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.

Patch

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