##// END OF EJS Templates
mq: make patchheader .plainmode more reliable...
Mads Kiilerich -
r22544:0d75ce89 default
parent child Browse files
Show More
@@ -202,7 +202,11 b' class patchheader(object):'
202 202 self.nodeid = nodeid
203 203 self.branch = branch
204 204 self.haspatch = diffstart > 1
205 self.plainmode = plainmode
205 self.plainmode = (plainmode or
206 '# HG changeset patch' not in self.comments and
207 util.any(c.startswith('Date: ') or
208 c.startswith('From: ')
209 for c in self.comments))
206 210
207 211 def setuser(self, user):
208 212 if not self.updateheader(['From: ', '# User '], user):
@@ -210,7 +214,7 b' class patchheader(object):'
210 214 patchheaderat = self.comments.index('# HG changeset patch')
211 215 self.comments.insert(patchheaderat + 1, '# User ' + user)
212 216 except ValueError:
213 if self.plainmode or self._hasheader(['Date: ']):
217 if self.plainmode:
214 218 self.comments = ['From: ' + user] + self.comments
215 219 else:
216 220 tmp = ['# HG changeset patch', '# User ' + user]
@@ -223,7 +227,7 b' class patchheader(object):'
223 227 patchheaderat = self.comments.index('# HG changeset patch')
224 228 self.comments.insert(patchheaderat + 1, '# Date ' + date)
225 229 except ValueError:
226 if self.plainmode or self._hasheader(['From: ']):
230 if self.plainmode:
227 231 self.comments = ['Date: ' + date] + self.comments
228 232 else:
229 233 tmp = ['# HG changeset patch', '# Date ' + date]
@@ -258,14 +262,6 b' class patchheader(object):'
258 262 break
259 263 return res
260 264
261 def _hasheader(self, prefixes):
262 '''Check if a header starts with any of the given prefixes.'''
263 for prefix in prefixes:
264 for comment in self.comments:
265 if comment.startswith(prefix):
266 return True
267 return False
268
269 265 def __str__(self):
270 266 s = '\n'.join(self.comments).rstrip()
271 267 if not s:
General Comments 0
You need to be logged in to leave comments. Login now