##// END OF EJS Templates
changelog: convert user and desc from local encoding early...
Martin Geisler -
r14379:bd23d5f2 stable
parent child Browse files
Show More
@@ -199,6 +199,11 b' class changelog(revlog.revlog):'
199
199
200 def add(self, manifest, files, desc, transaction, p1, p2,
200 def add(self, manifest, files, desc, transaction, p1, p2,
201 user, date=None, extra=None):
201 user, date=None, extra=None):
202 # Convert to UTF-8 encoded bytestrings as the very first
203 # thing: calling any method on a localstr object will turn it
204 # into a str object and the cached UTF-8 string is thus lost.
205 user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
206
202 user = user.strip()
207 user = user.strip()
203 # An empty username or a username with a "\n" will make the
208 # An empty username or a username with a "\n" will make the
204 # revision text contain two "\n\n" sequences -> corrupt
209 # revision text contain two "\n\n" sequences -> corrupt
@@ -212,8 +217,6 b' class changelog(revlog.revlog):'
212 # strip trailing whitespace and leading and trailing empty lines
217 # strip trailing whitespace and leading and trailing empty lines
213 desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
218 desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
214
219
215 user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
216
217 if date:
220 if date:
218 parseddate = "%d %d" % util.parsedate(date)
221 parseddate = "%d %d" % util.parsedate(date)
219 else:
222 else:
@@ -1,5 +1,5 b''
1 import os
1 import os
2 from mercurial import hg, ui
2 from mercurial import hg, ui, context, encoding
3
3
4 u = ui.ui()
4 u = ui.ui()
5
5
@@ -17,3 +17,16 b" repo[None].add(['foo'])"
17 repo.commit(text='commit1', date="0 0")
17 repo.commit(text='commit1', date="0 0")
18
18
19 print "workingfilectx.date =", repo[None]['foo'].date()
19 print "workingfilectx.date =", repo[None]['foo'].date()
20
21 # test memctx with non-ASCII commit message
22
23 def filectxfn(repo, memctx, path):
24 return context.memfilectx("foo", "")
25
26 ctx = context.memctx(repo, ['tip', None],
27 encoding.tolocal("Gr\xc3\xbcezi!"),
28 ["foo"], filectxfn)
29 ctx.commit()
30 for enc in "ASCII", "Latin-1", "UTF-8":
31 encoding.encoding = enc
32 print "%-8s: %s" % (enc, repo["tip"].description())
@@ -1,1 +1,4 b''
1 workingfilectx.date = (1000, 0)
1 workingfilectx.date = (1000, 0)
2 ASCII : Gr?ezi!
3 Latin-1 : Gr�ezi!
4 UTF-8 : Grüezi!
General Comments 0
You need to be logged in to leave comments. Login now