Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb5a3756

Browse files
committed
test_reflog works
1 parent45c1c99 commitb5a3756

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

‎git/refs/log.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
)
2020
fromgit.compatimport (
2121
xrange,
22-
string_types
22+
string_types,
23+
defenc
2324
)
2425

2526
importtime
@@ -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-
returnself._fmt% (self.oldhexsha,self.newhexsha,name,act.email,
43+
returnself._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
deffrom_line(cls,line):
8484
""":return: New RefLogEntry instance from the given revlog line.
85-
:param line: line without trailing newline
85+
:param line: linebyteswithout 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
exceptValueError:
@@ -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)andconfig_readerorActor.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
foreinself:
289-
write(repr(e))
293+
write(repr(e).encode(defenc))
290294
# END for each entry
291295

292296
def_deserialize(self,stream):

‎git/test/test_reflog.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
RefLog
99
)
1010
fromgit.utilimportActor
11+
fromgitdb.utilimporthex_to_bin
1112

1213
importtempfile
1314
importshutil
@@ -51,7 +52,7 @@ def test_base(self):
5152
assertlen(reflog)
5253

5354
# iter_entries works with path and with stream
54-
assertlen(list(RefLog.iter_entries(open(rlp_master))))
55+
assertlen(list(RefLog.iter_entries(open(rlp_master,'rb'))))
5556
assertlen(list(RefLog.iter_entries(rlp_master)))
5657

5758
# raise on invalid revlog
@@ -65,7 +66,7 @@ def test_base(self):
6566
self.failUnlessRaises(ValueError,RefLog().write)
6667

6768
# test serialize and deserialize - results must match exactly
68-
binsha=chr(255)*20
69+
binsha=hex_to_bin(('f'*40).encode('ascii'))
6970
msg="my reflog message"
7071
cr=self.rorepo.config_reader()
7172
forrlpin (rlp_head,rlp_master):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp