Patchwork [06,of,10] simplemerge: update to conform with modern import conventions

login
register
mail settings
Submitter Augie Fackler
Date Aug. 23, 2017, 2:55 p.m.
Message ID <a513d142d47423242743.1503500105@imladris.local>
Download mbox | patch
Permalink /patch/23235/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 23, 2017, 2:55 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1503425593 14400
#      Tue Aug 22 14:13:13 2017 -0400
# Node ID a513d142d47423242743902f8e94d033c8ecc563
# Parent  ab897b232da53bc7b198027103de5e521f6e8e29
simplemerge: update to conform with modern import conventions
Yuya Nishihara - Aug. 24, 2017, 12:32 p.m.
On Wed, 23 Aug 2017 10:55:05 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1503425593 14400
> #      Tue Aug 22 14:13:13 2017 -0400
> # Node ID a513d142d47423242743902f8e94d033c8ecc563
> # Parent  ab897b232da53bc7b198027103de5e521f6e8e29
> simplemerge: update to conform with modern import conventions

Queued the series, thanks.

> --- a/contrib/simplemerge
> +++ b/contrib/simplemerge
> @@ -1,12 +1,20 @@
>  #!/usr/bin/env python
> -
> -from mercurial import demandimport
> -demandimport.enable()
> +from __future__ import absolute_import
>  
>  import getopt
>  import sys
> +
> +import hgdemandimport
> +hgdemandimport.enable()

This makes the import of getopt non-lazy, but that should be okay because
getopt isn't big and is loaded anyway.

Patch

diff --git a/contrib/simplemerge b/contrib/simplemerge
--- a/contrib/simplemerge
+++ b/contrib/simplemerge
@@ -1,12 +1,20 @@ 
 #!/usr/bin/env python
-
-from mercurial import demandimport
-demandimport.enable()
+from __future__ import absolute_import
 
 import getopt
 import sys
+
+import hgdemandimport
+hgdemandimport.enable()
+
 from mercurial.i18n import _
-from mercurial import error, simplemerge, fancyopts, util, ui
+from mercurial import (
+    error,
+    fancyopts,
+    simplemerge,
+    ui as uimod,
+    util,
+)
 
 options = [('L', 'label', [], _('labels to use on conflict markers')),
            ('a', 'text', None, _('treat all files as text')),
@@ -55,7 +63,7 @@  try:
         sys.exit(0)
     if len(args) != 3:
             raise ParseError(_('wrong number of arguments'))
-    sys.exit(simplemerge.simplemerge(ui.ui.load(), *args, **opts))
+    sys.exit(simplemerge.simplemerge(uimod.ui.load(), *args, **opts))
 except ParseError as e:
     sys.stdout.write("%s: %s\n" % (sys.argv[0], e))
     showhelp()