Skip to content

Commit 08457a7

Browse files
committed
Added python 2.4 support: Repo will now use the original GitCmdObjectDB in python 2.4, as the pure python implementation cannot work without memory maps
1 parent 3288a24 commit 08457a7

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

lib/git/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def _init_externals():
2929
from git.refs import *
3030
from git.diff import *
3131
from git.exc import *
32+
from git.db import *
3233
from git.cmd import Git
3334
from git.repo import Repo
3435
from git.remote import *

lib/git/db.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ def __init__(self, root_path, git):
3434
self._git = git
3535

3636
def info(self, sha):
37-
t = self._git.get_object_header(bin_to_hex(sha))
38-
return OInfo(*t)
37+
hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
38+
return OInfo(hex_to_bin(hexsha), typename, size)
3939

4040
def stream(self, sha):
4141
"""For now, all lookup is done by git itself"""
42-
t = self._git.stream_object_data(bin_to_hex(sha))
43-
return OStream(*t)
42+
hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(sha))
43+
return OStream(hex_to_bin(hexsha), typename, size, stream)
4444

4545

4646
# { Interface

lib/git/ext/gitdb

Submodule gitdb updated from f534e6e to 18152fe

lib/git/repo/base.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
import sys
3535
import re
3636

37+
DefaultDBType = GitDB
38+
if sys.version_info[1] < 5: # python 2.4 compatiblity
39+
DefaultDBType = GitCmdObjectDB
40+
# END handle python 2.4
41+
3742

3843
__all__ = ('Repo', )
3944

@@ -66,7 +71,7 @@ class Repo(object):
6671
# represents the configuration level of a configuration file
6772
config_level = ("system", "global", "repository")
6873

69-
def __init__(self, path=None, odbt = GitDB):
74+
def __init__(self, path=None, odbt = DefaultDBType):
7075
"""Create a new Repo instance
7176
7277
:param path: is the path to either the root git directory or the bare git repo::

test/git/test_repo.py

+7
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,10 @@ def test_rev_parse(self):
545545

546546
# cannot handle rev-log for now
547547
self.failUnlessRaises(ValueError, rev_parse, "hi@there")
548+
549+
def test_repo_odbtype(self):
550+
target_type = GitDB
551+
if sys.version_info[1] < 5:
552+
target_type = GitCmdObjectDB
553+
assert isinstance(self.rorepo.odb, target_type)
554+

0 commit comments

Comments
 (0)