changeset 953:a02e5916a7e3

import: drop version check for ``import --obsolete`` This code base does not support anything below mercurial-3.0 anyway.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 02 Jun 2014 14:18:29 -0700
parents f83f46411b09
children ef155e3ead8f
files hgext/evolve.py
diffstat 1 files changed, 27 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Tue Jun 03 01:16:39 2014 -0700
+++ b/hgext/evolve.py	Mon Jun 02 14:18:29 2014 -0700
@@ -884,36 +884,34 @@
      _('record the specified user in metadata'), _('USER')),
 ]
 
-if getattr(mercurial.cmdutil, 'tryimportone', None) is not None:
-    # hg 3.0 and greate
-    @eh.uisetup
-    def _installimportobsolete(ui):
-        entry = cmdutil.findcmd('import', commands.table)[1]
-        entry[1].append(('', 'obsolete', False,
-                        _('mark the old node as obsoleted by'
-                          'the created commit')))
+@eh.uisetup
+def _installimportobsolete(ui):
+    entry = cmdutil.findcmd('import', commands.table)[1]
+    entry[1].append(('', 'obsolete', False,
+                    _('mark the old node as obsoleted by'
+                      'the created commit')))
 
-    @eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
-    def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
-        extracted = patch.extract(ui, hunk)
-        expected = extracted[5]
-        oldextract = patch.extract
-        try:
-            patch.extract = lambda ui, hunk: extracted
-            ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
-        finally:
-            patch.extract = oldextract
-        created = ret[1]
-        if opts['obsolete'] and created is not None and created != expected:
-                tr = repo.transaction('import-obs')
-                try:
-                    metadata = {'user': ui.username()}
-                    repo.obsstore.create(tr, node.bin(expected), (created,),
-                                         metadata=metadata)
-                    tr.close()
-                finally:
-                    tr.release()
-        return ret
+@eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
+def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
+    extracted = patch.extract(ui, hunk)
+    expected = extracted[5]
+    oldextract = patch.extract
+    try:
+        patch.extract = lambda ui, hunk: extracted
+        ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
+    finally:
+        patch.extract = oldextract
+    created = ret[1]
+    if opts['obsolete'] and created is not None and created != expected:
+            tr = repo.transaction('import-obs')
+            try:
+                metadata = {'user': ui.username()}
+                repo.obsstore.create(tr, node.bin(expected), (created,),
+                                     metadata=metadata)
+                tr.close()
+            finally:
+                tr.release()
+    return ret
 
 
 def _deprecatealias(oldalias, newalias):