1680 q.save_dirty() |
1680 q.save_dirty() |
1681 return 0 |
1681 return 0 |
1682 |
1682 |
1683 def applied(ui, repo, patch=None, **opts): |
1683 def applied(ui, repo, patch=None, **opts): |
1684 """print the patches already applied""" |
1684 """print the patches already applied""" |
|
1685 |
1685 q = repo.mq |
1686 q = repo.mq |
|
1687 l = len(q.applied) |
|
1688 |
1686 if patch: |
1689 if patch: |
1687 if patch not in q.series: |
1690 if patch not in q.series: |
1688 raise util.Abort(_("patch %s is not in series file") % patch) |
1691 raise util.Abort(_("patch %s is not in series file") % patch) |
1689 end = q.series.index(patch) + 1 |
1692 end = q.series.index(patch) + 1 |
1690 else: |
1693 else: |
1691 end = q.series_end(True) |
1694 end = q.series_end(True) |
1692 return q.qseries(repo, length=end, status='A', summary=opts.get('summary')) |
1695 |
|
1696 if opts.get('last') and not end: |
|
1697 ui.write(_("no patches applied\n")) |
|
1698 return 1 |
|
1699 elif opts.get('last') and end == 1: |
|
1700 ui.write(_("only one patch applied\n")) |
|
1701 return 1 |
|
1702 elif opts.get('last'): |
|
1703 start = end - 2 |
|
1704 end = 1 |
|
1705 else: |
|
1706 start = 0 |
|
1707 |
|
1708 return q.qseries(repo, length=end, start=start, status='A', |
|
1709 summary=opts.get('summary')) |
1693 |
1710 |
1694 def unapplied(ui, repo, patch=None, **opts): |
1711 def unapplied(ui, repo, patch=None, **opts): |
1695 """print the patches not yet applied""" |
1712 """print the patches not yet applied""" |
|
1713 |
1696 q = repo.mq |
1714 q = repo.mq |
1697 if patch: |
1715 if patch: |
1698 if patch not in q.series: |
1716 if patch not in q.series: |
1699 raise util.Abort(_("patch %s is not in series file") % patch) |
1717 raise util.Abort(_("patch %s is not in series file") % patch) |
1700 start = q.series.index(patch) + 1 |
1718 start = q.series.index(patch) + 1 |
1701 else: |
1719 else: |
1702 start = q.series_end(True) |
1720 start = q.series_end(True) |
1703 q.qseries(repo, start=start, status='U', summary=opts.get('summary')) |
1721 |
|
1722 if start == len(q.series) and opts.get('first'): |
|
1723 ui.write(_("all patches applied\n")) |
|
1724 return 1 |
|
1725 |
|
1726 length = opts.get('first') and 1 or None |
|
1727 return q.qseries(repo, start=start, length=length, status='U', |
|
1728 summary=opts.get('summary')) |
1704 |
1729 |
1705 def qimport(ui, repo, *filename, **opts): |
1730 def qimport(ui, repo, *filename, **opts): |
1706 """import a patch |
1731 """import a patch |
1707 |
1732 |
1708 The patch is inserted into the series after the last applied |
1733 The patch is inserted into the series after the last applied |
2520 extensions.wrapcommand(commands.table, 'import', mqimport) |
2545 extensions.wrapcommand(commands.table, 'import', mqimport) |
2521 |
2546 |
2522 seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
2547 seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
2523 |
2548 |
2524 cmdtable = { |
2549 cmdtable = { |
2525 "qapplied": (applied, [] + seriesopts, _('hg qapplied [-s] [PATCH]')), |
2550 "qapplied": |
|
2551 (applied, |
|
2552 [('1', 'last', None, _('show only the last patch'))] + seriesopts, |
|
2553 _('hg qapplied [-s] [PATCH]')), |
2526 "qclone": |
2554 "qclone": |
2527 (clone, |
2555 (clone, |
2528 [('', 'pull', None, _('use pull protocol to copy metadata')), |
2556 [('', 'pull', None, _('use pull protocol to copy metadata')), |
2529 ('U', 'noupdate', None, _('do not update the new working directories')), |
2557 ('U', 'noupdate', None, _('do not update the new working directories')), |
2530 ('', 'uncompressed', None, |
2558 ('', 'uncompressed', None, |
2643 [('f', 'force', None, _('force removal with local changes')), |
2671 [('f', 'force', None, _('force removal with local changes')), |
2644 ('b', 'backup', None, _('bundle unrelated changesets')), |
2672 ('b', 'backup', None, _('bundle unrelated changesets')), |
2645 ('n', 'nobackup', None, _('no backups'))], |
2673 ('n', 'nobackup', None, _('no backups'))], |
2646 _('hg strip [-f] [-b] [-n] REV')), |
2674 _('hg strip [-f] [-b] [-n] REV')), |
2647 "qtop": (top, [] + seriesopts, _('hg qtop [-s]')), |
2675 "qtop": (top, [] + seriesopts, _('hg qtop [-s]')), |
2648 "qunapplied": (unapplied, [] + seriesopts, _('hg qunapplied [-s] [PATCH]')), |
2676 "qunapplied": |
|
2677 (unapplied, |
|
2678 [('1', 'first', None, _('show only the first patch'))] + seriesopts, |
|
2679 _('hg qunapplied [-s] [PATCH]')), |
2649 "qfinish": |
2680 "qfinish": |
2650 (finish, |
2681 (finish, |
2651 [('a', 'applied', None, _('finish all applied changesets'))], |
2682 [('a', 'applied', None, _('finish all applied changesets'))], |
2652 _('hg qfinish [-a] [REV]...')), |
2683 _('hg qfinish [-a] [REV]...')), |
2653 } |
2684 } |