Mercurial > hg-git
changeset 479:5c1d4311440d
submodules: only use the ordereddict backport if collections.OrderedDict is unavailable
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Tue, 28 Aug 2012 09:09:01 -0500 |
parents | 64eb2789e5bf |
children | ac644c0e16d4 |
files | hggit/git_handler.py hggit/util.py setup.py |
diffstat | 3 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py Tue Aug 28 09:08:22 2012 -0500 +++ b/hggit/git_handler.py Tue Aug 28 09:09:01 2012 -0500 @@ -1,6 +1,5 @@ import os, math, urllib, re import stat, posixpath, StringIO -import ordereddict from dulwich.errors import HangupException, GitProtocolError from dulwich.index import commit_tree @@ -503,7 +502,7 @@ 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())
--- a/hggit/util.py Tue Aug 28 09:08:22 2012 -0500 +++ b/hggit/util.py Tue Aug 28 09:09:01 2012 -0500 @@ -1,5 +1,8 @@ """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.""" @@ -7,7 +10,7 @@ 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 @@ -21,7 +24,7 @@ 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 @@ -32,4 +35,3 @@ def serialize_hgsubstate(data): """Produces a string from OrderedDict hgsubstate content""" return ''.join(['%s %s\n' % (data[n], n) for n in sorted(data)]) -
--- a/setup.py Tue Aug 28 09:08:22 2012 -0500 +++ b/setup.py Tue Aug 28 09:09:01 2012 -0500 @@ -3,6 +3,12 @@ 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', @@ -19,5 +25,5 @@ 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, )