patch: move import/export wrapping close to the function definition
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 30 Mar 2016 22:02:52 -0700
changeset 1945 f4f5bf8b4d17
parent 1944 daad8249d5cf
child 1946 72246b13bd72
patch: move import/export wrapping close to the function definition This gather similar logic together.
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Wed Mar 30 21:53:55 2016 -0700
+++ b/hgext3rd/topic/__init__.py	Wed Mar 30 22:02:52 2016 -0700
@@ -345,6 +345,15 @@
     if 'topic' in patchdata:
         extra['topic'] = patchdata['topic']
 
+if util.safehasattr(cmdutil, 'extraexport'):
+    cmdutil.extraexport.append('topic')
+    cmdutil.extraexportmap['topic'] = _exporttopic
+if util.safehasattr(cmdutil, 'extrapreimport'):
+    cmdutil.extrapreimport.append('topic')
+    cmdutil.extrapreimportmap['topic'] = _importtopic
+if util.safehasattr(patch, 'patchheadermap'):
+    patch.patchheadermap.append(('EXP-Topic', 'topic'))
+
 extensions.afterloaded('rebase', _fixrebase)
 
 entry = extensions.wrapcommand(commands.table, 'commit', commitwrap)
@@ -356,11 +365,3 @@
 extensions.wrapfunction(changegroup.cg1unpacker, 'apply', cgapply)
 cmdutil.summaryhooks.add('topic', summaryhook)
 
-if util.safehasattr(cmdutil, 'extraexport'):
-    cmdutil.extraexport.append('topic')
-    cmdutil.extraexportmap['topic'] = _exporttopic
-if util.safehasattr(cmdutil, 'extrapreimport'):
-    cmdutil.extrapreimport.append('topic')
-    cmdutil.extrapreimportmap['topic'] = _importtopic
-if util.safehasattr(patch, 'patchheadermap'):
-    patch.patchheadermap.append(('EXP-Topic', 'topic'))