mercurial/changelog.py
changeset 14380 10546bb7d201
parent 14334 85c82ebc96a3
parent 14379 bd23d5f28bbb
child 14643 7e295dd10d40
equal deleted inserted replaced
14378:1dab7afff11f 14380:10546bb7d201
   203         files = l[3:]
   203         files = l[3:]
   204         return (manifest, user, (time, timezone), files, desc, extra)
   204         return (manifest, user, (time, timezone), files, desc, extra)
   205 
   205 
   206     def add(self, manifest, files, desc, transaction, p1, p2,
   206     def add(self, manifest, files, desc, transaction, p1, p2,
   207                   user, date=None, extra=None):
   207                   user, date=None, extra=None):
       
   208         # Convert to UTF-8 encoded bytestrings as the very first
       
   209         # thing: calling any method on a localstr object will turn it
       
   210         # into a str object and the cached UTF-8 string is thus lost.
       
   211         user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
       
   212 
   208         user = user.strip()
   213         user = user.strip()
   209         # An empty username or a username with a "\n" will make the
   214         # An empty username or a username with a "\n" will make the
   210         # revision text contain two "\n\n" sequences -> corrupt
   215         # revision text contain two "\n\n" sequences -> corrupt
   211         # repository since read cannot unpack the revision.
   216         # repository since read cannot unpack the revision.
   212         if not user:
   217         if not user:
   215             raise error.RevlogError(_("username %s contains a newline")
   220             raise error.RevlogError(_("username %s contains a newline")
   216                                     % repr(user))
   221                                     % repr(user))
   217 
   222 
   218         # strip trailing whitespace and leading and trailing empty lines
   223         # strip trailing whitespace and leading and trailing empty lines
   219         desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
   224         desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
   220 
       
   221         user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
       
   222 
   225 
   223         if date:
   226         if date:
   224             parseddate = "%d %d" % util.parsedate(date)
   227             parseddate = "%d %d" % util.parsedate(date)
   225         else:
   228         else:
   226             parseddate = "%d %d" % util.makedate()
   229             parseddate = "%d %d" % util.makedate()