##// END OF EJS Templates
incoming: add support for remote repo using bundlerepo
Benoit Boissinot -
r1944:fdf40c9b default
parent child Browse files
Show More
@@ -9,9 +9,9 b' 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."""
@@ -1757,16 +1757,36 b' def incoming(ui, repo, source="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)
@@ -1780,6 +1800,9 b' def incoming(ui, repo, source="default",'
1780 dodiff(ui, ui, other, prev, n)
1800 dodiff(ui, ui, other, prev, n)
1781 ui.write("\n")
1801 ui.write("\n")
1782
1802
1803 if cleanup:
1804 os.unlink(cleanup)
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
@@ -2732,9 +2755,10 b' table = {'
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,
General Comments 0
You need to be logged in to leave comments. Login now