From 4fd7b945dfca73caf00883d4cf43740edb7516df Mon Sep 17 00:00:00 2001 From: firm1 Date: Thu, 4 Sep 2014 03:38:08 +0200 Subject: add support of utf8 --- git/refs/log.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'git/refs/log.py') diff --git a/git/refs/log.py b/git/refs/log.py index 8ce98d30..c6f9a218 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -32,7 +32,6 @@ __all__ = ["RefLog", "RefLogEntry"] class RefLogEntry(tuple): """Named tuple allowing easy access to the revlog data fields""" - _fmt = "%s %s %s <%s> %i %s\t%s\n" _re_hexsha_only = re.compile('^[0-9A-Fa-f]{40}$') __slots__ = tuple() @@ -40,9 +39,8 @@ class RefLogEntry(tuple): """Representation of ourselves in git reflog format""" act = self.actor time = self.time - return self._fmt % (self.oldhexsha, self.newhexsha, act.name, act.email, - time[0], altz_to_utctz_str(time[1]), self.message) - + return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, self.newhexsha, act.name, act.email, + time[0], altz_to_utctz_str(time[1]), self.message).encode("utf-8") @property def oldhexsha(self): """The hexsha to the commit the ref pointed to before the change""" @@ -267,7 +265,6 @@ class RefLog(list, Serializable): lf = LockFile(filepath) lf._obtain_lock_or_raise() - fd = open(filepath, 'ab') try: fd.write(repr(entry).encode(defenc)) -- cgit v1.2.1 From b6ed8d46c72366e111b9a97a7c238ef4af3bf4dc Mon Sep 17 00:00:00 2001 From: firm1 Date: Wed, 7 Jan 2015 13:51:48 +0100 Subject: fix pep8 --- git/refs/log.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'git/refs/log.py') diff --git a/git/refs/log.py b/git/refs/log.py index c6f9a218..ec19c1e8 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -39,8 +39,14 @@ class RefLogEntry(tuple): """Representation of ourselves in git reflog format""" act = self.actor time = self.time - return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, self.newhexsha, act.name, act.email, - time[0], altz_to_utctz_str(time[1]), self.message).encode("utf-8") + return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, + self.newhexsha, + act.name, + act.email, + time[0], + altz_to_utctz_str(time[1]), + self.message).encode("utf-8") + @property def oldhexsha(self): """The hexsha to the commit the ref pointed to before the change""" -- cgit v1.2.1