Commits

Augie Fackler committed 5c1d431

submodules: only use the ordereddict backport if collections.OrderedDict is unavailable

Comments (0)

Files changed (3)

hggit/git_handler.py

 import os, math, urllib, re
 import stat, posixpath, StringIO
-import ordereddict
 
 from dulwich.errors import HangupException, GitProtocolError
 from dulwich.index import commit_tree
 
     def iterblobs(self, ctx):
         if '.hgsubstate' in ctx:
-            hgsub = ordereddict.OrderedDict()
+            hgsub = util.OrderedDict()
             if '.hgsub' in ctx:
                 hgsub = util.parse_hgsub(ctx['.hgsub'].data().splitlines())
             hgsubstate = util.parse_hgsubstate(ctx['.hgsubstate'].data().splitlines())
 """Compatability functions for old Mercurial versions."""
-import ordereddict
+try:
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 
 def progress(ui, *args, **kwargs):
     """Shim for progress on hg < 1.4. Remove when 1.3 is dropped."""
 
 def parse_hgsub(lines):
     """Fills OrderedDict with hgsub file content passed as list of lines"""
-    rv = ordereddict.OrderedDict()
+    rv = OrderedDict()
     for l in lines:
         ls = l.strip();
         if not ls or ls[0] == '#': continue
 
 def parse_hgsubstate(lines):
     """Fills OrderedDict with hgsubtate file content passed as list of lines"""
-    rv = ordereddict.OrderedDict()
+    rv = OrderedDict()
     for l in lines:
         ls = l.strip();
         if not ls or ls[0] == '#': continue
 def serialize_hgsubstate(data):
     """Produces a string from OrderedDict hgsubstate content"""
     return ''.join(['%s %s\n' % (data[n], n) for n in sorted(data)])
-
 except:
     from distutils.core import setup
 
+try:
+    from collections import OrderedDict
+    extra_req = []
+except ImportError:
+    extra_req = 'ordereddict>=1.1'
+
 setup(
     name='hg-git',
     version='0.4.0',
     keywords='hg git mercurial',
     license='GPLv2',
     packages=['hggit'],
-    install_requires=['dulwich>=0.8.0', 'ordereddict>=1.1'],
+    install_requires=['dulwich>=0.8.0'] + extra_req,
 )