comparison hgext/mq.py @ 14573:d590ff1f22b2

mq: rename series_guards to seriesguards
author Adrian Buehlmann <adrian@cadifra.com>
date Mon, 13 Jun 2011 11:40:27 +0200
parents 8ff2957c1d82
children 12fba7bcb4f1
comparison
equal deleted inserted replaced
14572:8ff2957c1d82 14573:d590ff1f22b2
311 def series(self): 311 def series(self):
312 self.parse_series() 312 self.parse_series()
313 return self.series 313 return self.series
314 314
315 @util.propertycache 315 @util.propertycache
316 def series_guards(self): 316 def seriesguards(self):
317 self.parse_series() 317 self.parse_series()
318 return self.series_guards 318 return self.seriesguards
319 319
320 def invalidate(self): 320 def invalidate(self):
321 for a in 'applied fullseries series series_guards'.split(): 321 for a in 'applied fullseries series seriesguards'.split():
322 if a in self.__dict__: 322 if a in self.__dict__:
323 delattr(self, a) 323 delattr(self, a)
324 self.applied_dirty = 0 324 self.applied_dirty = 0
325 self.series_dirty = 0 325 self.series_dirty = 0
326 self.guards_dirty = False 326 self.guards_dirty = False
371 371
372 guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)') 372 guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
373 373
374 def parse_series(self): 374 def parse_series(self):
375 self.series = [] 375 self.series = []
376 self.series_guards = [] 376 self.seriesguards = []
377 for l in self.fullseries: 377 for l in self.fullseries:
378 h = l.find('#') 378 h = l.find('#')
379 if h == -1: 379 if h == -1:
380 patch = l 380 patch = l
381 comment = '' 381 comment = ''
388 if patch: 388 if patch:
389 if patch in self.series: 389 if patch in self.series:
390 raise util.Abort(_('%s appears more than once in %s') % 390 raise util.Abort(_('%s appears more than once in %s') %
391 (patch, self.join(self.series_path))) 391 (patch, self.join(self.series_path)))
392 self.series.append(patch) 392 self.series.append(patch)
393 self.series_guards.append(self.guard_re.findall(comment)) 393 self.seriesguards.append(self.guard_re.findall(comment))
394 394
395 def check_guard(self, guard): 395 def check_guard(self, guard):
396 if not guard: 396 if not guard:
397 return _('guard cannot be an empty string') 397 return _('guard cannot be an empty string')
398 bad_chars = '# \t\r\n\f' 398 bad_chars = '# \t\r\n\f'
447 self.series_dirty = True 447 self.series_dirty = True
448 448
449 def pushable(self, idx): 449 def pushable(self, idx):
450 if isinstance(idx, str): 450 if isinstance(idx, str):
451 idx = self.series.index(idx) 451 idx = self.series.index(idx)
452 patchguards = self.series_guards[idx] 452 patchguards = self.seriesguards[idx]
453 if not patchguards: 453 if not patchguards:
454 return True, None 454 return True, None
455 guards = self.active() 455 guards = self.active()
456 exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards] 456 exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards]
457 if exactneg: 457 if exactneg:
2410 hg qguard other.patch -- +2.6.17 -stable 2410 hg qguard other.patch -- +2.6.17 -stable
2411 2411
2412 Returns 0 on success. 2412 Returns 0 on success.
2413 ''' 2413 '''
2414 def status(idx): 2414 def status(idx):
2415 guards = q.series_guards[idx] or ['unguarded'] 2415 guards = q.seriesguards[idx] or ['unguarded']
2416 if q.series[idx] in applied: 2416 if q.series[idx] in applied:
2417 state = 'applied' 2417 state = 'applied'
2418 elif q.pushable(idx)[0]: 2418 elif q.pushable(idx)[0]:
2419 state = 'unapplied' 2419 state = 'unapplied'
2420 else: 2420 else:
2836 'from %d to %d\n') % 2836 'from %d to %d\n') %
2837 (len(old_guarded), len(guarded))) 2837 (len(old_guarded), len(guarded)))
2838 elif opts.get('series'): 2838 elif opts.get('series'):
2839 guards = {} 2839 guards = {}
2840 noguards = 0 2840 noguards = 0
2841 for gs in q.series_guards: 2841 for gs in q.seriesguards:
2842 if not gs: 2842 if not gs:
2843 noguards += 1 2843 noguards += 1
2844 for g in gs: 2844 for g in gs:
2845 guards.setdefault(g, 0) 2845 guards.setdefault(g, 0)
2846 guards[g] += 1 2846 guards[g] += 1