evolve: drop 4.5 compatibility with `patch.extract` API
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 07 Mar 2020 02:03:28 +0700
changeset 5185 c111d5db3713
parent 5184 2ccd7c97ed59
child 5186 4bac3454beef
evolve: drop 4.5 compatibility with `patch.extract` API
hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py	Sat Mar 07 01:43:40 2020 +0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Sat Mar 07 02:03:28 2020 +0700
@@ -11,7 +11,6 @@
 
 from __future__ import absolute_import
 
-import contextlib
 import random
 
 from mercurial import (
@@ -219,14 +218,7 @@
 def _writepatch(ui, repo, old, fp):
     """utility function to use filestore and patchrepo to apply a patch to the
     repository with metadata being extracted from the patch"""
-    metadata = patch.extract(ui, fp)
-    if util.safehasattr(metadata, 'get'): # < hg-4.6
-        @contextlib.contextmanager
-        def patchcontext():
-            yield metadata
-        patchcontext = patchcontext()
-    else:
-        patchcontext = metadata
+    patchcontext = patch.extract(ui, fp)
     pold = old.p1()
 
     with patchcontext as metadata: