Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb82dbf5

Browse files
committed
GitCmd implementation of gitdb base moved to git-python where it belongs. Previously it was located in gitdb, which doesn't have any facilities to use the git command
1 parente837b90 commitb82dbf5

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

‎lib/git/db.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Module with our own gitdb implementation - it uses the git command"""
2+
fromgitdb.baseimport (
3+
OInfo,
4+
OStream
5+
)
6+
7+
fromgitdb.dbimportLooseObjectDB
8+
9+
__all__= ('GitCmdObjectDB', )
10+
11+
#class GitCmdObjectDB(CompoundDB, ObjectDBW):
12+
classGitCmdObjectDB(LooseObjectDB):
13+
"""A database representing the default git object store, which includes loose
14+
objects, pack files and an alternates file
15+
16+
It will create objects only in the loose object database.
17+
:note: for now, we use the git command to do all the lookup, just until he
18+
have packs and the other implementations
19+
"""
20+
def__init__(self,root_path,git):
21+
"""Initialize this instance with the root and a git command"""
22+
super(GitCmdObjectDB,self).__init__(root_path)
23+
self._git=git
24+
25+
definfo(self,sha):
26+
t=self._git.get_object_header(sha)
27+
returnOInfo(*t)
28+
29+
defstream(self,sha):
30+
"""For now, all lookup is done by git itself"""
31+
t=self._git.stream_object_data(sha)
32+
returnOStream(*t)
33+

‎lib/git/ext/gitdb

Submodule gitdb updated from 099ec0d to 3cee78e

‎lib/git/repo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
fromconfigimportGitConfigParser
1414
fromremoteimportRemote
1515

16-
fromgitdbimportGitObjectDB
16+
fromdbimportGitCmdObjectDB
1717

1818
importos
1919
importsys
@@ -68,7 +68,7 @@ class Repo(object):
6868
# represents the configuration level of a configuration file
6969
config_level= ("system","global","repository")
7070

71-
def__init__(self,path=None,odbt=GitObjectDB):
71+
def__init__(self,path=None,odbt=GitCmdObjectDB):
7272
""" Create a new Repo instance
7373
7474
:param path: is the path to either the root git directory or the bare git repo::
@@ -131,7 +131,7 @@ def __init__(self, path=None, odbt = GitObjectDB):
131131

132132
# special handling, in special times
133133
args= [os.path.join(self.git_dir,'objects')]
134-
ifissubclass(odbt,GitObjectDB):
134+
ifissubclass(odbt,GitCmdObjectDB):
135135
args.append(self.git)
136136
self.odb=odbt(*args)
137137

‎lib/git/utils.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
importtempfile
1111

1212
fromgitdb.utilimport (
13-
stream_copy,
1413
make_sha,
1514
FDStreamWrapper,
1615
LockedFD,
@@ -19,6 +18,21 @@
1918
)
2019

2120

21+
defstream_copy(source,destination,chunk_size=512*1024):
22+
"""Copy all data from the source stream into the destination stream in chunks
23+
of size chunk_size
24+
25+
:return: amount of bytes written"""
26+
br=0
27+
whileTrue:
28+
chunk=source.read(chunk_size)
29+
destination.write(chunk)
30+
br+=len(chunk)
31+
iflen(chunk)<chunk_size:
32+
break
33+
# END reading output stream
34+
returnbr
35+
2236
defjoin_path(a,*p):
2337
"""Join path tokens together similar to os.path.join, but always use
2438
'/' instead of possibly '\' on windows."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp