| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,8 @@ | |||
| 19 | 19 | ) | |
| 20 | 20 | from git.compat import ( | |
| 21 | 21 | xrange, | |
| 22 | - string_types | ||
| 22 | + string_types, | ||
| 23 | + defenc | ||
| 23 | 24 | ) | |
| 24 | 25 | ||
| 25 | 26 | import time | |
@@ -38,9 +39,8 @@ class RefLogEntry(tuple): | |||
| 38 | 39 | def __repr__(self): | |
| 39 | 40 | """Representation of ourselves in git reflog format""" | |
| 40 | 41 | act = self.actor | |
| 41 | - name = act.name.encode('utf-8') | ||
| 42 | 42 | 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, | ||
| 44 | 44 | time[0], altz_to_utctz_str(time[1]), self.message) | |
| 45 | 45 | ||
| 46 | 46 | @property | |
@@ -82,8 +82,9 @@ def new(self, oldhexsha, newhexsha, actor, time, tz_offset, message): | |||
| 82 | 82 | @classmethod | |
| 83 | 83 | def from_line(cls, line): | |
| 84 | 84 | """:return: New RefLogEntry instance from the given revlog line. | |
| 85 | - :param line: line without trailing newline | ||
| 85 | + :param line: line bytes without trailing newline | ||
| 86 | 86 | :raise ValueError: If line could not be parsed""" | |
| 87 | + line = line.decode(defenc) | ||
| 87 | 88 | try: | |
| 88 | 89 | info, msg = line.split('\t', 1) | |
| 89 | 90 | except ValueError: | |
@@ -253,15 +254,18 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message): | |||
| 253 | 254 | # END handle sha type | |
| 254 | 255 | assure_directory_exists(filepath, is_file=True) | |
| 255 | 256 | 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 | + )) | ||
| 258 | 262 | ||
| 259 | 263 | lf = LockFile(filepath) | |
| 260 | 264 | lf._obtain_lock_or_raise() | |
| 261 | 265 | ||
| 262 | - fd = open(filepath, 'a') | ||
| 266 | + fd = open(filepath, 'ab') | ||
| 263 | 267 | try: | |
| 264 | - fd.write(repr(entry)) | ||
| 268 | + fd.write(repr(entry).encode(defenc)) | ||
| 265 | 269 | finally: | |
| 266 | 270 | fd.close() | |
| 267 | 271 | lf._release_lock() | |
@@ -286,7 +290,7 @@ def _serialize(self, stream): | |||
| 286 | 290 | ||
| 287 | 291 | # write all entries | |
| 288 | 292 | for e in self: | |
| 289 | - write(repr(e)) | ||
| 293 | + write(repr(e).encode(defenc)) | ||
| 290 | 294 | # END for each entry | |
| 291 | 295 | ||
| 292 | 296 | def _deserialize(self, stream): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | RefLog | |
| 9 | 9 | ) | |
| 10 | 10 | from git.util import Actor | |
| 11 | + from gitdb.util import hex_to_bin | ||
| 11 | 12 | ||
| 12 | 13 | import tempfile | |
| 13 | 14 | import shutil | |
@@ -51,7 +52,7 @@ def test_base(self): | |||
| 51 | 52 | assert len(reflog) | |
| 52 | 53 | ||
| 53 | 54 | # iter_entries works with path and with stream | |
| 54 | - assert len(list(RefLog.iter_entries(open(rlp_master)))) | ||
| 55 | + assert len(list(RefLog.iter_entries(open(rlp_master, 'rb')))) | ||
| 55 | 56 | assert len(list(RefLog.iter_entries(rlp_master))) | |
| 56 | 57 | ||
| 57 | 58 | # raise on invalid revlog | |
@@ -65,7 +66,7 @@ def test_base(self): | |||
| 65 | 66 | self.failUnlessRaises(ValueError, RefLog().write) | |
| 66 | 67 | ||
| 67 | 68 | # test serialize and deserialize - results must match exactly | |
| 68 | - binsha = chr(255) * 20 | ||
| 69 | + binsha = hex_to_bin(('f' * 40).encode('ascii')) | ||
| 69 | 70 | msg = "my reflog message" | |
| 70 | 71 | cr = self.rorepo.config_reader() | |
| 71 | 72 | for rlp in (rlp_head, rlp_master): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments