changeset 2293:1659b42c28c2

compat: only install the better filtered message for mercurial 4.2 and above The helper function does not exist in earlier version.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 01 May 2017 06:06:41 +0200
parents f026e85bd0b2
children 75996eafab43
files hgext3rd/evolve/__init__.py
diffstat 1 files changed, 33 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py	Sat Apr 29 05:35:01 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Mon May 01 06:06:41 2017 +0200
@@ -533,6 +533,39 @@
 
     ui.warn("(%s)\n" % solvemsg)
 
+if util.safehasattr(context, '_filterederror'):
+    # if < hg-4.2 we do not update the message
+    @eh.wrapfunction(context, '_filterederror')
+    def evolve_filtererror(original, repo, changeid):
+        """build an exception to be raised about a filtered changeid
+
+        This is extracted in a function to help extensions (eg: evolve) to
+        experiment with various message variants."""
+        if repo.filtername.startswith('visible'):
+
+            unfilteredrepo = repo.unfiltered()
+            rev = unfilteredrepo[changeid]
+            reason, successors = _getobsoletereason(unfilteredrepo, rev.node())
+
+            # Be more precise in cqse the revision is superseed
+            if reason == 'superseed':
+                reason = _("successor: %s") % successors[0]
+            elif reason == 'superseed_split':
+                if len(successors) <= 2:
+                    reason = _("successors: %s") % ", ".join(successors)
+                else:
+                    firstsuccessors = ", ".join(successors[:2])
+                    remainingnumber = len(successors) - 2
+                    successorsmsg = _("%s and %d more") % (firstsuccessors, remainingnumber)
+                    reason = _("successors: %s") % successorsmsg
+
+            msg = _("hidden revision '%s'") % changeid
+            hint = _('use --hidden to access hidden revisions; %s') % reason
+            return error.FilteredRepoLookupError(msg, hint=hint)
+        msg = _("filtered revision '%s' (not in '%s' subset)")
+        msg %= (changeid, repo.filtername)
+        return error.FilteredRepoLookupError(msg)
+
 @eh.wrapcommand("update")
 @eh.wrapcommand("pull")
 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
@@ -3203,35 +3236,3 @@
                 f.write(orig.topic())
 
     return merge.graft(repo, orig, pctx, ['local', 'graft'], True)
-
-
-@eh.wrapfunction(context, '_filterederror')
-def evolve_filtererror(original, repo, changeid):
-    """build an exception to be raised about a filtered changeid
-
-    This is extracted in a function to help extensions (eg: evolve) to
-    experiment with various message variants."""
-    if repo.filtername.startswith('visible'):
-
-        unfilteredrepo = repo.unfiltered()
-        rev = unfilteredrepo[changeid]
-        reason, successors = _getobsoletereason(unfilteredrepo, rev.node())
-
-        # Be more precise in cqse the revision is superseed
-        if reason == 'superseed':
-            reason = _("successor: %s") % successors[0]
-        elif reason == 'superseed_split':
-            if len(successors) <= 2:
-                reason = _("successors: %s") % ", ".join(successors)
-            else:
-                firstsuccessors = ", ".join(successors[:2])
-                remainingnumber = len(successors) - 2
-                successorsmsg = _("%s and %d more") % (firstsuccessors, remainingnumber)
-                reason = _("successors: %s") % successorsmsg
-
-        msg = _("hidden revision '%s'") % changeid
-        hint = _('use --hidden to access hidden revisions; %s') % reason
-        return error.FilteredRepoLookupError(msg, hint=hint)
-    msg = _("filtered revision '%s' (not in '%s' subset)")
-    msg %= (changeid, repo.filtername)
-    return error.FilteredRepoLookupError(msg)