mercurial/changelog.py
branchstable
changeset 14379 bd23d5f28bbb
parent 10420 41d0ed2c79df
child 14380 10546bb7d201
equal deleted inserted replaced
14360:ab687820c4cc 14379:bd23d5f28bbb
   197         files = l[3:]
   197         files = l[3:]
   198         return (manifest, user, (time, timezone), files, desc, extra)
   198         return (manifest, user, (time, timezone), files, desc, extra)
   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
   205         # repository since read cannot unpack the revision.
   210         # repository since read cannot unpack the revision.
   206         if not user:
   211         if not user:
   209             raise error.RevlogError(_("username %s contains a newline")
   214             raise error.RevlogError(_("username %s contains a newline")
   210                                     % repr(user))
   215                                     % repr(user))
   211 
   216 
   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 
       
   215         user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
       
   216 
   219 
   217         if date:
   220         if date:
   218             parseddate = "%d %d" % util.parsedate(date)
   221             parseddate = "%d %d" % util.parsedate(date)
   219         else:
   222         else:
   220             parseddate = "%d %d" % util.makedate()
   223             parseddate = "%d %d" % util.makedate()