# HG changeset patch # User Franz Glasner # Date 1563114229 -7200 # Node ID 02da2f42acc2ebee1de90b5c60f742a2e12915bf # Parent 20c505821a6d083b457a04a866a0309ee9915b6f Make timestamps Mercurial 5.0.1 compatible: the signature of many functions in mercurial.match has changed. Provide wrapper calls based in inspection of formal arguments. diff -r 20c505821a6d -r 02da2f42acc2 extensions/timestamps.py --- a/extensions/timestamps.py Fri Jul 12 19:13:00 2019 +0200 +++ b/extensions/timestamps.py Sun Jul 14 16:23:49 2019 +0200 @@ -70,6 +70,7 @@ import calendar import collections import datetime +import inspect import io import itertools import os @@ -107,7 +108,7 @@ else: command = cmdutil.command(cmdtable) -testedwith = "4.5.2 4.6.1 4.8.1 4.9" +testedwith = "4.5.2 4.6.1 4.8.1 4.9 5.0.1" def getversion(): @@ -330,7 +331,7 @@ fstatus = self.status( match=_matchmod.differencematcher( match, - _matchmod.exact( + _matchmod_exact( self.root, '', [TIMESTAMPS_DATABASE, @@ -354,7 +355,7 @@ # ensure the database file is really tracked dbstatus = self.status( - match=_matchmod.exact(self.root, '', [TIMESTAMPS_DATABASE]), + match=_matchmod_exact(self.root, '', [TIMESTAMPS_DATABASE]), clean=True) if dbstatus.modified or dbstatus.added or dbstatus.clean: # already tracked @@ -376,7 +377,7 @@ auto_included = [] for f in (TIMESTAMPS_DATABASE, TIMESTAMPS_CONFIGFILE): fstatus = self.status( - match=_matchmod.exact(self.root, '', [f])) + match=_matchmod_exact(self.root, '', [f])) if fstatus.added or fstatus.modified: auto_included.append(f) if auto_included: @@ -386,7 +387,7 @@ # match = _matchmod.unionmatcher( [match, - _matchmod.exact(self.root, + _matchmod_exact(self.root, '', auto_included)]) self.ui.note(_("timestamps have been collected\n")) @@ -518,7 +519,7 @@ # NOTE: no need for a local repo here # tsconfmatch = _gen_matcher_from_tsconfig(ctx, tsconfig=tsconfig, ui=ui) \ - or _matchmod.never(ctx.repo().root, '') + or _matchmod_never(ctx.repo().root, '') ts = _Timestamps.from_ctx(ctx, ui, name=TIMESTAMPS_DATABASE) if ts is None: raise error.Abort(_("timestamps database file does not exist")) @@ -620,7 +621,7 @@ else: # check whether the existing configuration file is really tracked fstatus = ctx.status( - match=_matchmod.exact(repo.root, '', [TIMESTAMPS_CONFIGFILE]), + match=_matchmod_exact(repo.root, '', [TIMESTAMPS_CONFIGFILE]), listclean=True) if fstatus.modified or fstatus.added or fstatus.clean: configname = TIMESTAMPS_CONFIGFILE @@ -1226,3 +1227,19 @@ + repr(ms._stateextras) + '\n') ui.debug("UPDATE MergeState mdstate: " + repr(ms.mdstate()) + '\n') + + +if hasattr(inspect, "getfullargspec"): + # PY3 + _matchmod_with_root = "root" in inspect.getfullargspec(_matchmod.exact).args +else: + _matchmod_with_root = "root" in inspect.getargspec(_matchmod.exact).args + +if _matchmod_with_root: + _matchmod_exact = _matchmod.exact + _matchmod_never = _matchmod.never +else: + def _matchmod_exact(root, cwd, files, badfn=None): + return _matchmod.exact(files, badfn=badfn) + def _matchmod_never(root, cwd, badfn=None): + return _matchmod.never(badfn=badfn)