##// END OF EJS Templates
mq: drop updateheader - inserthgheader and insertplainheader is enough
Mads Kiilerich -
r23443:3b653c2f default
parent child Browse files
Show More
@@ -303,38 +303,34 b' class patchheader(object):'
303 303 for c in self.comments))
304 304
305 305 def setuser(self, user):
306 if not self.updateheader(['From: ', '# User '], user):
307 try:
308 inserthgheader(self.comments, '# User ', user)
309 except ValueError:
310 if self.plainmode:
311 insertplainheader(self.comments, 'From', user)
312 else:
313 tmp = ['# HG changeset patch', '# User ' + user]
314 self.comments = tmp + self.comments
306 try:
307 inserthgheader(self.comments, '# User ', user)
308 except ValueError:
309 if self.plainmode:
310 insertplainheader(self.comments, 'From', user)
311 else:
312 tmp = ['# HG changeset patch', '# User ' + user]
313 self.comments = tmp + self.comments
315 314 self.user = user
316 315
317 316 def setdate(self, date):
318 if not self.updateheader(['Date: ', '# Date '], date):
319 try:
320 inserthgheader(self.comments, '# Date ', date)
321 except ValueError:
322 if self.plainmode:
323 insertplainheader(self.comments, 'Date', date)
324 else:
325 tmp = ['# HG changeset patch', '# Date ' + date]
326 self.comments = tmp + self.comments
317 try:
318 inserthgheader(self.comments, '# Date ', date)
319 except ValueError:
320 if self.plainmode:
321 insertplainheader(self.comments, 'Date', date)
322 else:
323 tmp = ['# HG changeset patch', '# Date ' + date]
324 self.comments = tmp + self.comments
327 325 self.date = date
328 326
329 327 def setparent(self, parent):
330 if not (self.updateheader(['# Parent '], parent) or
331 self.updateheader(['# Parent '], parent)):
332 try:
333 inserthgheader(self.comments, '# Parent ', parent)
334 except ValueError:
335 if not self.plainmode:
336 tmp = ['# HG changeset patch', '# Parent ' + parent]
337 self.comments = tmp + self.comments
328 try:
329 inserthgheader(self.comments, '# Parent ', parent)
330 except ValueError:
331 if not self.plainmode:
332 tmp = ['# HG changeset patch', '# Parent ' + parent]
333 self.comments = tmp + self.comments
338 334 self.parent = parent
339 335
340 336 def setmessage(self, message):
@@ -346,18 +342,6 b' class patchheader(object):'
346 342 self.comments.append('')
347 343 self.comments.append(message)
348 344
349 def updateheader(self, prefixes, new):
350 '''Update all references to a field in the patch header.
351 Return whether the field is present.'''
352 res = False
353 for prefix in prefixes:
354 for i in xrange(len(self.comments)):
355 if self.comments[i].startswith(prefix):
356 self.comments[i] = prefix + new
357 res = True
358 break
359 return res
360
361 345 def __str__(self):
362 346 s = '\n'.join(self.comments).rstrip()
363 347 if not s:
General Comments 0
You need to be logged in to leave comments. Login now