Skip to content

Commit f6aa8d1

Browse files
committed
initial set of adjustments to make (most) imports work.
More to come, especially when it's about strings
1 parent 3936084 commit f6aa8d1

37 files changed

+136
-114
lines changed

Diff for: README.md

-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ In short, I want to make a new release of 0.3 with all contributions and fixes i
8383

8484
The goals I have set for myself, in order, are as follows, all on branch 0.3.
8585

86-
* bring the test suite back online to work with the most commonly used git version
87-
* merge all open pull requests, may there be a test-case or not, back. If something breaks, fix it if possible or let the contributor know
88-
* conform git-python's structure and toolchain to the one used in my [other OSS projects](https://github.com/Byron/bcore)
89-
* evaluate all open issues and close them if possible
9086
* evaluate python 3.3 compatibility and establish it if possible
9187

9288
While that is happening, I will try hard to foster community around the project. This means being more responsive on the mailing list and in issues, as well as setting up clear guide lines about the [contribution](http://rfc.zeromq.org/spec:22) and maintenance workflow.

Diff for: doc/source/changes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changelog
66
=====
77
* When fetching, pulling or pushing, and an error occours, it will not be reported on stdout anymore. However, if there is a fatal error, it will still result in a GitCommandError to be thrown. This goes hand in hand with improved fetch result parsing.
88
* Code Cleanup (in preparation for python 3 support)
9+
910
* Applied autopep8 and cleaned up code
1011
* Using python logging module instead of print statments to signal certain kinds of errors
1112

Diff for: git/cmd.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
import os
88
import sys
99
import logging
10-
from util import (
11-
LazyMixin,
12-
stream_copy
13-
)
14-
from exc import GitCommandError
15-
1610
from subprocess import (
1711
call,
1812
Popen,
1913
PIPE
2014
)
2115

16+
17+
from .util import (
18+
LazyMixin,
19+
stream_copy
20+
)
21+
from .exc import GitCommandError
22+
23+
2224
execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output',
2325
'with_exceptions', 'as_process',
2426
'output_stream')

Diff for: git/compat.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#-*-coding:utf-8-*-
2+
# config.py
3+
# Copyright (C) 2008, 2009 Michael Trier ([email protected]) and contributors
4+
#
5+
# This module is part of GitPython and is released under
6+
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
7+
"""utilities to help provide compatibility with python 3"""
8+
9+
from gitdb.utils.compat import ( # noqa
10+
PY3,
11+
xrange,
12+
MAXSIZE,
13+
izip,
14+
)
15+
16+
from gitdb.utils.encoding import ( # noqa
17+
string_types,
18+
text_type
19+
)

Diff for: git/config.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
configuration files"""
88

99
import re
10-
import ConfigParser as cp
10+
try:
11+
import ConfigParser as cp
12+
except ImportError:
13+
# PY3
14+
import configparser as cp
1115
import inspect
1216
import logging
1317

Diff for: git/db.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
"""Module with our own gitdb implementation - it uses the git command"""
2-
from exc import (
3-
GitCommandError,
4-
BadObject
5-
)
6-
72
from gitdb.base import (
83
OInfo,
94
OStream
105
)
11-
126
from gitdb.util import (
137
bin_to_hex,
148
hex_to_bin
159
)
1610
from gitdb.db import GitDB
1711
from gitdb.db import LooseObjectDB
1812

13+
from .exc import (
14+
GitCommandError,
15+
BadObject
16+
)
17+
1918

2019
__all__ = ('GitCmdObjectDB', 'GitDB')
2120

Diff for: git/diff.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
76
import re
8-
from objects.blob import Blob
9-
from objects.util import mode_str_to_int
107

118
from gitdb.util import hex_to_bin
129

10+
from .objects.blob import Blob
11+
from .objects.util import mode_str_to_int
12+
1313

1414
__all__ = ('Diffable', 'DiffIndex', 'Diff')
1515

Diff for: git/index/base.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,23 @@
88
import sys
99
import subprocess
1010
import glob
11-
from cStringIO import StringIO
11+
from io import StringIO
1212

1313
from stat import S_ISLNK
1414

15-
from typ import (
15+
from .typ import (
1616
BaseIndexEntry,
1717
IndexEntry,
1818
)
1919

20-
from util import (
20+
from .util import (
2121
TemporaryFileSwap,
2222
post_clear_cache,
2323
default_index,
2424
git_working_dir
2525
)
2626

2727
import git.diff as diff
28-
2928
from git.exc import (
3029
GitCommandError,
3130
CheckoutError
@@ -40,6 +39,7 @@
4039
)
4140

4241
from git.objects.util import Serializable
42+
from git.compat import izip
4343

4444
from git.util import (
4545
LazyMixin,
@@ -49,7 +49,7 @@
4949
to_native_path_linux,
5050
)
5151

52-
from fun import (
52+
from .fun import (
5353
entry_key,
5454
write_cache,
5555
read_cache,
@@ -62,7 +62,6 @@
6262
from gitdb.base import IStream
6363
from gitdb.db import MemoryDB
6464
from gitdb.util import to_bin_sha
65-
from itertools import izip
6665

6766
__all__ = ('IndexFile', 'CheckoutError')
6867

Diff for: git/index/fun.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule
1414

15-
from cStringIO import StringIO
15+
from io import StringIO
1616

1717
from git.util import IndexFileSHA1Writer
1818
from git.exc import UnmergedEntriesError
@@ -22,15 +22,15 @@
2222
traverse_trees_recursive
2323
)
2424

25-
from typ import (
25+
from .typ import (
2626
BaseIndexEntry,
2727
IndexEntry,
2828
CE_NAMEMASK,
2929
CE_STAGESHIFT
3030
)
3131
CE_NAMEMASK_INV = ~CE_NAMEMASK
3232

33-
from util import (
33+
from .util import (
3434
pack,
3535
unpack
3636
)
@@ -49,7 +49,7 @@ def stat_mode_to_index_mode(mode):
4949
return S_IFLNK
5050
if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK: # submodules
5151
return S_IFGITLINK
52-
return S_IFREG | 0644 | (mode & 0100) # blobs with or without executable bit
52+
return S_IFREG | 0o644 | (mode & 0o100) # blobs with or without executable bit
5353

5454

5555
def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1Writer):

Diff for: git/index/typ.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
"""Module with additional types used by the index"""
22

3-
from util import (
3+
from binascii import b2a_hex
4+
5+
from .util import (
46
pack,
57
unpack
68
)
9+
from git.objects import Blob
710

8-
from binascii import (
9-
b2a_hex,
10-
)
1111

12-
from git.objects import Blob
1312
__all__ = ('BlobFilter', 'BaseIndexEntry', 'IndexEntry')
1413

1514
#{ Invariants

Diff for: git/objects/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
from .base import *
88
# Fix import dependency - add IndexObject to the util module, so that it can be
99
# imported by the submodule.base
10-
from .submodule import util
11-
util.IndexObject = IndexObject
12-
util.Object = Object
10+
from .submodule import util as smutil
11+
smutil.IndexObject = IndexObject
12+
smutil.Object = Object
13+
del(smutil)
1314
from .submodule.base import *
1415
from .submodule.root import *
1516

Diff for: git/objects/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6+
from .util import get_object_type_by_name
67
from git.util import LazyMixin, join_path_native, stream_copy
7-
from util import get_object_type_by_name
88
from gitdb.util import (
99
bin_to_hex,
1010
basename

Diff for: git/objects/blob.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
76
from mimetypes import guess_type
8-
import base
7+
from . import base
98

109
__all__ = ('Blob', )
1110

Diff for: git/objects/commit.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,32 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

7+
from gitdb import IStream
8+
from gitdb.util import hex_to_bin
79
from git.util import (
810
Actor,
911
Iterable,
1012
Stats,
1113
finalize_process
1214
)
1315
from git.diff import Diffable
14-
from tree import Tree
15-
from gitdb import IStream
16-
from cStringIO import StringIO
1716

18-
import base
19-
from gitdb.util import (
20-
hex_to_bin
21-
)
22-
from util import (
17+
from .tree import Tree
18+
from . import base
19+
from .util import (
2320
Traversable,
2421
Serializable,
2522
parse_date,
2623
altz_to_utctz_str,
2724
parse_actor_and_date
2825
)
26+
2927
from time import (
3028
time,
3129
altzone
3230
)
3331
import os
32+
from io import StringIO
3433
import logging
3534

3635
log = logging.getLogger('git.objects.commit')

Diff for: git/objects/submodule/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import util
2-
from util import (
1+
from . import util
2+
from .util import (
33
mkhead,
44
sm_name,
55
sm_section,
@@ -8,7 +8,7 @@
88
find_first_remote_branch
99
)
1010
from git.objects.util import Traversable
11-
from StringIO import StringIO # need a dict to set bloody .name field
11+
from io import StringIO # need a dict to set bloody .name field
1212
from git.util import (
1313
Iterable,
1414
join_path_native,

Diff for: git/objects/submodule/root.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
from base import Submodule, UpdateProgress
2-
from util import (
1+
from .base import (
2+
Submodule,
3+
UpdateProgress
4+
)
5+
from .util import (
36
find_first_remote_branch
47
)
58
from git.exc import InvalidGitRepositoryError

Diff for: git/objects/submodule/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import git
22
from git.exc import InvalidGitRepositoryError
33
from git.config import GitConfigParser
4-
from StringIO import StringIO
4+
from io import StringIO
55
import weakref
66

77
__all__ = ('sm_section', 'sm_name', 'mkhead', 'unbare_repo', 'find_first_remote_branch',

Diff for: git/objects/tag.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
""" Module containing all object based types. """
7-
import base
8-
from gitdb.util import hex_to_bin
9-
from util import (
7+
from . import base
8+
from .util import (
109
get_object_type_by_name,
1110
parse_actor_and_date
1211
)
12+
from gitdb.util import hex_to_bin
1313

1414
__all__ = ("TagObject", )
1515

Diff for: git/objects/tree.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
import util
7-
from base import IndexObject
86
from git.util import join_path
9-
from blob import Blob
10-
from submodule.base import Submodule
117
import git.diff as diff
8+
from gitdb.util import to_bin_sha
129

13-
from fun import (
10+
from . import util
11+
from .base import IndexObject
12+
from .blob import Blob
13+
from .submodule.base import Submodule
14+
15+
from .fun import (
1416
tree_entries_from_data,
1517
tree_to_stream
1618
)
1719

18-
from gitdb.util import (
19-
to_bin_sha,
20-
)
21-
2220
__all__ = ("TreeModifier", "Tree")
2321

2422

0 commit comments

Comments
 (0)