comparison hgext/mq.py @ 2818:05316bb57d01

mq: make guards more strict, add tests
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 09 Aug 2006 09:38:11 -0700
parents 12139eedd6a0
children 49988d9f0758
comparison
equal deleted inserted replaced
2817:12139eedd6a0 2818:05316bb57d01
174 guards = self.active() 174 guards = self.active()
175 exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards] 175 exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards]
176 if exactneg: 176 if exactneg:
177 return False, exactneg[0] 177 return False, exactneg[0]
178 pos = [g for g in patchguards if g[0] == '+'] 178 pos = [g for g in patchguards if g[0] == '+']
179 exactpos = [g for g in pos if g[1:] in guards] 179 nonpos = [g for g in pos if g[1:] not in guards]
180 if pos: 180 if pos:
181 if exactpos: 181 if not nonpos:
182 return True, exactpos[0] 182 return True, ''
183 return False, '' 183 return False, nonpos
184 return True, '' 184 return True, ''
185 185
186 def explain_pushable(self, idx, all_patches=False): 186 def explain_pushable(self, idx, all_patches=False):
187 write = all_patches and self.ui.write or self.ui.warn 187 write = all_patches and self.ui.write or self.ui.warn
188 if all_patches or self.ui.verbose: 188 if all_patches or self.ui.verbose:
199 self.series[idx]) 199 self.series[idx])
200 else: 200 else:
201 write(_('allowing %s - guarded by %r\n') % 201 write(_('allowing %s - guarded by %r\n') %
202 (self.series[idx], why)) 202 (self.series[idx], why))
203 if not pushable: 203 if not pushable:
204 if why and why[0] in '-+': 204 if why:
205 write(_('skipping %s - guarded by %r\n') % 205 write(_('skipping %s - guarded by %r\n') %
206 (self.series[idx], why)) 206 (self.series[idx], ' '.join(why)))
207 else: 207 else:
208 write(_('skipping %s - no matching guards\n') % 208 write(_('skipping %s - no matching guards\n') %
209 self.series[idx]) 209 self.series[idx])
210 210
211 def save_dirty(self): 211 def save_dirty(self):
1738 qguard bar.patch +stable (posative guard) 1738 qguard bar.patch +stable (posative guard)
1739 qselect stable 1739 qselect stable
1740 1740
1741 this sets "stable" guard. mq will skip foo.patch (because it has 1741 this sets "stable" guard. mq will skip foo.patch (because it has
1742 nagative match) but push bar.patch (because it has posative 1742 nagative match) but push bar.patch (because it has posative
1743 match). 1743 match). patch is pushed only if all posative guards match and no
1744 nagative guards match.
1744 1745
1745 with no arguments, default is to print current active guards. 1746 with no arguments, default is to print current active guards.
1746 with arguments, set active guards as given. 1747 with arguments, set active guards as given.
1747 1748
1748 use -n/--none to deactivate guards (no other arguments needed). 1749 use -n/--none to deactivate guards (no other arguments needed).
1758 q.set_active(args) 1759 q.set_active(args)
1759 q.save_dirty() 1760 q.save_dirty()
1760 if not args: 1761 if not args:
1761 ui.status(_('guards deactivated\n')) 1762 ui.status(_('guards deactivated\n'))
1762 if q.series: 1763 if q.series:
1763 pushable = [p for p in q.unapplied(repo) if q.pushable(p[0])[0]]
1764 ui.status(_('%d of %d unapplied patches active\n') % 1764 ui.status(_('%d of %d unapplied patches active\n') %
1765 (len(pushable), len(q.series))) 1765 (len(q.unapplied(repo)), len(q.series)))
1766 elif opts['series']: 1766 elif opts['series']:
1767 guards = {} 1767 guards = {}
1768 noguards = 0 1768 noguards = 0
1769 for gs in q.series_guards: 1769 for gs in q.series_guards:
1770 if not gs: 1770 if not gs: