hgext/mq.py
changeset 2832 582cbc4392cb
parent 2830 49988d9f0758
child 2833 addd03c7fbfa
equal deleted inserted replaced
2831:0b9ac7dfcf56 2832:582cbc4392cb
   723     #
   723     #
   724     # 1) a number to indicate an offset in the series file
   724     # 1) a number to indicate an offset in the series file
   725     # 2) a unique substring of the patch name was given
   725     # 2) a unique substring of the patch name was given
   726     # 3) patchname[-+]num to indicate an offset in the series file
   726     # 3) patchname[-+]num to indicate an offset in the series file
   727     def lookup(self, patch, strict=False):
   727     def lookup(self, patch, strict=False):
       
   728         patch = patch and str(patch)
       
   729 
   728         def partial_name(s):
   730         def partial_name(s):
   729             if s in self.series:
   731             if s in self.series:
   730                 return s
   732                 return s
   731             matches = [x for x in self.series if s in x]
   733             matches = [x for x in self.series if s in x]
   732             if len(matches) > 1:
   734             if len(matches) > 1:
  1748     
  1750     
  1749     use -n/--none to deactivate guards (no other arguments needed).
  1751     use -n/--none to deactivate guards (no other arguments needed).
  1750     when no guards active, patches with posative guards are skipped,
  1752     when no guards active, patches with posative guards are skipped,
  1751     patches with nagative guards are pushed.
  1753     patches with nagative guards are pushed.
  1752 
  1754 
       
  1755     qselect can change guards of applied patches. it does not pop
       
  1756     guarded patches by default.  use --pop to pop back to last applied
       
  1757     patch that is not guarded.  use --reapply (implies --pop) to push
       
  1758     back to current patch afterwards, but skip guarded patches.
       
  1759 
  1753     use -s/--series to print list of all guards in series file (no
  1760     use -s/--series to print list of all guards in series file (no
  1754     other arguments needed).  use -v for more information.'''
  1761     other arguments needed).  use -v for more information.'''
  1755 
  1762 
  1756     q = repo.mq
  1763     q = repo.mq
  1757     guards = q.active()
  1764     guards = q.active()
  1758     if args or opts['none']:
  1765     if args or opts['none']:
       
  1766         old_unapplied = q.unapplied(repo)
       
  1767         old_guarded = [i for i in xrange(len(q.applied)) if
       
  1768                        not q.pushable(i)[0]]
  1759         q.set_active(args)
  1769         q.set_active(args)
  1760         q.save_dirty()
  1770         q.save_dirty()
  1761         if not args:
  1771         if not args:
  1762             ui.status(_('guards deactivated\n'))
  1772             ui.status(_('guards deactivated\n'))
  1763         if q.series:
  1773         if not opts['pop'] and not opts['reapply']:
  1764             ui.status(_('%d of %d unapplied patches active\n') %
  1774             unapplied = q.unapplied(repo)
  1765                       (len(q.unapplied(repo)), len(q.series)))
  1775             guarded = [i for i in xrange(len(q.applied))
       
  1776                        if not q.pushable(i)[0]]
       
  1777             if len(unapplied) != len(old_unapplied):
       
  1778                 ui.status(_('number of unguarded, unapplied patches has '
       
  1779                             'changed from %d to %d\n') %
       
  1780                           (len(old_unapplied), len(unapplied)))
       
  1781             if len(guarded) != len(old_guarded):
       
  1782                 ui.status(_('number of guarded, applied patches has changed '
       
  1783                             'from %d to %d\n') %
       
  1784                           (len(old_guarded), len(guarded)))
  1766     elif opts['series']:
  1785     elif opts['series']:
  1767         guards = {}
  1786         guards = {}
  1768         noguards = 0
  1787         noguards = 0
  1769         for gs in q.series_guards:
  1788         for gs in q.series_guards:
  1770             if not gs:
  1789             if not gs:
  1788             ui.note(_('active guards:\n'))
  1807             ui.note(_('active guards:\n'))
  1789             for g in guards:
  1808             for g in guards:
  1790                 ui.write(g, '\n')
  1809                 ui.write(g, '\n')
  1791         else:
  1810         else:
  1792             ui.write(_('no active guards\n'))
  1811             ui.write(_('no active guards\n'))
       
  1812     reapply = opts['reapply'] and q.applied and q.appliedname(-1)
       
  1813     popped = False
       
  1814     if opts['pop'] or opts['reapply']:
       
  1815         for i in xrange(len(q.applied)):
       
  1816             pushable, reason = q.pushable(i)
       
  1817             if not pushable:
       
  1818                 ui.status(_('popping guarded patches\n'))
       
  1819                 popped = True
       
  1820                 if i == 0:
       
  1821                     q.pop(repo, all=True)
       
  1822                 else:
       
  1823                     q.pop(repo, i-1)
       
  1824                 break
       
  1825     if popped:
       
  1826         try:
       
  1827             if reapply:
       
  1828                 ui.status(_('reapplying unguarded patches\n'))
       
  1829                 q.push(repo, reapply)
       
  1830         finally:
       
  1831             q.save_dirty()
  1793 
  1832 
  1794 def reposetup(ui, repo):
  1833 def reposetup(ui, repo):
  1795     class mqrepo(repo.__class__):
  1834     class mqrepo(repo.__class__):
  1796         def tags(self):
  1835         def tags(self):
  1797             if self.tagscache:
  1836             if self.tagscache:
  1905           ('e', 'empty', None, 'clear queue status file'),
  1944           ('e', 'empty', None, 'clear queue status file'),
  1906           ('f', 'force', None, 'force copy')],
  1945           ('f', 'force', None, 'force copy')],
  1907          'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'),
  1946          'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'),
  1908     "qselect": (select,
  1947     "qselect": (select,
  1909                 [('n', 'none', None, _('disable all guards')),
  1948                 [('n', 'none', None, _('disable all guards')),
  1910                  ('s', 'series', None, _('list all guards in series file'))],
  1949                  ('s', 'series', None, _('list all guards in series file')),
  1911                 'hg qselect [GUARDS]'),
  1950                  ('', 'pop', None,
       
  1951                   _('pop to before first guarded applied patch')),
       
  1952                  ('', 'reapply', None, _('pop, then reapply patches'))],
       
  1953                 'hg qselect [OPTION...] [GUARD...]'),
  1912     "qseries":
  1954     "qseries":
  1913         (series,
  1955         (series,
  1914          [('m', 'missing', None, 'print patches not in series'),
  1956          [('m', 'missing', None, 'print patches not in series'),
  1915           ('s', 'summary', None, _('print first line of patch header'))],
  1957           ('s', 'summary', None, _('print first line of patch header'))],
  1916          'hg qseries [-m]'),
  1958          'hg qseries [-m]'),