hgext/mq.py
changeset 12281 d9cf0d1d0d0f
parent 12266 00658492e2aa
child 12282 9e457c3f47d9
equal deleted inserted replaced
12280:6ee719f56f01 12281:d9cf0d1d0d0f
   769 
   769 
   770         numrevs = 0
   770         numrevs = 0
   771         if opts.get('rev'):
   771         if opts.get('rev'):
   772             if not self.applied:
   772             if not self.applied:
   773                 raise util.Abort(_('no patches applied'))
   773                 raise util.Abort(_('no patches applied'))
   774             revs = cmdutil.revrange(repo, opts['rev'])
   774             revs = cmdutil.revrange(repo, opts.get('rev'))
   775             if len(revs) > 1 and revs[0] > revs[1]:
   775             if len(revs) > 1 and revs[0] > revs[1]:
   776                 revs.reverse()
   776                 revs.reverse()
   777             revpatches = self._revpatches(repo, revs)
   777             revpatches = self._revpatches(repo, revs)
   778             realpatches += revpatches
   778             realpatches += revpatches
   779             numrevs = len(revpatches)
   779             numrevs = len(revpatches)
  1829 
  1829 
  1830       hg qimport -e existing-patch -n new-name
  1830       hg qimport -e existing-patch -n new-name
  1831     """
  1831     """
  1832     q = repo.mq
  1832     q = repo.mq
  1833     try:
  1833     try:
  1834         q.qimport(repo, filename, patchname=opts['name'],
  1834         q.qimport(repo, filename, patchname=opts.get('name'),
  1835               existing=opts['existing'], force=opts['force'], rev=opts['rev'],
  1835               existing=opts.get('existing'), force=opts.get('force'),
  1836               git=opts['git'])
  1836               rev=opts.get('rev'), git=opts.get('git'))
  1837     finally:
  1837     finally:
  1838         q.save_dirty()
  1838         q.save_dirty()
  1839 
  1839 
  1840     if opts.get('push') and not opts.get('rev'):
  1840     if opts.get('push') and not opts.get('rev'):
  1841         return q.push(repo, None)
  1841         return q.push(repo, None)
  1874     an unversioned patch repository into a versioned one). You can use
  1874     an unversioned patch repository into a versioned one). You can use
  1875     qcommit to commit changes to this queue repository.
  1875     qcommit to commit changes to this queue repository.
  1876 
  1876 
  1877     This command is deprecated. Without -c, it's implied by other relevant
  1877     This command is deprecated. Without -c, it's implied by other relevant
  1878     commands. With -c, use :hg:`init --mq` instead."""
  1878     commands. With -c, use :hg:`init --mq` instead."""
  1879     return qinit(ui, repo, create=opts['create_repo'])
  1879     return qinit(ui, repo, create=opts.get('create_repo'))
  1880 
  1880 
  1881 def clone(ui, source, dest=None, **opts):
  1881 def clone(ui, source, dest=None, **opts):
  1882     '''clone main and patch repository at same time
  1882     '''clone main and patch repository at same time
  1883 
  1883 
  1884     If source is local, destination will have no patches applied. If
  1884     If source is local, destination will have no patches applied. If
  1899             url = url[:-1]
  1899             url = url[:-1]
  1900         return url + '/.hg/patches'
  1900         return url + '/.hg/patches'
  1901     if dest is None:
  1901     if dest is None:
  1902         dest = hg.defaultdest(source)
  1902         dest = hg.defaultdest(source)
  1903     sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source))
  1903     sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source))
  1904     if opts['patches']:
  1904     if opts.get('patches'):
  1905         patchespath = ui.expandpath(opts['patches'])
  1905         patchespath = ui.expandpath(opts.get('patches'))
  1906     else:
  1906     else:
  1907         patchespath = patchdir(sr)
  1907         patchespath = patchdir(sr)
  1908     try:
  1908     try:
  1909         hg.repository(ui, patchespath)
  1909         hg.repository(ui, patchespath)
  1910     except error.RepoError:
  1910     except error.RepoError:
  1923             qbase = sr.lookup('qbase')
  1923             qbase = sr.lookup('qbase')
  1924         except error.RepoError:
  1924         except error.RepoError:
  1925             pass
  1925             pass
  1926     ui.note(_('cloning main repository\n'))
  1926     ui.note(_('cloning main repository\n'))
  1927     sr, dr = hg.clone(ui, sr.url(), dest,
  1927     sr, dr = hg.clone(ui, sr.url(), dest,
  1928                       pull=opts['pull'],
  1928                       pull=opts.get('pull'),
  1929                       rev=destrev,
  1929                       rev=destrev,
  1930                       update=False,
  1930                       update=False,
  1931                       stream=opts['uncompressed'])
  1931                       stream=opts.get('uncompressed'))
  1932     ui.note(_('cloning patch repository\n'))
  1932     ui.note(_('cloning patch repository\n'))
  1933     hg.clone(ui, opts['patches'] or patchdir(sr), patchdir(dr),
  1933     hg.clone(ui, opts.get('patches') or patchdir(sr), patchdir(dr),
  1934              pull=opts['pull'], update=not opts['noupdate'],
  1934              pull=opts.get('pull'), update=not opts.get('noupdate'),
  1935              stream=opts['uncompressed'])
  1935              stream=opts.get('uncompressed'))
  1936     if dr.local():
  1936     if dr.local():
  1937         if qbase:
  1937         if qbase:
  1938             ui.note(_('stripping applied patches from destination '
  1938             ui.note(_('stripping applied patches from destination '
  1939                       'repository\n'))
  1939                       'repository\n'))
  1940             dr.mq.strip(dr, [qbase], update=False, backup=None)
  1940             dr.mq.strip(dr, [qbase], update=False, backup=None)
  1941         if not opts['noupdate']:
  1941         if not opts.get('noupdate'):
  1942             ui.note(_('updating destination repository\n'))
  1942             ui.note(_('updating destination repository\n'))
  1943             hg.update(dr, dr.changelog.tip())
  1943             hg.update(dr, dr.changelog.tip())
  1944 
  1944 
  1945 def commit(ui, repo, *pats, **opts):
  1945 def commit(ui, repo, *pats, **opts):
  1946     """commit changes in the queue repository (DEPRECATED)
  1946     """commit changes in the queue repository (DEPRECATED)
  1952         raise util.Abort('no queue repository')
  1952         raise util.Abort('no queue repository')
  1953     commands.commit(r.ui, r, *pats, **opts)
  1953     commands.commit(r.ui, r, *pats, **opts)
  1954 
  1954 
  1955 def series(ui, repo, **opts):
  1955 def series(ui, repo, **opts):
  1956     """print the entire series file"""
  1956     """print the entire series file"""
  1957     repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary'])
  1957     repo.mq.qseries(repo, missing=opts.get('missing'), summary=opts.get('summary'))
  1958     return 0
  1958     return 0
  1959 
  1959 
  1960 def top(ui, repo, **opts):
  1960 def top(ui, repo, **opts):
  1961     """print the name of the current patch"""
  1961     """print the name of the current patch"""
  1962     q = repo.mq
  1962     q = repo.mq
  2019     is important for preserving permission changes and copy/rename
  2019     is important for preserving permission changes and copy/rename
  2020     information.
  2020     information.
  2021     """
  2021     """
  2022     msg = cmdutil.logmessage(opts)
  2022     msg = cmdutil.logmessage(opts)
  2023     def getmsg():
  2023     def getmsg():
  2024         return ui.edit(msg, opts['user'] or ui.username())
  2024         return ui.edit(msg, opts.get('user') or ui.username())
  2025     q = repo.mq
  2025     q = repo.mq
  2026     opts['msg'] = msg
  2026     opts['msg'] = msg
  2027     if opts.get('edit'):
  2027     if opts.get('edit'):
  2028         opts['msg'] = getmsg
  2028         opts['msg'] = getmsg
  2029     else:
  2029     else:
  2052     and renames. See the diffs help topic for more information on the
  2052     and renames. See the diffs help topic for more information on the
  2053     git diff format.
  2053     git diff format.
  2054     """
  2054     """
  2055     q = repo.mq
  2055     q = repo.mq
  2056     message = cmdutil.logmessage(opts)
  2056     message = cmdutil.logmessage(opts)
  2057     if opts['edit']:
  2057     if opts.get('edit'):
  2058         if not q.applied:
  2058         if not q.applied:
  2059             ui.write(_("no patches applied\n"))
  2059             ui.write(_("no patches applied\n"))
  2060             return 1
  2060             return 1
  2061         if message:
  2061         if message:
  2062             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
  2062             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
  2108     if not q.check_toppatch(repo)[0]:
  2108     if not q.check_toppatch(repo)[0]:
  2109         raise util.Abort(_('no patches applied'))
  2109         raise util.Abort(_('no patches applied'))
  2110     q.check_localchanges(repo)
  2110     q.check_localchanges(repo)
  2111 
  2111 
  2112     message = cmdutil.logmessage(opts)
  2112     message = cmdutil.logmessage(opts)
  2113     if opts['edit']:
  2113     if opts.get('edit'):
  2114         if message:
  2114         if message:
  2115             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
  2115             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
  2116 
  2116 
  2117     parent = q.lookup('qtip')
  2117     parent = q.lookup('qtip')
  2118     patches = []
  2118     patches = []
  2142         for msg in messages:
  2142         for msg in messages:
  2143             message.append('* * *')
  2143             message.append('* * *')
  2144             message.extend(msg)
  2144             message.extend(msg)
  2145         message = '\n'.join(message)
  2145         message = '\n'.join(message)
  2146 
  2146 
  2147     if opts['edit']:
  2147     if opts.get('edit'):
  2148         message = ui.edit(message, user or ui.username())
  2148         message = ui.edit(message, user or ui.username())
  2149 
  2149 
  2150     diffopts = q.patchopts(q.diffopts(), *patches)
  2150     diffopts = q.patchopts(q.diffopts(), *patches)
  2151     q.refresh(repo, msg=message, git=diffopts.git)
  2151     q.refresh(repo, msg=message, git=diffopts.git)
  2152     q.delete(repo, patches, opts)
  2152     q.delete(repo, patches, opts)
  2155 def goto(ui, repo, patch, **opts):
  2155 def goto(ui, repo, patch, **opts):
  2156     '''push or pop patches until named patch is at top of stack'''
  2156     '''push or pop patches until named patch is at top of stack'''
  2157     q = repo.mq
  2157     q = repo.mq
  2158     patch = q.lookup(patch)
  2158     patch = q.lookup(patch)
  2159     if q.isapplied(patch):
  2159     if q.isapplied(patch):
  2160         ret = q.pop(repo, patch, force=opts['force'])
  2160         ret = q.pop(repo, patch, force=opts.get('force'))
  2161     else:
  2161     else:
  2162         ret = q.push(repo, patch, force=opts['force'])
  2162         ret = q.push(repo, patch, force=opts.get('force'))
  2163     q.save_dirty()
  2163     q.save_dirty()
  2164     return ret
  2164     return ret
  2165 
  2165 
  2166 def guard(ui, repo, *args, **opts):
  2166 def guard(ui, repo, *args, **opts):
  2167     '''set or print guards for a patch
  2167     '''set or print guards for a patch
  2203         ui.write('\n')
  2203         ui.write('\n')
  2204     q = repo.mq
  2204     q = repo.mq
  2205     applied = set(p.name for p in q.applied)
  2205     applied = set(p.name for p in q.applied)
  2206     patch = None
  2206     patch = None
  2207     args = list(args)
  2207     args = list(args)
  2208     if opts['list']:
  2208     if opts.get('list'):
  2209         if args or opts['none']:
  2209         if args or opts.get('none'):
  2210             raise util.Abort(_('cannot mix -l/--list with options or arguments'))
  2210             raise util.Abort(_('cannot mix -l/--list with options or arguments'))
  2211         for i in xrange(len(q.series)):
  2211         for i in xrange(len(q.series)):
  2212             status(i)
  2212             status(i)
  2213         return
  2213         return
  2214     if not args or args[0][0:1] in '-+':
  2214     if not args or args[0][0:1] in '-+':
  2217         patch = q.applied[-1].name
  2217         patch = q.applied[-1].name
  2218     if patch is None and args[0][0:1] not in '-+':
  2218     if patch is None and args[0][0:1] not in '-+':
  2219         patch = args.pop(0)
  2219         patch = args.pop(0)
  2220     if patch is None:
  2220     if patch is None:
  2221         raise util.Abort(_('no patch to work with'))
  2221         raise util.Abort(_('no patch to work with'))
  2222     if args or opts['none']:
  2222     if args or opts.get('none'):
  2223         idx = q.find_series(patch)
  2223         idx = q.find_series(patch)
  2224         if idx is None:
  2224         if idx is None:
  2225             raise util.Abort(_('no patch named %s') % patch)
  2225             raise util.Abort(_('no patch named %s') % patch)
  2226         q.set_guards(idx, args)
  2226         q.set_guards(idx, args)
  2227         q.save_dirty()
  2227         q.save_dirty()
  2274     will be lost.
  2274     will be lost.
  2275     """
  2275     """
  2276     q = repo.mq
  2276     q = repo.mq
  2277     mergeq = None
  2277     mergeq = None
  2278 
  2278 
  2279     if opts['merge']:
  2279     if opts.get('merge'):
  2280         if opts['name']:
  2280         if opts.get('name'):
  2281             newpath = repo.join(opts['name'])
  2281             newpath = repo.join(opts.get('name'))
  2282         else:
  2282         else:
  2283             newpath, i = lastsavename(q.path)
  2283             newpath, i = lastsavename(q.path)
  2284         if not newpath:
  2284         if not newpath:
  2285             ui.warn(_("no saved queues found, please use -n\n"))
  2285             ui.warn(_("no saved queues found, please use -n\n"))
  2286             return 1
  2286             return 1
  2287         mergeq = queue(ui, repo.join(""), newpath)
  2287         mergeq = queue(ui, repo.join(""), newpath)
  2288         ui.warn(_("merging with queue at: %s\n") % mergeq.path)
  2288         ui.warn(_("merging with queue at: %s\n") % mergeq.path)
  2289     ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
  2289     ret = q.push(repo, patch, force=opts.get('force'), list=opts.get('list'),
  2290                  mergeq=mergeq, all=opts.get('all'), move=opts.get('move'))
  2290                  mergeq=mergeq, all=opts.get('all'), move=opts.get('move'))
  2291     return ret
  2291     return ret
  2292 
  2292 
  2293 def pop(ui, repo, patch=None, **opts):
  2293 def pop(ui, repo, patch=None, **opts):
  2294     """pop the current patch off the stack
  2294     """pop the current patch off the stack
  2296     By default, pops off the top of the patch stack. If given a patch
  2296     By default, pops off the top of the patch stack. If given a patch
  2297     name, keeps popping off patches until the named patch is at the
  2297     name, keeps popping off patches until the named patch is at the
  2298     top of the stack.
  2298     top of the stack.
  2299     """
  2299     """
  2300     localupdate = True
  2300     localupdate = True
  2301     if opts['name']:
  2301     if opts.get('name'):
  2302         q = queue(ui, repo.join(""), repo.join(opts['name']))
  2302         q = queue(ui, repo.join(""), repo.join(opts.get('name')))
  2303         ui.warn(_('using patch queue: %s\n') % q.path)
  2303         ui.warn(_('using patch queue: %s\n') % q.path)
  2304         localupdate = False
  2304         localupdate = False
  2305     else:
  2305     else:
  2306         q = repo.mq
  2306         q = repo.mq
  2307     ret = q.pop(repo, patch, force=opts['force'], update=localupdate,
  2307     ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate,
  2308                 all=opts['all'])
  2308                 all=opts.get('all'))
  2309     q.save_dirty()
  2309     q.save_dirty()
  2310     return ret
  2310     return ret
  2311 
  2311 
  2312 def rename(ui, repo, patch, name=None, **opts):
  2312 def rename(ui, repo, patch, name=None, **opts):
  2313     """rename a patch
  2313     """rename a patch
  2377     """restore the queue state saved by a revision (DEPRECATED)
  2377     """restore the queue state saved by a revision (DEPRECATED)
  2378 
  2378 
  2379     This command is deprecated, use rebase --mq instead."""
  2379     This command is deprecated, use rebase --mq instead."""
  2380     rev = repo.lookup(rev)
  2380     rev = repo.lookup(rev)
  2381     q = repo.mq
  2381     q = repo.mq
  2382     q.restore(repo, rev, delete=opts['delete'],
  2382     q.restore(repo, rev, delete=opts.get('delete'),
  2383               qupdate=opts['update'])
  2383               qupdate=opts.get('update'))
  2384     q.save_dirty()
  2384     q.save_dirty()
  2385     return 0
  2385     return 0
  2386 
  2386 
  2387 def save(ui, repo, **opts):
  2387 def save(ui, repo, **opts):
  2388     """save current queue state (DEPRECATED)
  2388     """save current queue state (DEPRECATED)
  2392     message = cmdutil.logmessage(opts)
  2392     message = cmdutil.logmessage(opts)
  2393     ret = q.save(repo, msg=message)
  2393     ret = q.save(repo, msg=message)
  2394     if ret:
  2394     if ret:
  2395         return ret
  2395         return ret
  2396     q.save_dirty()
  2396     q.save_dirty()
  2397     if opts['copy']:
  2397     if opts.get('copy'):
  2398         path = q.path
  2398         path = q.path
  2399         if opts['name']:
  2399         if opts.get('name'):
  2400             newpath = os.path.join(q.basepath, opts['name'])
  2400             newpath = os.path.join(q.basepath, opts.get('name'))
  2401             if os.path.exists(newpath):
  2401             if os.path.exists(newpath):
  2402                 if not os.path.isdir(newpath):
  2402                 if not os.path.isdir(newpath):
  2403                     raise util.Abort(_('destination %s exists and is not '
  2403                     raise util.Abort(_('destination %s exists and is not '
  2404                                        'a directory') % newpath)
  2404                                        'a directory') % newpath)
  2405                 if not opts['force']:
  2405                 if not opts.get('force'):
  2406                     raise util.Abort(_('destination %s exists, '
  2406                     raise util.Abort(_('destination %s exists, '
  2407                                        'use -f to force') % newpath)
  2407                                        'use -f to force') % newpath)
  2408         else:
  2408         else:
  2409             newpath = savename(path)
  2409             newpath = savename(path)
  2410         ui.warn(_("copy %s to %s\n") % (path, newpath))
  2410         ui.warn(_("copy %s to %s\n") % (path, newpath))
  2411         util.copyfiles(path, newpath)
  2411         util.copyfiles(path, newpath)
  2412     if opts['empty']:
  2412     if opts.get('empty'):
  2413         try:
  2413         try:
  2414             os.unlink(q.join(q.status_path))
  2414             os.unlink(q.join(q.status_path))
  2415         except:
  2415         except:
  2416             pass
  2416             pass
  2417     return 0
  2417     return 0
  2437 
  2437 
  2438     Use the --nobackup option to discard the backup bundle once the
  2438     Use the --nobackup option to discard the backup bundle once the
  2439     operation completes.
  2439     operation completes.
  2440     """
  2440     """
  2441     backup = 'all'
  2441     backup = 'all'
  2442     if opts['backup']:
  2442     if opts.get('backup'):
  2443         backup = 'strip'
  2443         backup = 'strip'
  2444     elif opts['nobackup']:
  2444     elif opts.get('nobackup'):
  2445         backup = 'none'
  2445         backup = 'none'
  2446 
  2446 
  2447     cl = repo.changelog
  2447     cl = repo.changelog
  2448     revs = set(cl.rev(repo.lookup(r)) for r in revs)
  2448     revs = set(cl.rev(repo.lookup(r)) for r in revs)
  2449 
  2449 
  2477                     break
  2477                     break
  2478             del q.applied[start:end]
  2478             del q.applied[start:end]
  2479             q.save_dirty()
  2479             q.save_dirty()
  2480 
  2480 
  2481     repo.mq.strip(repo, list(rootnodes), backup=backup, update=update,
  2481     repo.mq.strip(repo, list(rootnodes), backup=backup, update=update,
  2482                   force=opts['force'])
  2482                   force=opts.get('force'))
  2483     return 0
  2483     return 0
  2484 
  2484 
  2485 def select(ui, repo, *args, **opts):
  2485 def select(ui, repo, *args, **opts):
  2486     '''set or print guarded patches to push
  2486     '''set or print guarded patches to push
  2487 
  2487 
  2515     Use -s/--series to print a list of all guards in the series file
  2515     Use -s/--series to print a list of all guards in the series file
  2516     (no other arguments needed). Use -v for more information.'''
  2516     (no other arguments needed). Use -v for more information.'''
  2517 
  2517 
  2518     q = repo.mq
  2518     q = repo.mq
  2519     guards = q.active()
  2519     guards = q.active()
  2520     if args or opts['none']:
  2520     if args or opts.get('none'):
  2521         old_unapplied = q.unapplied(repo)
  2521         old_unapplied = q.unapplied(repo)
  2522         old_guarded = [i for i in xrange(len(q.applied)) if
  2522         old_guarded = [i for i in xrange(len(q.applied)) if
  2523                        not q.pushable(i)[0]]
  2523                        not q.pushable(i)[0]]
  2524         q.set_active(args)
  2524         q.set_active(args)
  2525         q.save_dirty()
  2525         q.save_dirty()
  2526         if not args:
  2526         if not args:
  2527             ui.status(_('guards deactivated\n'))
  2527             ui.status(_('guards deactivated\n'))
  2528         if not opts['pop'] and not opts['reapply']:
  2528         if not opts.get('pop') and not opts.get('reapply'):
  2529             unapplied = q.unapplied(repo)
  2529             unapplied = q.unapplied(repo)
  2530             guarded = [i for i in xrange(len(q.applied))
  2530             guarded = [i for i in xrange(len(q.applied))
  2531                        if not q.pushable(i)[0]]
  2531                        if not q.pushable(i)[0]]
  2532             if len(unapplied) != len(old_unapplied):
  2532             if len(unapplied) != len(old_unapplied):
  2533                 ui.status(_('number of unguarded, unapplied patches has '
  2533                 ui.status(_('number of unguarded, unapplied patches has '
  2535                           (len(old_unapplied), len(unapplied)))
  2535                           (len(old_unapplied), len(unapplied)))
  2536             if len(guarded) != len(old_guarded):
  2536             if len(guarded) != len(old_guarded):
  2537                 ui.status(_('number of guarded, applied patches has changed '
  2537                 ui.status(_('number of guarded, applied patches has changed '
  2538                             'from %d to %d\n') %
  2538                             'from %d to %d\n') %
  2539                           (len(old_guarded), len(guarded)))
  2539                           (len(old_guarded), len(guarded)))
  2540     elif opts['series']:
  2540     elif opts.get('series'):
  2541         guards = {}
  2541         guards = {}
  2542         noguards = 0
  2542         noguards = 0
  2543         for gs in q.series_guards:
  2543         for gs in q.series_guards:
  2544             if not gs:
  2544             if not gs:
  2545                 noguards += 1
  2545                 noguards += 1
  2562             ui.note(_('active guards:\n'))
  2562             ui.note(_('active guards:\n'))
  2563             for g in guards:
  2563             for g in guards:
  2564                 ui.write(g, '\n')
  2564                 ui.write(g, '\n')
  2565         else:
  2565         else:
  2566             ui.write(_('no active guards\n'))
  2566             ui.write(_('no active guards\n'))
  2567     reapply = opts['reapply'] and q.applied and q.appliedname(-1)
  2567     reapply = opts.get('reapply') and q.applied and q.appliedname(-1)
  2568     popped = False
  2568     popped = False
  2569     if opts['pop'] or opts['reapply']:
  2569     if opts.get('pop') or opts.get('reapply'):
  2570         for i in xrange(len(q.applied)):
  2570         for i in xrange(len(q.applied)):
  2571             pushable, reason = q.pushable(i)
  2571             pushable, reason = q.pushable(i)
  2572             if not pushable:
  2572             if not pushable:
  2573                 ui.status(_('popping guarded patches\n'))
  2573                 ui.status(_('popping guarded patches\n'))
  2574                 popped = True
  2574                 popped = True
  2599 
  2599 
  2600     This can be especially useful if your changes have been applied to
  2600     This can be especially useful if your changes have been applied to
  2601     an upstream repository, or if you are about to push your changes
  2601     an upstream repository, or if you are about to push your changes
  2602     to upstream.
  2602     to upstream.
  2603     """
  2603     """
  2604     if not opts['applied'] and not revrange:
  2604     if not opts.get('applied') and not revrange:
  2605         raise util.Abort(_('no revisions specified'))
  2605         raise util.Abort(_('no revisions specified'))
  2606     elif opts['applied']:
  2606     elif opts.get('applied'):
  2607         revrange = ('qbase::qtip',) + revrange
  2607         revrange = ('qbase::qtip',) + revrange
  2608 
  2608 
  2609     q = repo.mq
  2609     q = repo.mq
  2610     if not q.applied:
  2610     if not q.applied:
  2611         ui.status(_('no patches applied\n'))
  2611         ui.status(_('no patches applied\n'))