Bug 1270317 - Remove purgelong compatibility with ancient Mercurial versions; r=jlund
authorGregory Szorc <gps@mozilla.com>
Fri, 06 May 2016 10:50:52 -0700
changeset 296439 e97f355e24c9a98f62ade458ce6a25364088b9a4
parent 296438 e679c2e0b1b5d8e6ec19deaa44dbbdf9bcf31383
child 296440 214b6958340a237d4cb67a09cc7eb2c49541d973
push id76329
push usergszorc@mozilla.com
push dateFri, 06 May 2016 18:16:07 +0000
treeherdermozilla-inbound@273d52aff2ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlund
bugs1270317
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/mozharness/external_tools/purgelong.py
--- 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: