プロジェクト

全般

プロフィール

Vote #79472

完了

Mercurial 4.7 compatibility

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
SCM_3
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
3
version_id:
142
issue_org_id:
29413
author_id:
350973
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Hello,

Redmine 3.4.6 doesn't work with mercurial 4.7.
Logs say that in redmine/lib/redmine/scm/adapters/mercurial/redminehelper.py, module cmdutil does not have a command method.
Checking mercurial 4.6.1 source, this method is indeed deprecated ; it must have been removed from 4.7.
I got it back to work by following deprecation instruction which was "used registrar.command instead":

import re, time, cgi, urllib
from mercurial import cmdutil, commands, node, error, hg, registrar # added registrar

cmdtable = {}
command = registrar.command(cmdtable) # replaced cmdutil with registrar

Regards.


journals

--------------------------------------------------------------------------------
Another problem with exploring branches using hg 4.7.
It can be solved by modifying _changectx of redmine/scm/adapters/mercurial/redminehelper.py:
<pre>
def _changectx(repo, rev):
if hasattr(repo, 'branchtip') and rev in repo.branchmap(): # mercurial 4.7 doesn't select on branch name
rev = repo.branchtip(rev)
if hasattr(repo, 'changectx'):
return repo.changectx(rev)
else:
return repo[rev]
</pre>
--------------------------------------------------------------------------------
Maybe clever:

<pre>
def _changectx(repo, rev):
if isinstance(rev, str):
rev = repo.lookup(rev)
if hasattr(repo, 'changectx'):
return repo.changectx(rev)
else:
return repo[rev]
</pre>
--------------------------------------------------------------------------------
Frédéric Fondement, thank you for reporting the issue and submitting the workaround. Do you know it also work with Mercurial < 4.7?
--------------------------------------------------------------------------------
Good point !
The change I proposed fails with 4.0.

Here is the new version sucessfully tested with hg 4.7, 4.6, 4.5, 4.4, 4.1, 4.0, 3.9, 3.5, 2.6.2 (the older I can easily access - using pip):

<pre>
import re, time, cgi, urllib
from mercurial import cmdutil, commands, node, error, hg, registrar

cmdtable = {}
command = registrar.command(cmdtable) if hasattr(registrar, 'command') else cmdutil.command(cmdtable)
</pre>

<pre>
def _changectx(repo, rev):
if isinstance(rev, str):
rev = repo.lookup(rev)
if hasattr(repo, 'changectx'):
return repo.changectx(rev)
else:
return repo[rev]
</pre>
--------------------------------------------------------------------------------
I made a patch file from #29413#note-5.
--------------------------------------------------------------------------------
LGTM. The test suite passed with both Mercurial 2.6.2 and 4.7.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed. Thank you for reporting and fixing the issue.
--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリSCM_3 にセット
  • 対象バージョン3.3.9_142 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0