Edgewall Software
Modify

Opened 4 weeks ago

Last modified 4 weeks ago

#13419 assigned defect

walkchangerevs has been moved to scmutil from cmdutil in Mercurial 5.6

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone:
Component: plugin/mercurial Version: 1.4.3
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

TracMercurial tests fail with Mercurial 5.6+, due to walkchangerevs being moved to scmutil from cmdutil.

refs: https://www.mercurial-scm.org/repo/hg/rev/508dfd1c18df

======================================================================
ERROR: test_on_empty_repos (tracext.hg.tests.backend.MercurialNormalTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/mercurial-plugin/tracext/hg/tests/backend.py", line 223, in test_on_empty_repos
    self.assertEqual([(u'/', nullrev, 'add')], list(node.get_history()))
  File "/home/jun66j5/src/mercurial-plugin/tracext/hg/backend.py", line 1184, in get_history
    if arity(cmdutil.walkchangerevs) == 4:
AttributeError: 'module' object has no attribute 'walkchangerevs'

----------------------------------------------------------------------
Ran 17 tests in 0.335s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=17 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=17 errors=1 failures=0>

I applied the following patch to quickly fix it, but TypeError: 'alwaysmatcher' object is not iterable is raised. walkchangerevs's interface has been changed in https://www.mercurial-scm.org/repo/hg/rev/0356b41fe01d.

diff -r c29da66b9469 tracext/hg/backend.py
--- a/tracext/hg/backend.py     Thu Jan 17 15:29:26 2019 -0800
+++ b/tracext/hg/backend.py     Thu Sep 16 13:04:29 2021 +0900
@@ -132,6 +132,11 @@
     has_bookmarks = bool(listbookmarks)
     has_phasestr = None

+    if hasattr(cmdutil, 'walkchangerevs'):
+        from mercurial.cmdutil import walkchangerevs
+    else:
+        from mercurial.scmutil import walkchangerevs
+
 except ImportError, e:
     hg_import_error = exception_to_unicode(e)
     ui = object
@@ -1181,7 +1186,7 @@
         opts = {'rev': ['%s:0' % self.changectx.hex()]}
         if self.isfile and self.repos.version_info < (2, 1, 1):
             opts['follow'] = True
-        if arity(cmdutil.walkchangerevs) == 4:
+        if arity(walkchangerevs) == 4:
             return self._get_history_1_4(repo, pats, opts, limit)
         else:
             return self._get_history_1_3(repo, pats, opts, limit)
@@ -1201,7 +1206,7 @@
         path = self.path
         entry = None
         count = 0
-        for ctx in cmdutil.walkchangerevs(repo, matcher, opts, prep):
+        for ctx in walkchangerevs(repo, matcher, opts, prep):
             if self.isfile and entry:
                 path = fncache[ctx.rev()]
                 if path != entry[0]:
@@ -1225,8 +1230,7 @@
         get = cachefunc(changefn)
         if self.isfile:
             fncache = {}
-        chgiter, matchfn = cmdutil.walkchangerevs(self.repos.ui, repo, pats,
-                                                  get, opts)
+        chgiter, matchfn = walkchangerevs(self.repos.ui, repo, pats, get, opts)
         # keep one lookahead entry so that we can detect renames
         path = self.path
         entry = None
======================================================================
ERROR: test_on_empty_repos (tracext.hg.tests.backend.MercurialNormalTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/mercurial-plugin/tracext/hg/tests/backend.py", line 223, in test_on_empty_repos
    self.assertEqual([(u'/', nullrev, 'add')], list(node.get_history()))
  File "/home/jun66j5/src/mercurial-plugin/tracext/hg/backend.py", line 1209, in _get_history_1_4
    for ctx in walkchangerevs(repo, matcher, opts, prep):
  File "/home/jun66j5/src/mercurial-plugin/.tox/py27-trac14-hg56/lib/python2.7/site-packages/mercurial/scmutil.py", line 790, in iterate
    it = iter(revs)
TypeError: 'alwaysmatcher' object is not iterable

----------------------------------------------------------------------
Ran 17 tests in 0.344s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=17 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=17 errors=1 failures=0>

Attachments (1)

t13419.diff (4.6 KB ) - added by Jun Omae 4 weeks ago.

Download all attachments as: .zip

Change History (2)

by Jun Omae, 4 weeks ago

Attachment: t13419.diff added

comment:1 by Jun Omae, 4 weeks ago

Owner: set to Jun Omae
Status: newassigned

Proposed changes in attachment:t13419.diff (verified with Mercurial 4.5 - 5.9 on Python 2.7).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as assigned The owner will remain Jun Omae.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.