Patchwork [2,of,3] fancyopts: switch from fancyopts.getopt.* to getopt.*

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 6, 2016, 1:56 a.m.
Message ID <559b73b5d7b919da68bf.1480989400@pulkit-goyal>
Download mbox | patch
Permalink /patch/17825/
State Accepted
Headers show

Comments

Pulkit Goyal - Dec. 6, 2016, 1:56 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1480985878 -19800
#      Tue Dec 06 06:27:58 2016 +0530
# Node ID 559b73b5d7b919da68bf2ce5b05dd9677ddc1c2d
# Parent  d85f937e2f04d7b6356070adb99677ae1c2bab15
fancyopts: switch from fancyopts.getopt.* to getopt.*

In the next patch, we will be creating a bytes version of getopt.getopt() and
doing that will leave getopt as unused import in fancyopts. So before removing
that there are instances in codebase where instead of importing getopt, we
have used fancyopts.getopt. This patch will switch all those cases so that
the next patch can remove the import of getopt from fancyopts without breaking
things.

Patch

diff -r d85f937e2f04 -r 559b73b5d7b9 contrib/simplemerge
--- a/contrib/simplemerge	Mon Dec 05 06:46:51 2016 +0530
+++ b/contrib/simplemerge	Tue Dec 06 06:27:58 2016 +0530
@@ -3,6 +3,7 @@ 
 from mercurial import demandimport
 demandimport.enable()
 
+import getopt
 import sys
 from mercurial.i18n import _
 from mercurial import error, simplemerge, fancyopts, util, ui
@@ -47,7 +48,7 @@ 
     opts = {}
     try:
         args = fancyopts.fancyopts(sys.argv[1:], options, opts)
-    except fancyopts.getopt.GetoptError as e:
+    except getopt.GetoptError as e:
         raise ParseError(e)
     if opts['help']:
         showhelp()
diff -r d85f937e2f04 -r 559b73b5d7b9 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Mon Dec 05 06:46:51 2016 +0530
+++ b/mercurial/dispatch.py	Tue Dec 06 06:27:58 2016 +0530
@@ -10,6 +10,7 @@ 
 import atexit
 import difflib
 import errno
+import getopt
 import os
 import pdb
 import re
@@ -448,7 +449,7 @@ 
 
     try:
         args = fancyopts.fancyopts(args, commands.globalopts, options)
-    except fancyopts.getopt.GetoptError as inst:
+    except getopt.GetoptError as inst:
         raise error.CommandError(None, inst)
 
     if args:
@@ -471,7 +472,7 @@ 
 
     try:
         args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True)
-    except fancyopts.getopt.GetoptError as inst:
+    except getopt.GetoptError as inst:
         raise error.CommandError(cmd, inst)
 
     # separate global options back out
@@ -601,7 +602,7 @@ 
 
     try:
         args = fancyopts.fancyopts(args, commands.globalopts, options)
-    except fancyopts.getopt.GetoptError:
+    except getopt.GetoptError:
         return
 
     if not args: