[PATCH 1 of 8 v3] convert: git use absolute_import

timeless timeless at mozdev.org
Wed Mar 2 20:55:50 UTC 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1456951333 0
#      Wed Mar 02 20:42:13 2016 +0000
# Node ID 836d43c8127b9c323d8fb5c00e875dbbc1a27536
# Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
convert: git use absolute_import

diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -4,14 +4,21 @@
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
+from __future__ import absolute_import
 
 import os
 import subprocess
-from mercurial import util, config, error
-from mercurial.node import hex, nullid
+from mercurial import (
+    config,
+    error,
+    node as nodemod,
+    util,
+)
 from mercurial.i18n import _
 
-from common import NoRepo, commit, converter_source, checktool
+from . import (
+    common,
+)
 
 class submodule(object):
     def __init__(self, path, node, url):
@@ -25,7 +32,7 @@
     def hgsubstate(self):
         return "%s %s" % (self.node, self.path)
 
-class convert_git(converter_source):
+class convert_git(common.converter_source):
     # Windows does not support GIT_DIR= construct while other systems
     # cannot remove environment variable. Just assume none have
     # both issues.
@@ -92,7 +99,8 @@
         if os.path.isdir(path + "/.git"):
             path += "/.git"
         if not os.path.exists(path + "/objects"):
-            raise NoRepo(_("%s does not look like a Git repository") % path)
+            raise common.NoRepo(_("%s does not look like a Git repository") %
+                                path)
 
         # The default value (50) is based on the default for 'git diff'.
         similarity = ui.configint('convert', 'git.similarity', default=50)
@@ -107,7 +115,7 @@
         else:
             self.simopt = ''
 
-        checktool('git', 'git')
+        common.checktool('git', 'git')
 
         self.path = path
         self.submodules = []
@@ -134,7 +142,7 @@
         return heads
 
     def catfile(self, rev, type):
-        if rev == hex(nullid):
+        if rev == nodemod.nullhex:
             raise IOError
         self.catfilepipe[0].write(rev+'\n')
         self.catfilepipe[0].flush()
@@ -151,7 +159,7 @@
         return data
 
     def getfile(self, name, rev):
-        if rev == hex(nullid):
+        if rev == nodemod.nullhex:
             return None, None
         if name == '.hgsub':
             data = '\n'.join([m.hgsub() for m in self.submoditer()])
@@ -165,7 +173,7 @@
         return data, mode
 
     def submoditer(self):
-        null = hex(nullid)
+        null = nodemod.nullhex
         for m in sorted(self.submodules, key=lambda p: p.path):
             if m.node != null:
                 yield m
@@ -240,7 +248,7 @@
                 subexists[0] = True
                 if entry[4] == 'D' or renamesource:
                     subdeleted[0] = True
-                    changes.append(('.hgsub', hex(nullid)))
+                    changes.append(('.hgsub', nodemod.nullhex))
                 else:
                     changes.append(('.hgsub', ''))
             elif entry[1] == '160000' or entry[0] == ':160000':
@@ -248,7 +256,7 @@
                     subexists[0] = True
             else:
                 if renamesource:
-                    h = hex(nullid)
+                    h = nodemod.nullhex
                 self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
                 changes.append((f, h))
 
@@ -287,7 +295,7 @@
 
         if subexists[0]:
             if subdeleted[0]:
-                changes.append(('.hgsubstate', hex(nullid)))
+                changes.append(('.hgsubstate', nodemod.nullhex))
             else:
                 self.retrievegitmodules(version)
                 changes.append(('.hgsubstate', ''))
@@ -324,8 +332,9 @@
         tz = -int(tzs) * (int(tzh) * 3600 + int(tzm))
         date = tm + " " + str(tz)
 
-        c = commit(parents=parents, date=date, author=author, desc=message,
-                   rev=version)
+        c = common.commit(parents=parents, date=date, author=author,
+                          desc=message,
+                          rev=version)
         return c
 
     def numcommits(self):
diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -41,7 +41,6 @@
   hgext/convert/cvsps.py not using absolute_import
   hgext/convert/darcs.py not using absolute_import
   hgext/convert/filemap.py not using absolute_import
-  hgext/convert/git.py not using absolute_import
   hgext/convert/gnuarch.py not using absolute_import
   hgext/convert/hg.py not using absolute_import
   hgext/convert/monotone.py not using absolute_import


More information about the Mercurial-devel mailing list