1919)
2020from git .compat import (
2121xrange ,
22- string_types
22+ string_types ,
23+ defenc
2324)
2425
2526import time
@@ -38,9 +39,8 @@ class RefLogEntry(tuple):
3839def __repr__ (self ):
3940"""Representation of ourselves in git reflog format"""
4041act = self .actor
41- name = act .name .encode ('utf-8' )
4242time = 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 ,
4444time [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
8383def from_line (cls ,line ):
8484""":return: New RefLogEntry instance from the given revlog line.
85- :param line: line without trailing newline
85+ :param line: linebytes without trailing newline
8686 :raise ValueError: If line could not be parsed"""
87+ line = line .decode (defenc )
8788try :
8889info ,msg = line .split ('\t ' ,1 )
8990except ValueError :
@@ -253,15 +254,18 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
253254# END handle sha type
254255assure_directory_exists (filepath ,is_file = True )
255256committer = 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
259263lf = LockFile (filepath )
260264lf ._obtain_lock_or_raise ()
261265
262- fd = open (filepath ,'a ' )
266+ fd = open (filepath ,'ab ' )
263267try :
264- fd .write (repr (entry ))
268+ fd .write (repr (entry ). encode ( defenc ) )
265269finally :
266270fd .close ()
267271lf ._release_lock ()
@@ -286,7 +290,7 @@ def _serialize(self, stream):
286290
287291# write all entries
288292for e in self :
289- write (repr (e ))
293+ write (repr (e ). encode ( defenc ) )
290294# END for each entry
291295
292296def _deserialize (self ,stream ):