changeset 1125:8f55daa87ce4

git-handler: fix deprecated API in next hg version https://phab.mercurial-scm.org/D2003 Mercurial version 4.6 will introduce a refactoring of the utils.py file into smaller files, starting with dateutil.py. This change prepares this move so that the warnings won't break the tests.
author Paul Morelle <paul.morelle@octobus.net>
date Wed, 21 Mar 2018 23:29:07 +0100
parents 666ab5997802
children e41773ad3584
files hggit/git_handler.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py	Tue May 01 10:28:16 2018 -0500
+++ b/hggit/git_handler.py	Wed Mar 21 23:29:07 2018 +0100
@@ -54,6 +54,13 @@
 
 RE_AUTHOR_FILE = re.compile('\s*=\s*')
 
+# mercurial.utils.dateutil functions were in mercurial.util in Mercurial < 4.6
+try:
+    from mercurial.utils import dateutil
+    dateutil.parsedate
+except ImportError:
+    dateutil = hgutil
+
 CALLBACK_BUFFER = ''
 
 
@@ -1312,7 +1319,7 @@
             return refs
 
         # filter refs older than min_timestamp
-        min_timestamp, min_offset = hgutil.parsedate(min_date)
+        min_timestamp, min_offset = dateutil.parsedate(min_date)
 
         def check_min_time(obj):
             if isinstance(obj, Tag):