diff --git a/hggit/compat.py b/hggit/compat.py
index 771ff61ff20b9a687307833c50289539fd46fdcf_aGdnaXQvY29tcGF0LnB5..8a327480a72014b1d1868ea2fc894b40cb12bc55_aGdnaXQvY29tcGF0LnB5 100644
--- a/hggit/compat.py
+++ b/hggit/compat.py
@@ -42,6 +42,9 @@
 except NameError:
     from mercurial.pycompat import unicode
 
+quote = hgutil.urlreq.quote
+unquote = hgutil.urlreq.unquote
+
 
 def gitvfs(repo):
     """return a vfs suitable to read git related data"""
diff --git a/hggit/git2hg.py b/hggit/git2hg.py
index 771ff61ff20b9a687307833c50289539fd46fdcf_aGdnaXQvZ2l0MmhnLnB5..8a327480a72014b1d1868ea2fc894b40cb12bc55_aGdnaXQvZ2l0MmhnLnB5 100644
--- a/hggit/git2hg.py
+++ b/hggit/git2hg.py
@@ -2,7 +2,6 @@
 
 from __future__ import absolute_import, print_function
 
-import urllib
 from dulwich.objects import Commit, Tag
 
 from . import compat
@@ -129,7 +128,7 @@
                 branch = data
             if command == b'extra':
                 k, v = data.split(b" : ", 1)
-                extra[k] = urllib.unquote(v)
+                extra[k] = compat.unquote(v)
 
     git_fn = 0
     for field, data in git_extra:
@@ -139,6 +138,6 @@
             command = field[3:]
             if command == b'rename':
                 before, after = data.split(b':', 1)
-                renames[urllib.unquote(after)] = urllib.unquote(before)
+                renames[compat.unquote(after)] = compat.unquote(before)
             elif command == b'extra':
                 k, v = data.split(b':', 1)
@@ -143,9 +142,9 @@
             elif command == b'extra':
                 k, v = data.split(b':', 1)
-                extra[urllib.unquote(k)] = urllib.unquote(v)
+                extra[compat.unquote(k)] = compat.unquote(v)
         else:
             # preserve ordering in Git by using an incrementing integer for
             # each field. Note that extra metadata in Git is an ordered list
             # of pairs.
             hg_field = b'GIT%d-%s' % (git_fn, field)
             git_fn += 1
@@ -146,9 +145,9 @@
         else:
             # preserve ordering in Git by using an incrementing integer for
             # each field. Note that extra metadata in Git is an ordered list
             # of pairs.
             hg_field = b'GIT%d-%s' % (git_fn, field)
             git_fn += 1
-            extra[urllib.quote(hg_field)] = urllib.quote(data)
+            extra[compat.quote(hg_field)] = compat.quote(data)
 
     return (message, renames, branch, extra)
diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 771ff61ff20b9a687307833c50289539fd46fdcf_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..8a327480a72014b1d1868ea2fc894b40cb12bc55_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -4,7 +4,6 @@
 import itertools
 import io
 import os
-import urllib
 import re
 
 from dulwich.errors import HangupException, GitProtocolError
@@ -686,7 +685,7 @@
             name = self.get_valid_git_username_email(a.group(1))
             email = self.get_valid_git_username_email(a.group(2))
             if a.group(3) is not None and len(a.group(3)) != 0:
-                name += b' ext:(' + urllib.quote(a.group(3)) + b')'
+                name += b' ext:(' + compat.quote(a.group(3)) + b')'
             author = b'%s <%s>'\
                      % (self.get_valid_git_username_email(name),
                          self.get_valid_git_username_email(email))
@@ -751,7 +750,7 @@
 
         git_extraitems.sort()
         for i, field, value in git_extraitems:
-            git_extra.append((urllib.unquote(field), urllib.unquote(value)))
+            git_extra.append((compat.unquote(field), compat.unquote(value)))
 
         if extra.get(b'hg-git-rename-source', None) != b'git':
             renames = []
@@ -768,8 +767,8 @@
                         extra_message += (b"rename : " + oldfile + b" => " +
                                           newfile + b"\n")
                     else:
-                        spec = b'%s:%s' % (urllib.quote(oldfile),
-                                           urllib.quote(newfile))
+                        spec = b'%s:%s' % (compat.quote(oldfile),
+                                           compat.quote(newfile))
                         git_extra.append((b'HG:rename', spec))
 
         # hg extra items always go at the end
@@ -780,5 +779,5 @@
             else:
                 if extra_in_message:
                     extra_message += (b"extra : " + key + b" : " +
-                                      urllib.quote(value) + b"\n")
+                                      compat.quote(value) + b"\n")
                 else:
@@ -784,6 +783,6 @@
                 else:
-                    spec = b'%s:%s' % (urllib.quote(key),
-                                       urllib.quote(value))
+                    spec = b'%s:%s' % (compat.quote(key),
+                                       compat.quote(value))
                     git_extra.append((b'HG:extra', spec))
 
         if extra_message:
@@ -925,7 +924,7 @@
             m = RE_GIT_AUTHOR_EXTRA.match(commit.author)
             if m:
                 name = m.group(1)
-                ex = urllib.unquote(m.group(2))
+                ex = compat.unquote(m.group(2))
                 email = m.group(3)
                 author = name + b' <' + email + b'>' + ex
 
diff --git a/hggit/util.py b/hggit/util.py
index 771ff61ff20b9a687307833c50289539fd46fdcf_aGdnaXQvdXRpbC5weQ==..8a327480a72014b1d1868ea2fc894b40cb12bc55_aGdnaXQvdXRpbC5weQ== 100644
--- a/hggit/util.py
+++ b/hggit/util.py
@@ -4,7 +4,6 @@
 from __future__ import absolute_import, print_function
 
 import re
-import urllib
 
 try:
     from collections import OrderedDict
@@ -146,7 +145,7 @@
 
     Raises an error.Abort when the url is unsafe.
     """
-    host = urllib.unquote(host)
+    host = compat.unquote(host)
     if host.startswith(b'-'):
         raise error.Abort(_(b'potentially unsafe hostname: %r') %
                           (host,))