changeset 126:4ac08a4210ec

7902421: jcheck fails with mercurial 4.8 with TypeError: walkchangerevs() takes exactly 4 arguments (5 given) Reviewed-by: erikj Contributed-By: gnu.andrew@redhat.com
author jjg
date Wed, 29 May 2019 10:25:28 -0700
parents b8f3bac16fc8
children 3f30d0fbf215
files jcheck.py
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jcheck.py	Tue Mar 12 09:27:17 2019 -0700
+++ b/jcheck.py	Wed May 29 10:25:28 2019 -0700
@@ -43,7 +43,7 @@
 _version = "@VERSION@"
 _date = "@DATE@"
 
-import sys, os, re, urllib, urllib2, json
+import sys, os, re, urllib, urllib2, json, inspect
 from mercurial.node import *
 from mercurial import cmdutil, context, error, patch, templater, util, utils
 try:
@@ -678,13 +678,16 @@
         if hash in self.blacklist:
             self.error(ctx, "Blacklisted changeset: " + hash)
 
-    def check(self, node):
+    def check(self, rev, node):
         self.summarized = False
         self.cs_bugids = [ ]
         self.cs_author = None
         self.cs_reviewers = [ ]
         self.cs_contributor = None
-        ctx = context.changectx(self.repo, node)
+        if len(inspect.getargspec(context.changectx.__init__).args) == 4:
+            ctx = context.changectx(self.repo, rev, node)
+        else:
+            ctx = context.changectx(self.repo, node)
         self.ui.note(oneline(ctx))
         if hex(node) in changeset_whitelist:
             self.ui.note("%s in whitelist; skipping\n" % hex(node))
@@ -741,7 +744,7 @@
     end = (hasattr(repo.changelog, 'count') and repo.changelog.count() or
            len(repo.changelog))
     for rev in xrange(start, end):
-        ch.check(repo.changelog.node(rev))
+        ch.check(rev, repo.changelog.node(rev))
     if ch.rv == Fail:
         ui.status("\n")
     return ch.rv
@@ -798,7 +801,7 @@
         nop = lambda c, fns: None
         iter = cmdutil.walkchangerevs(repo, _matchall(repo), opts, nop)
         for ctx in iter:
-            ch.check(ctx.node())
+            ch.check(ctx, ctx.node())
     except (AttributeError, TypeError):
         # AttributeError:  matchall does not exist in hg < 1.1
         # TypeError:  walkchangerevs args differ in hg <= 1.3.1
@@ -811,7 +814,7 @@
                 node = repo.changelog.node(rev)
                 if ui.debugflag:
                     displayer.show(rev, node, copies=False)
-                ch.check(node)
+                ch.check(rev, node)
             elif st == 'iter':
                 if ui.debugflag:
                     displayer.flush(rev)