7 |
7 |
8 from demandload import demandload |
8 from demandload import demandload |
9 from node import * |
9 from node import * |
10 from i18n import gettext as _ |
10 from i18n import gettext as _ |
11 demandload(globals(), "os re sys signal shutil imp urllib pdb") |
11 demandload(globals(), "os re sys signal shutil imp urllib pdb") |
12 demandload(globals(), "fancyopts ui hg util lock revlog templater") |
12 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") |
13 demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") |
13 demandload(globals(), "fnmatch hgweb mdiff random signal tempfile time") |
14 demandload(globals(), "errno socket version struct atexit sets bz2") |
14 demandload(globals(), "traceback errno socket version struct atexit sets bz2") |
15 |
15 |
16 class UnknownCommand(Exception): |
16 class UnknownCommand(Exception): |
17 """Exception raised if command is not in the command table.""" |
17 """Exception raised if command is not in the command table.""" |
18 class AmbiguousCommand(Exception): |
18 class AmbiguousCommand(Exception): |
19 """Exception raised if command shortcut matches more than one command.""" |
19 """Exception raised if command shortcut matches more than one command.""" |
1755 |
1755 |
1756 Show new changesets found in the specified repo or the default |
1756 Show new changesets found in the specified repo or the default |
1757 pull repo. These are the changesets that would be pulled if a pull |
1757 pull repo. These are the changesets that would be pulled if a pull |
1758 was requested. |
1758 was requested. |
1759 |
1759 |
1760 Currently only local repositories are supported. |
1760 For remote repository, using --bundle avoids downloading the changesets |
|
1761 twice if the incoming is followed by a pull. |
1761 """ |
1762 """ |
1762 source = ui.expandpath(source) |
1763 source = ui.expandpath(source) |
1763 other = hg.repository(ui, source) |
1764 other = hg.repository(ui, source) |
1764 if not other.local(): |
1765 incoming = repo.findincoming(other) |
1765 raise util.Abort(_("incoming doesn't work for remote repositories yet")) |
1766 if not incoming: |
1766 o = repo.findincoming(other) |
|
1767 if not o: |
|
1768 return |
1767 return |
1769 o = other.changelog.nodesbetween(o)[0] |
1768 |
|
1769 cleanup = None |
|
1770 if not other.local() or opts["bundle"]: |
|
1771 # create an uncompressed bundle |
|
1772 if not opts["bundle"]: |
|
1773 # create a temporary bundle |
|
1774 fd, fname = tempfile.mkstemp(suffix=".hg", |
|
1775 prefix="tmp-hg-incoming") |
|
1776 f = os.fdopen(fd, "wb") |
|
1777 cleanup = fname |
|
1778 else: |
|
1779 fname = opts["bundle"] |
|
1780 f = open(fname, "wb") |
|
1781 |
|
1782 cg = other.changegroup(incoming, "incoming") |
|
1783 write_bundle(cg, fname, compress=other.local(), fh=f) |
|
1784 f.close() |
|
1785 if not other.local(): |
|
1786 # use a bundlerepo |
|
1787 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
|
1788 |
|
1789 o = other.changelog.nodesbetween(incoming)[0] |
1770 if opts['newest_first']: |
1790 if opts['newest_first']: |
1771 o.reverse() |
1791 o.reverse() |
1772 displayer = show_changeset(ui, other, opts) |
1792 displayer = show_changeset(ui, other, opts) |
1773 for n in o: |
1793 for n in o: |
1774 parents = [p for p in other.changelog.parents(n) if p != nullid] |
1794 parents = [p for p in other.changelog.parents(n) if p != nullid] |
1777 displayer.show(changenode=n) |
1797 displayer.show(changenode=n) |
1778 if opts['patch']: |
1798 if opts['patch']: |
1779 prev = (parents and parents[0]) or nullid |
1799 prev = (parents and parents[0]) or nullid |
1780 dodiff(ui, ui, other, prev, n) |
1800 dodiff(ui, ui, other, prev, n) |
1781 ui.write("\n") |
1801 ui.write("\n") |
|
1802 |
|
1803 if cleanup: |
|
1804 os.unlink(cleanup) |
1782 |
1805 |
1783 def init(ui, dest="."): |
1806 def init(ui, dest="."): |
1784 """create a new repository in the given directory |
1807 """create a new repository in the given directory |
1785 |
1808 |
1786 Initialize a new repository in the given directory. If the given |
1809 Initialize a new repository in the given directory. If the given |
2730 _('hg import [-p NUM] [-b BASE] [-f] PATCH...')), |
2753 _('hg import [-p NUM] [-b BASE] [-f] PATCH...')), |
2731 "incoming|in": (incoming, |
2754 "incoming|in": (incoming, |
2732 [('M', 'no-merges', None, _('do not show merges')), |
2755 [('M', 'no-merges', None, _('do not show merges')), |
2733 ('', 'style', '', _('display using template map file')), |
2756 ('', 'style', '', _('display using template map file')), |
2734 ('n', 'newest-first', None, _('show newest record first')), |
2757 ('n', 'newest-first', None, _('show newest record first')), |
|
2758 ('', 'bundle', '', _('file to store the bundles into')), |
2735 ('p', 'patch', None, _('show patch')), |
2759 ('p', 'patch', None, _('show patch')), |
2736 ('', 'template', '', _('display with template'))], |
2760 ('', 'template', '', _('display with template'))], |
2737 _('hg incoming [-p] [-n] [-M] [SOURCE]')), |
2761 _('hg incoming [-p] [-n] [-M] [--bundle FILENAME] [SOURCE]')), |
2738 "^init": (init, [], _('hg init [DEST]')), |
2762 "^init": (init, [], _('hg init [DEST]')), |
2739 "locate": |
2763 "locate": |
2740 (locate, |
2764 (locate, |
2741 [('r', 'rev', '', _('search the repository as it stood at rev')), |
2765 [('r', 'rev', '', _('search the repository as it stood at rev')), |
2742 ('0', 'print0', None, |
2766 ('0', 'print0', None, |