#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
This commit is contained in:
Matt Harbison
2019-01-23 11:49:57 -05:00
parent 7e5325a1ce
commit 628973ed7d

View File

@@ -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: