1919)
2020from git .compat import (
2121 xrange ,
22- string_types
22+ string_types ,
23+ defenc
2324)
2425
2526import time
@@ -38,9 +39,8 @@ class RefLogEntry(tuple):
3839 def __repr__ (self ):
3940 """Representation of ourselves in git reflog format"""
4041 act = self .actor
41- name = act .name .encode ('utf-8' )
4242 time = self .time
43- return self ._fmt % (self .oldhexsha , self .newhexsha , name , act .email ,
43+ return self ._fmt % (self .oldhexsha , self .newhexsha , act . name , act .email ,
4444 time [0 ], altz_to_utctz_str (time [1 ]), self .message )
4545
4646 @property
@@ -82,8 +82,9 @@ def new(self, oldhexsha, newhexsha, actor, time, tz_offset, message):
8282 @classmethod
8383 def from_line (cls , line ):
8484 """:return: New RefLogEntry instance from the given revlog line.
85- :param line: line without trailing newline
85+ :param line: line bytes without trailing newline
8686 :raise ValueError: If line could not be parsed"""
87+ line = line .decode (defenc )
8788 try :
8889 info , msg = line .split ('\t ' , 1 )
8990 except ValueError :
@@ -253,15 +254,18 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
253254 # END handle sha type
254255 assure_directory_exists (filepath , is_file = True )
255256 committer = isinstance (config_reader , Actor ) and config_reader or Actor .committer (config_reader )
256- entry = RefLogEntry (
257- (bin_to_hex (oldbinsha ), bin_to_hex (newbinsha ), committer , (int (time .time ()), time .altzone ), message ))
257+ entry = RefLogEntry ((
258+ bin_to_hex (oldbinsha ).decode ('ascii' ),
259+ bin_to_hex (newbinsha ).decode ('ascii' ),
260+ committer , (int (time .time ()), time .altzone ), message
261+ ))
258262
259263 lf = LockFile (filepath )
260264 lf ._obtain_lock_or_raise ()
261265
262- fd = open (filepath , 'a ' )
266+ fd = open (filepath , 'ab ' )
263267 try :
264- fd .write (repr (entry ))
268+ fd .write (repr (entry ). encode ( defenc ) )
265269 finally :
266270 fd .close ()
267271 lf ._release_lock ()
@@ -286,7 +290,7 @@ def _serialize(self, stream):
286290
287291 # write all entries
288292 for e in self :
289- write (repr (e ))
293+ write (repr (e ). encode ( defenc ) )
290294 # END for each entry
291295
292296 def _deserialize (self , stream ):
0 commit comments