Rename addmessageheader()'s crlf parameter to linebreak

The parameter's value is a string representing the linebreak,
and can sometimes contain just '\n', in which case naming it
crlf is slightly misleading.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:
Adam Spiers 2014-06-24 18:05:21 +01:00 committed by Eygene Ryabinkin
parent e791901b97
commit afead6c48e

View File

@ -420,13 +420,13 @@ next line\n
""" """
def addmessageheader(self, content, crlf, headername, headervalue): def addmessageheader(self, content, linebreak, headername, headervalue):
""" """
Adds new header to the provided message. Adds new header to the provided message.
Arguments: Arguments:
- content: message content, headers and body as a single string - content: message content, headers and body as a single string
- crlf: string that carries line ending - linebreak: string that carries line ending
- headername: name of the header to add - headername: name of the header to add
- headervalue: value of the header to add - headervalue: value of the header to add
@ -434,12 +434,12 @@ next line\n
self.ui.debug('', self.ui.debug('',
'addmessageheader: called to add %s: %s' % (headername, 'addmessageheader: called to add %s: %s' % (headername,
headervalue)) headervalue))
prefix = crlf prefix = linebreak
suffix = '' suffix = ''
insertionpoint = content.find(crlf + crlf) insertionpoint = content.find(linebreak * 2)
if insertionpoint == 0 or insertionpoint == -1: if insertionpoint == 0 or insertionpoint == -1:
prefix = '' prefix = ''
suffix = crlf suffix = linebreak
if insertionpoint == -1: if insertionpoint == -1:
insertionpoint = 0 insertionpoint = 0
# When body starts immediately, without preceding '\n' # When body starts immediately, without preceding '\n'
@ -447,8 +447,8 @@ next line\n
# we seen many broken ones), we should add '\n' to make # we seen many broken ones), we should add '\n' to make
# new (and the only header, in this case) to be properly # new (and the only header, in this case) to be properly
# separated from the message body. # separated from the message body.
if content[0:len(crlf)] != crlf: if content[0:len(linebreak)] != linebreak:
suffix = suffix + crlf suffix = suffix + linebreak
self.ui.debug('', 'addmessageheader: insertionpoint = %d' % insertionpoint) self.ui.debug('', 'addmessageheader: insertionpoint = %d' % insertionpoint)
headers = content[0:insertionpoint] headers = content[0:insertionpoint]