##// 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 for c in self.comments))
303 for c in self.comments))
304
304
305 def setuser(self, user):
305 def setuser(self, user):
306 if not self.updateheader(['From: ', '# User '], user):
306 try:
307 try:
307 inserthgheader(self.comments, '# User ', user)
308 inserthgheader(self.comments, '# User ', user)
308 except ValueError:
309 except ValueError:
309 if self.plainmode:
310 if self.plainmode:
310 insertplainheader(self.comments, 'From', user)
311 insertplainheader(self.comments, 'From', user)
311 else:
312 else:
312 tmp = ['# HG changeset patch', '# User ' + user]
313 tmp = ['# HG changeset patch', '# User ' + user]
313 self.comments = tmp + self.comments
314 self.comments = tmp + self.comments
315 self.user = user
314 self.user = user
316
315
317 def setdate(self, date):
316 def setdate(self, date):
318 if not self.updateheader(['Date: ', '# Date '], date):
317 try:
319 try:
318 inserthgheader(self.comments, '# Date ', date)
320 inserthgheader(self.comments, '# Date ', date)
319 except ValueError:
321 except ValueError:
320 if self.plainmode:
322 if self.plainmode:
321 insertplainheader(self.comments, 'Date', date)
323 insertplainheader(self.comments, 'Date', date)
322 else:
324 else:
323 tmp = ['# HG changeset patch', '# Date ' + date]
325 tmp = ['# HG changeset patch', '# Date ' + date]
324 self.comments = tmp + self.comments
326 self.comments = tmp + self.comments
327 self.date = date
325 self.date = date
328
326
329 def setparent(self, parent):
327 def setparent(self, parent):
330 if not (self.updateheader(['# Parent '], parent) or
328 try:
331 self.updateheader(['# Parent '], parent)):
329 inserthgheader(self.comments, '# Parent ', parent)
332 try:
330 except ValueError:
333 inserthgheader(self.comments, '# Parent ', parent)
331 if not self.plainmode:
334 except ValueError:
332 tmp = ['# HG changeset patch', '# Parent ' + parent]
335 if not self.plainmode:
333 self.comments = tmp + self.comments
336 tmp = ['# HG changeset patch', '# Parent ' + parent]
337 self.comments = tmp + self.comments
338 self.parent = parent
334 self.parent = parent
339
335
340 def setmessage(self, message):
336 def setmessage(self, message):
@@ -346,18 +342,6 b' class patchheader(object):'
346 self.comments.append('')
342 self.comments.append('')
347 self.comments.append(message)
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 def __str__(self):
345 def __str__(self):
362 s = '\n'.join(self.comments).rstrip()
346 s = '\n'.join(self.comments).rstrip()
363 if not s:
347 if not s:
General Comments 0
You need to be logged in to leave comments. Login now