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

Commit1fe889e

Browse files
committed
All tests adjusted to work with the changed internal sha representation
1 parent47e3138 commit1fe889e

File tree

19 files changed

+198
-173
lines changed

19 files changed

+198
-173
lines changed

‎lib/git/diff.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
fromobjects.blobimportBlob
99
fromobjects.utilsimportmode_str_to_int
1010
fromerrorsimportGitCommandError
11+
12+
fromgitdb.utilimporthex_to_bin
1113

1214
__all__= ('Diffable','DiffIndex','Diff')
1315

@@ -197,11 +199,11 @@ def __init__(self, repo, a_path, b_path, a_blob_id, b_blob_id, a_mode,
197199
ifa_blob_idisNone:
198200
self.a_blob=None
199201
else:
200-
self.a_blob=Blob(repo,a_blob_id,mode=a_mode,path=a_path)
202+
self.a_blob=Blob(repo,hex_to_bin(a_blob_id),mode=a_mode,path=a_path)
201203
ifb_blob_idisNone:
202204
self.b_blob=None
203205
else:
204-
self.b_blob=Blob(repo,b_blob_id,mode=b_mode,path=b_path)
206+
self.b_blob=Blob(repo,hex_to_bin(b_blob_id),mode=b_mode,path=b_path)
205207

206208
self.a_mode=a_mode
207209
self.b_mode=b_mode

‎lib/git/objects/blob.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
__all__= ('Blob', )
1111

1212
classBlob(base.IndexObject):
13-
"""A Blob encapsulates a git blob object"""
14-
DEFAULT_MIME_TYPE="text/plain"
15-
type="blob"
13+
"""A Blob encapsulates a git blob object"""
14+
DEFAULT_MIME_TYPE="text/plain"
15+
type="blob"
1616

17-
__slots__="data"
17+
__slots__="data"
1818

1919
def_set_cache_(self,attr):
2020
ifattr=="data":
@@ -26,11 +26,11 @@ def _set_cache_(self, attr):
2626
super(Blob,self)._set_cache_(attr)
2727
# END handle data
2828

29-
@property
30-
defmime_type(self):
31-
""" :return:String describing the mime type of this file (based on the filename)
32-
:note: Defaults to 'text/plain' in case the actual file type is unknown. """
33-
guesses=None
34-
ifself.path:
35-
guesses=guess_type(self.path)
36-
returnguessesandguesses[0]orself.DEFAULT_MIME_TYPE
29+
@property
30+
defmime_type(self):
31+
""" :return:String describing the mime type of this file (based on the filename)
32+
:note: Defaults to 'text/plain' in case the actual file type is unknown. """
33+
guesses=None
34+
ifself.path:
35+
guesses=guess_type(self.path)
36+
returnguessesandguesses[0]orself.DEFAULT_MIME_TYPE

‎lib/git/objects/commit.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
get_user_id,
2424
parse_date,
2525
Actor,
26-
altz_to_utctz_str
26+
altz_to_utctz_str,
2727
parse_actor_and_date
2828
)
2929
fromtimeimport (
3030
time,
3131
altzone
3232
)
33+
importos
3334

3435
__all__= ('Commit', )
3536

@@ -76,7 +77,7 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
7677
:param parents: tuple( Commit, ... )
7778
is a tuple of commit ids or actual Commits
7879
:param tree: Tree
79-
20 byte tree sha
80+
Tree object
8081
:param author: Actor
8182
is the author string ( will be implicitly converted into an Actor object )
8283
:param authored_date: int_seconds_since_epoch
@@ -103,7 +104,7 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
103104
:note: Timezone information is in the same format and in the same sign
104105
as what time.altzone returns. The sign is inverted compared to git's
105106
UTC timezone."""
106-
super(Commit,self).__init__(repo,sha)
107+
super(Commit,self).__init__(repo,binsha)
107108
self._set_self_from_args_(locals())
108109

109110
@classmethod
@@ -227,14 +228,14 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
227228
line=readline()
228229
ifnotline:
229230
break
230-
sha=line.strip()
231-
iflen(sha)>40:
231+
hexsha=line.strip()
232+
iflen(hexsha)>40:
232233
# split additional information, as returned by bisect for instance
233-
sha,rest=line.split(None,1)
234+
hexsha,rest=line.split(None,1)
234235
# END handle extra info
235236

236-
assertlen(sha)==40,"Invalid line: %s"%sha
237-
yieldCommit(repo,sha)
237+
assertlen(hexsha)==40,"Invalid line: %s"%hexsha
238+
yieldCommit(repo,hex_to_bin(hexsha))
238239
# END for each line in stream
239240

240241

@@ -282,7 +283,7 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False):
282283

283284
# COMMITER AND AUTHOR INFO
284285
cr=repo.config_reader()
285-
env=environ
286+
env=os.environ
286287
default_email=get_user_id()
287288
default_name=default_email.split('@')[0]
288289

‎lib/git/objects/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, repo, binsha, object=None, tag=None,
3232
it into a different format
3333
:param tagged_tz_offset: int_seconds_west_of_utc is the timezone that the
3434
authored_date is in, in a format similar to time.altzone"""
35-
super(TagObject,self).__init__(repo,sha )
35+
super(TagObject,self).__init__(repo,binsha )
3636
self._set_self_from_args_(locals())
3737

3838
def_set_cache_(self,attr):

‎lib/git/objects/tree.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
tree_to_stream
1616
)
1717

18-
fromgitdb.utilimportto_bin_sha
18+
fromgitdb.utilimport (
19+
to_bin_sha,
20+
join
21+
)
1922

2023
__all__= ("TreeModifier","Tree")
2124

@@ -61,7 +64,7 @@ def add(self, sha, mode, name, force=False):
6164
:return: self"""
6265
if'/'inname:
6366
raiseValueError("Name must not contain '/' characters")
64-
if (mode>>12)notinself._map_id_to_type:
67+
if (mode>>12)notinTree._map_id_to_type:
6568
raiseValueError("Invalid object type according to mode %o"%mode)
6669

6770
sha=to_bin_sha(sha)
@@ -150,7 +153,7 @@ def _iter_convert_to_object(self, iterable):
150153
forbinsha,mode,nameiniterable:
151154
path=join(self.path,name)
152155
try:
153-
yieldself._map_id_to_type[type_id](self.repo,binsha,mode>>12,path)
156+
yieldself._map_id_to_type[mode>>12](self.repo,binsha,mode,path)
154157
exceptKeyError:
155158
raiseTypeError("Unknown mode %o found in tree data for path '%s'"% (mode,path))
156159
# END for each item

‎lib/git/refs.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
isdir,
2626
exists,
2727
isfile,
28-
rename
28+
rename,
29+
hex_to_bin
2930
)
3031

3132

@@ -147,11 +148,11 @@ def _get_commit(self):
147148
Commit object we point to, works for detached and non-detached
148149
SymbolicReferences"""
149150
# we partially reimplement it to prevent unnecessary file access
150-
sha,target_ref_path=self._get_ref_info()
151+
hexsha,target_ref_path=self._get_ref_info()
151152

152153
# it is a detached reference
153-
ifsha:
154-
returnCommit(self.repo,sha)
154+
ifhexsha:
155+
returnCommit(self.repo,hex_to_bin(hexsha))
155156

156157
returnself.from_path(self.repo,target_ref_path).commit
157158

@@ -402,9 +403,9 @@ def rename(self, new_path, force=False):
402403
os.remove(new_abs_path)
403404
# END handle existing target file
404405

405-
dirname=dirname(new_abs_path)
406-
ifnotisdir(dirname):
407-
os.makedirs(dirname)
406+
dname=dirname(new_abs_path)
407+
ifnotisdir(dname):
408+
os.makedirs(dname)
408409
# END create directory
409410

410411
rename(cur_abs_path,new_abs_path)

‎lib/git/remote.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
TagReference
2222
)
2323

24-
fromgitdb.utilimportjoin
24+
fromgitdb.utilimport (
25+
join,
26+
)
2527
importre
2628

2729
__all__= ('RemoteProgress','PushInfo','FetchInfo','Remote')
@@ -256,7 +258,8 @@ def _from_line(cls, remote, line):
256258
ifcontrol_character==" ":
257259
split_token=".."
258260
old_sha,new_sha=summary.split(' ')[0].split(split_token)
259-
old_commit=Commit(remote.repo,old_sha)
261+
# have to use constructor here as the sha usually is abbreviated
262+
old_commit=remote.repo.commit(old_sha)
260263
# END message handling
261264

262265
returnPushInfo(flags,from_ref,to_ref_string,remote,old_commit,summary)

‎lib/git/repo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
fromgitdb.utilimport (
2222
join,
2323
isdir,
24-
isfile
24+
isfile,
25+
hex_to_bin
2526
)
2627
importos
2728
importsys
@@ -576,7 +577,7 @@ def blame(self, rev, file):
576577
sha=info['id']
577578
c=commits.get(sha)
578579
ifcisNone:
579-
c=Commit(self,sha,
580+
c=Commit(self,hex_to_bin(sha),
580581
author=Actor._from_string(info['author']+' '+info['author_email']),
581582
authored_date=info['author_date'],
582583
committer=Actor._from_string(info['committer']+' '+info['committer_email']),

‎lib/git/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
to_bin_sha
1919
)
2020

21+
__all__= ("stream_copy","join_path","to_native_path_windows","to_native_path_linux",
22+
"join_path_native","Stats","IndexFileSHA1Writer","Iterable","IterableList",
23+
"BlockingLockFile","LockFile" )
2124

2225
defstream_copy(source,destination,chunk_size=512*1024):
2326
"""Copy all data from the source stream into the destination stream in chunks
@@ -104,7 +107,7 @@ def _list_from_string(cls, repo, text):
104107
"""Create a Stat object from output retrieved by git-diff.
105108
106109
:return: git.Stat"""
107-
hsh= {'total': {'insertions':0,'deletions':0,'lines':0,'files':0},'files':{}}
110+
hsh= {'total': {'insertions':0,'deletions':0,'lines':0,'files':0},'files':dict()}
108111
forlineintext.splitlines():
109112
(raw_insertions,raw_deletions,filename)=line.split("\t")
110113
insertions=raw_insertions!='-'andint(raw_insertions)or0
@@ -305,6 +308,7 @@ def __getitem__(self, index):
305308
exceptAttributeError:
306309
raiseIndexError("No item found with id %r"% (self._prefix+index) )
307310

311+
308312
classIterable(object):
309313
"""Defines an interface for iterable items which is to assure a uniform
310314
way to retrieve and iterate items within the git repository"""

‎test/fixtures/diff_new_mode

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
diff --git a/conf/global_settings.py b/conf/global_settings.py
22
old mode 100644
33
new mode 100755
4-
index9ec1bac..1c4f83b
4+
index9ec1bac000000000000000000000000000000000..1c4f83b000000000000000000000000000000000
55
--- a/conf/global_settings.py
66
+++ b/conf/global_settings.py
77
@@ -58,6 +58,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp