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

Commit00ce31a

Browse files
committed
Objects: Constructor now manually checks and sets the input arguments to the local cache - previously a procedural approach was used, which was less code, but slower too. Especially in case of CommitObjects unrolling the loop manually makes a difference.
Submodule: Implemented query methods and did a bit of testing. More is to come, but the test works for now. As special addition, the submodule implementation uses the section name as submodule ID even though it seems to be just the path. This allows to make renames easier
1 parent4d36f8f commit00ce31a

File tree

5 files changed

+297
-52
lines changed

5 files changed

+297
-52
lines changed

‎lib/git/objects/base.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,6 @@ def new_from_sha(cls, repo, sha1):
6262
inst.size=oinfo.size
6363
returninst
6464

65-
def_set_self_from_args_(self,args_dict):
66-
"""Initialize attributes on self from the given dict that was retrieved
67-
from locals() in the calling method.
68-
69-
Will only set an attribute on self if the corresponding value in args_dict
70-
is not None"""
71-
forattr,valinargs_dict.items():
72-
ifattr!="self"andvalisnotNone:
73-
setattr(self,attr,val )
74-
# END set all non-None attributes
75-
7665
def_set_cache_(self,attr):
7766
"""Retrieve object information"""
7867
ifattr=="size":
@@ -140,7 +129,10 @@ def __init__(self, repo, binsha, mode=None, path=None):
140129
Path may not be set of the index object has been created directly as it cannot
141130
be retrieved without knowing the parent tree."""
142131
super(IndexObject,self).__init__(repo,binsha)
143-
self._set_self_from_args_(locals())
132+
ifmodeisnotNone:
133+
self.mode=mode
134+
ifpathisnotNone:
135+
self.path=path
144136

145137
def__hash__(self):
146138
""":return:

‎lib/git/objects/commit.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,26 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
108108
super(Commit,self).__init__(repo,binsha)
109109
iftreeisnotNone:
110110
assertisinstance(tree,Tree),"Tree needs to be a Tree instance, was %s"%type(tree)
111-
self._set_self_from_args_(locals())
111+
iftreeisnotNone:
112+
self.tree=tree
113+
ifauthorisnotNone:
114+
self.author=author
115+
ifauthored_dateisnotNone:
116+
self.authored_date=authored_date
117+
ifauthor_tz_offsetisnotNone:
118+
self.author_tz_offset=author_tz_offset
119+
ifcommitterisnotNone:
120+
self.committer=committer
121+
ifcommitted_dateisnotNone:
122+
self.committed_date=committed_date
123+
ifcommitter_tz_offsetisnotNone:
124+
self.committer_tz_offset=committer_tz_offset
125+
ifmessageisnotNone:
126+
self.message=message
127+
ifparentsisnotNone:
128+
self.parents=parents
129+
ifencodingisnotNone:
130+
self.encoding=encoding
112131

113132
@classmethod
114133
def_get_intermediate_items(cls,commit):
@@ -434,7 +453,7 @@ def _deserialize(self, stream):
434453
try:
435454
self.author.name=self.author.name.decode(self.encoding)
436455
exceptUnicodeDecodeError:
437-
print>>sys.stderr,"Failed to decode author name: %s"%self.author.name
456+
print>>sys.stderr,"Failed to decode author name '%s' using encoding %s"%(self.author.name,self.encoding)
438457
# END handle author's encoding
439458

440459
# a stream from our data simply gives us the plain message
@@ -443,7 +462,7 @@ def _deserialize(self, stream):
443462
try:
444463
self.message=self.message.decode(self.encoding)
445464
exceptUnicodeDecodeError:
446-
print>>sys.stderr,"Failed to decode message: %s"%self.message
465+
print>>sys.stderr,"Failed to decode message '%s' using encoding %s"%(self.message,self.encoding)
447466
# END exception handling
448467
returnself
449468

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp