File tree 3 files changed +26
-22
lines changed
3 files changed +26
-22
lines changed Original file line number Diff line number Diff line change 17
17
from itertools import islice
18
18
19
19
from gitdb .utils .compat import izip
20
+ from gitdb .typ import (
21
+ str_blob_type ,
22
+ str_commit_type ,
23
+ str_tree_type ,
24
+ str_tag_type ,
25
+ )
20
26
21
27
from io import StringIO
22
28
27
33
28
34
type_id_to_type_map = {
29
35
0 : "" , # EXT 1
30
- 1 : "commit" ,
31
- 2 : "tree" ,
32
- 3 : "blob" ,
33
- 4 : "tag" ,
36
+ 1 : str_commit_type ,
37
+ 2 : str_tree_type ,
38
+ 3 : str_blob_type ,
39
+ 4 : str_tag_type ,
34
40
5 : "" , # EXT 2
35
41
OFS_DELTA : "OFS_DELTA" , # OFFSET DELTA
36
42
REF_DELTA : "REF_DELTA" # REFERENCE DELTA
37
43
}
38
44
39
- type_to_type_id_map = dict (
40
- commit = 1 ,
41
- tree = 2 ,
42
- blob = 3 ,
43
- tag = 4 ,
44
- OFS_DELTA = OFS_DELTA ,
45
- REF_DELTA = REF_DELTA
46
- )
45
+ type_to_type_id_map = {
46
+ str_commit_type : 1 ,
47
+ str_tree_type : 2 ,
48
+ str_blob_type : 3 ,
49
+ str_tag_type : 4 ,
50
+ " OFS_DELTA" : OFS_DELTA ,
51
+ " REF_DELTA" : REF_DELTA ,
52
+ }
47
53
48
54
# used when dealing with larger streams
49
55
chunk_size = 1000 * mmap .PAGESIZE
@@ -398,7 +404,7 @@ def loose_object_header_info(m):
398
404
hdr = decompressobj ().decompress (m , decompress_size )
399
405
type_name , size = hdr [:hdr .find (NULL_BYTE )].split (" " .encode ("ascii" ))
400
406
401
- return force_text ( type_name ) , int (size )
407
+ return type_name , int (size )
402
408
403
409
def pack_object_header_info (data ):
404
410
"""
Original file line number Diff line number Diff line change 29
29
30
30
from gitdb .const import NULL_BYTE
31
31
from gitdb .utils .compat import buffer
32
- from gitdb .utils .encoding import force_bytes , force_text
32
+ from gitdb .utils .encoding import force_bytes
33
33
34
34
has_perf_mod = False
35
35
try :
@@ -117,7 +117,7 @@ def _parse_header_info(self):
117
117
118
118
self ._phi = True
119
119
120
- return force_text ( typ ) , size
120
+ return typ , size
121
121
122
122
#{ Interface
123
123
Original file line number Diff line number Diff line change 4
4
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
5
5
"""Module containing information about types known to the database"""
6
6
7
- #{ String types
7
+ from gitdb . utils . encoding import force_bytes
8
8
9
- str_blob_type = "blob"
10
- str_commit_type = "commit"
11
- str_tree_type = "tree"
12
- str_tag_type = "tag"
13
-
14
- #} END string types
9
+ str_blob_type = force_bytes ("blob" )
10
+ str_commit_type = force_bytes ("commit" )
11
+ str_tree_type = force_bytes ("tree" )
12
+ str_tag_type = force_bytes ("tag" )
You can’t perform that action at this time.
0 commit comments