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

Commitb02662d

Browse files
committed
src: reduce needless deps togitdb.util
1 parent0210e39 commitb02662d

21 files changed

+124
-151
lines changed

‎git/db.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""Module with our own gitdb implementation - it uses the git command"""
2+
fromgit.utilimportbin_to_hex,hex_to_bin
23
fromgitdb.baseimport (
34
OInfo,
45
OStream
56
)
6-
fromgitdb.utilimport (
7-
bin_to_hex,
8-
hex_to_bin
9-
)
107
fromgitdb.dbimportGitDB# @UnusedImport
118
fromgitdb.dbimportLooseObjectDB
129

‎git/diff.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
importre
77

8-
fromgitdb.utilimporthex_to_bin
8+
fromgit.cmdimporthandle_process_output
9+
fromgit.compatimport (
10+
defenc,
11+
PY3
12+
)
13+
fromgit.utilimportfinalize_process,hex_to_bin
914

1015
from .compatimportbinary_type
1116
from .objects.blobimportBlob
1217
from .objects.utilimportmode_str_to_int
1318

14-
fromgit.compatimport (
15-
defenc,
16-
PY3
17-
)
18-
fromgit.cmdimporthandle_process_output
19-
fromgit.utilimportfinalize_process
2019

2120
__all__= ('Diffable','DiffIndex','Diff','NULL_TREE')
2221

‎git/index/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
join_path_native,
4040
file_contents_ro,
4141
to_native_path_linux,
42-
unbare_repo
42+
unbare_repo,
43+
to_bin_sha
4344
)
4445
fromgitdb.baseimportIStream
4546
fromgitdb.dbimportMemoryDB
46-
fromgitdb.utilimportto_bin_sha
4747

4848
importgit.diffasdiff
4949
importos.pathasosp

‎git/objects/base.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +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-
from .utilimportget_object_type_by_name
7-
fromgit.utilimportLazyMixin,join_path_native,stream_copy
8-
fromgitdb.utilimport (
9-
bin_to_hex,
10-
basename
11-
)
6+
fromgit.utilimportLazyMixin,join_path_native,stream_copy,bin_to_hex
127

138
importgitdb.typasdbtyp
9+
importos.pathasosp
10+
11+
from .utilimportget_object_type_by_name
12+
1413

1514
_assertion_msg_format="Created object %r whose python type %r disagrees with the acutal git object type %r"
1615

@@ -170,7 +169,7 @@ def _set_cache_(self, attr):
170169
@property
171170
defname(self):
172171
""":return: Name portion of the path, effectively being the basename"""
173-
returnbasename(self.path)
172+
returnosp.basename(self.path)
174173

175174
@property
176175
defabspath(self):

‎git/objects/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
fromgitdbimportIStream
8-
fromgitdb.utilimporthex_to_bin
98
fromgit.utilimport (
9+
hex_to_bin,
1010
Actor,
1111
Iterable,
1212
Stats,

‎git/objects/tag.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
""" Module containing all object based types. """
77
from .importbase
8-
from .utilimport (
9-
get_object_type_by_name,
10-
parse_actor_and_date
11-
)
12-
fromgitdb.utilimporthex_to_bin
13-
fromgit.compatimportdefenc
8+
from .utilimportget_object_type_by_name,parse_actor_and_date
9+
from ..utilimporthex_to_bin
10+
from ..compatimportdefenc
1411

1512
__all__= ("TagObject", )
1613

‎git/objects/tree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
fromgit.utilimportjoin_path
77
importgit.diffasdiff
8-
fromgitdb.utilimportto_bin_sha
8+
fromgit.utilimportto_bin_sha
99

1010
from .importutil
1111
from .baseimportIndexObject
@@ -18,7 +18,7 @@
1818
tree_to_stream
1919
)
2020

21-
fromgitdb.utils.compatimportPY3
21+
fromgit.compatimportPY3
2222

2323
ifPY3:
2424
cmp=lambdaa,b: (a>b)- (a<b)

‎git/refs/log.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1+
importre
2+
importtime
3+
4+
fromgit.compatimport (
5+
PY3,
6+
xrange,
7+
string_types,
8+
defenc
9+
)
10+
fromgit.objects.utilimport (
11+
parse_date,
12+
Serializable,
13+
altz_to_utctz_str,
14+
)
115
fromgit.utilimport (
216
Actor,
317
LockedFD,
418
LockFile,
519
assure_directory_exists,
620
to_native_path,
7-
)
8-
9-
fromgitdb.utilimport (
1021
bin_to_hex,
11-
join,
12-
file_contents_ro_filepath,
22+
file_contents_ro_filepath
1323
)
1424

15-
fromgit.objects.utilimport (
16-
parse_date,
17-
Serializable,
18-
altz_to_utctz_str,
19-
)
20-
fromgit.compatimport (
21-
PY3,
22-
xrange,
23-
string_types,
24-
defenc
25-
)
25+
importos.pathasosp
2626

27-
importtime
28-
importre
2927

3028
__all__= ["RefLog","RefLogEntry"]
3129

@@ -185,7 +183,7 @@ def path(cls, ref):
185183
instance would be found. The path is not guaranteed to point to a valid
186184
file though.
187185
:param ref: SymbolicReference instance"""
188-
returnjoin(ref.repo.git_dir,"logs",to_native_path(ref.path))
186+
returnosp.join(ref.repo.git_dir,"logs",to_native_path(ref.path))
189187

190188
@classmethod
191189
defiter_entries(cls,stream):

‎git/refs/remote.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
importos
2+
13
fromgit.utilimportjoin_path
2-
fromgitdb.utilimportjoin
34

4-
from .headimportHead
5+
importos.pathasosp
56

6-
importos
7+
from .headimportHead
78

89

910
__all__= ["RemoteReference"]
@@ -36,7 +37,7 @@ def delete(cls, repo, *refs, **kwargs):
3637
# and delete remainders manually
3738
forrefinrefs:
3839
try:
39-
os.remove(join(repo.git_dir,ref.path))
40+
os.remove(osp.join(repo.git_dir,ref.path))
4041
exceptOSError:
4142
pass
4243
# END for each ref

‎git/refs/symbolic.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,14 @@
99
join_path,
1010
join_path_native,
1111
to_native_path_linux,
12-
assure_directory_exists
12+
assure_directory_exists,
13+
hex_to_bin,
14+
LockedFD
1315
)
1416
fromgitdb.excimport (
1517
BadObject,
1618
BadName
1719
)
18-
fromgitdb.utilimport (
19-
join,
20-
dirname,
21-
isdir,
22-
exists,
23-
isfile,
24-
rename,
25-
hex_to_bin,
26-
LockedFD
27-
)
2820

2921
importos.pathasosp
3022

@@ -83,7 +75,7 @@ def abspath(self):
8375

8476
@classmethod
8577
def_get_packed_refs_path(cls,repo):
86-
returnjoin(repo.git_dir,'packed-refs')
78+
returnosp.join(repo.git_dir,'packed-refs')
8779

8880
@classmethod
8981
def_iter_packed_refs(cls,repo):
@@ -136,7 +128,7 @@ def _get_ref_info(cls, repo, ref_path):
136128
point to, or None"""
137129
tokens=None
138130
try:
139-
withopen(join(repo.git_dir,ref_path),'rt')asfp:
131+
withopen(osp.join(repo.git_dir,ref_path),'rt')asfp:
140132
value=fp.read().rstrip()
141133
# Don't only split on spaces, but on whitespace, which allows to parse lines like
142134
# 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo
@@ -420,8 +412,8 @@ def delete(cls, repo, path):
420412
or just "myreference", hence 'refs/' is implied.
421413
Alternatively the symbolic reference to be deleted"""
422414
full_ref_path=cls.to_full_path(path)
423-
abs_path=join(repo.git_dir,full_ref_path)
424-
ifexists(abs_path):
415+
abs_path=osp.join(repo.git_dir,full_ref_path)
416+
ifosp.exists(abs_path):
425417
os.remove(abs_path)
426418
else:
427419
# check packed refs
@@ -472,14 +464,14 @@ def _create(cls, repo, path, resolve, reference, force, logmsg=None):
472464
corresponding object and a detached symbolic reference will be created
473465
instead"""
474466
full_ref_path=cls.to_full_path(path)
475-
abs_ref_path=join(repo.git_dir,full_ref_path)
467+
abs_ref_path=osp.join(repo.git_dir,full_ref_path)
476468

477469
# figure out target data
478470
target=reference
479471
ifresolve:
480472
target=repo.rev_parse(str(reference))
481473

482-
ifnotforceandisfile(abs_ref_path):
474+
ifnotforceandosp.isfile(abs_ref_path):
483475
target_data=str(target)
484476
ifisinstance(target,SymbolicReference):
485477
target_data=target.path
@@ -546,9 +538,9 @@ def rename(self, new_path, force=False):
546538
ifself.path==new_path:
547539
returnself
548540

549-
new_abs_path=join(self.repo.git_dir,new_path)
550-
cur_abs_path=join(self.repo.git_dir,self.path)
551-
ifisfile(new_abs_path):
541+
new_abs_path=osp.join(self.repo.git_dir,new_path)
542+
cur_abs_path=osp.join(self.repo.git_dir,self.path)
543+
ifosp.isfile(new_abs_path):
552544
ifnotforce:
553545
# if they point to the same file, its not an error
554546
withopen(new_abs_path,'rb')asfd1:
@@ -563,12 +555,12 @@ def rename(self, new_path, force=False):
563555
os.remove(new_abs_path)
564556
# END handle existing target file
565557

566-
dname=dirname(new_abs_path)
567-
ifnotisdir(dname):
558+
dname=osp.dirname(new_abs_path)
559+
ifnotosp.isdir(dname):
568560
os.makedirs(dname)
569561
# END create directory
570562

571-
rename(cur_abs_path,new_abs_path)
563+
os.rename(cur_abs_path,new_abs_path)
572564
self.path=new_path
573565

574566
returnself

‎git/remote.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,25 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
# Module implementing a remote object allowing easy access to git remotes
8+
importlogging
89
importre
910

11+
fromgit.cmdimporthandle_process_output,Git
12+
fromgit.compatimport (defenc,force_text,is_win)
13+
fromgit.excimportGitCommandError
14+
fromgit.utilimport (
15+
LazyMixin,
16+
Iterable,
17+
IterableList,
18+
RemoteProgress,
19+
CallableRemoteProgress
20+
)
21+
fromgit.utilimport (
22+
join_path,
23+
)
24+
25+
importos.pathasosp
26+
1027
from .configimport (
1128
SectionConstraint,
1229
cp,
@@ -18,21 +35,7 @@
1835
SymbolicReference,
1936
TagReference
2037
)
21-
fromgit.utilimport (
22-
LazyMixin,
23-
Iterable,
24-
IterableList,
25-
RemoteProgress,
26-
CallableRemoteProgress
27-
)
28-
fromgit.utilimport (
29-
join_path,
30-
)
31-
fromgit.cmdimporthandle_process_output,Git
32-
fromgitdb.utilimportjoin
33-
fromgit.compatimport (defenc,force_text,is_win)
34-
importlogging
35-
fromgit.excimportGitCommandError
38+
3639

3740
log=logging.getLogger('git.remote')
3841

@@ -644,7 +647,7 @@ def _get_fetch_info_from_stderr(self, proc, progress):
644647
continue
645648

646649
# read head information
647-
withopen(join(self.repo.git_dir,'FETCH_HEAD'),'rb')asfp:
650+
withopen(osp.join(self.repo.git_dir,'FETCH_HEAD'),'rb')asfp:
648651
fetch_head_info= [l.decode(defenc)forlinfp.readlines()]
649652

650653
l_fil=len(fetch_info_lines)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp