From 628973ed7d52439b2fabfc366207f8979762c17f Mon Sep 17 00:00:00 2001 From: Matt Harbison Date: Wed, 23 Jan 2019 11:49:57 -0500 Subject: [PATCH] #1001 support Mercurial 4.7 through 4.9 The command fallback is per the documented example[1], and the date fallback is adapted from hg-evolve. [1] https://www.mercurial-scm.org/repo/hg/rev/86f6b441adea --- .../resources/sonia/scm/hg/ext/fileview.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg/ext/fileview.py b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg/ext/fileview.py index 518f229011..02f3eb3e06 100644 --- a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg/ext/fileview.py +++ b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg/ext/fileview.py @@ -32,10 +32,24 @@ Prints date, size and last message of files. """ -from mercurial import cmdutil,util cmdtable = {} -command = cmdutil.command(cmdtable) + +try: + from mercurial import registrar + command = registrar.command(cmdtable) +except (AttributeError, ImportError): + # Fallback to hg < 4.3 support + from mercurial import cmdutil + command = cmdutil.command(cmdtable) + +try: + from mercurial.utils import dateutil + _parsedate = dateutil.parsedate +except ImportError: + # compat with hg < 4.6 + from mercurial import util + _parsedate = util.parsedate class SubRepository: url = None @@ -129,7 +143,7 @@ def printFile(ui, repo, file, disableLastCommit, transport): description = 'n/a' if not disableLastCommit: linkrev = repo[file.linkrev()] - date = '%d %d' % util.parsedate(linkrev.date()) + date = '%d %d' % _parsedate(linkrev.date()) description = linkrev.description() format = '%s %i %s %s\n' if transport: