Bug 1270317 - Remove purgelong compatibility with ancient Mercurial versions; r=jlund
We no longer use <3.7 in automation. So drop support for <3.2. While I
was here, I also added magic variables to the extension so Mercurial
can react intelligently to version compatibility issues.
MozReview-Commit-ID: 4tAvQljasDR
--- a/testing/mozharness/external_tools/purgelong.py
+++ b/testing/mozharness/external_tools/purgelong.py
@@ -16,16 +16,19 @@ the purge() command exits.
from contextlib import contextmanager
from functools import partial
import os
import errno
import mercurial.extensions
import mercurial.util
+testedwith = '3.7'
+minimumhgversion = '3.7'
+
if os.name == 'nt':
import ctypes
# Get a reference to the DeleteFileW function
# DeleteFileW accepts filenames encoded as a null terminated sequence of
# wide chars (UTF-16). Python's ctypes.c_wchar_p correctly encodes unicode
# strings to null terminated UTF-16 strings.
# However, we receive (byte) strings from mercurial. When these are passed
@@ -64,24 +67,18 @@ def unlink_wrapper(unlink_orig, fn, ui):
return unlink_long(fn)
@contextmanager
def wrap_unlink(ui):
'''Context manager that patches the required functions that are used by
the purge extension to remove files. When exiting the context manager
the original functions are restored.'''
- version = mercurial.util.version()
- if version >= '3.2':
- # hg 3.2 and higher use util.unlink for purging
- purgemod = mercurial.extensions.find('purge')
- to_wrap = [(purgemod.util, 'unlink')]
- else:
- # hg 3.1 and earlier use os.remove directly
- to_wrap = [(os, 'remove')]
+ purgemod = mercurial.extensions.find('purge')
+ to_wrap = [(purgemod.util, 'unlink')]
# pass along the ui object to the unlink_wrapper so we can get logging out
# of it
wrapped = partial(unlink_wrapper, ui=ui)
# Wrap the original function(s) with our unlink_wrapper
originals = {}
for mod, func in to_wrap: