Mercurial > hg
comparison mercurial/localrepo.py @ 19201:309c439cdbaa
bundle-ng: add bundlecaps argument to getbundle() command
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 09 Feb 2013 23:42:03 +0100 |
parents | 4cfdec944edf |
children | 0455fc94ae00 |
comparison
equal
deleted
inserted
replaced
19200:4cfdec944edf | 19201:309c439cdbaa |
---|---|
97 return self._repo.heads() | 97 return self._repo.heads() |
98 | 98 |
99 def known(self, nodes): | 99 def known(self, nodes): |
100 return self._repo.known(nodes) | 100 return self._repo.known(nodes) |
101 | 101 |
102 def getbundle(self, source, heads=None, common=None): | 102 def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
103 return self._repo.getbundle(source, heads=heads, common=common) | 103 return self._repo.getbundle(source, heads=heads, common=common, |
104 bundlecaps=None) | |
104 | 105 |
105 # TODO We might want to move the next two calls into legacypeer and add | 106 # TODO We might want to move the next two calls into legacypeer and add |
106 # unbundle instead. | 107 # unbundle instead. |
107 | 108 |
108 def lock(self): | 109 def lock(self): |
1672 elif heads is None and remote.capable('changegroupsubset'): | 1673 elif heads is None and remote.capable('changegroupsubset'): |
1673 # issue1320, avoid a race if remote changed after discovery | 1674 # issue1320, avoid a race if remote changed after discovery |
1674 heads = rheads | 1675 heads = rheads |
1675 | 1676 |
1676 if remote.capable('getbundle'): | 1677 if remote.capable('getbundle'): |
1678 # TODO: get bundlecaps from remote | |
1677 cg = remote.getbundle('pull', common=common, | 1679 cg = remote.getbundle('pull', common=common, |
1678 heads=heads or rheads) | 1680 heads=heads or rheads) |
1679 elif heads is None: | 1681 elif heads is None: |
1680 cg = remote.changegroup(fetch, 'pull') | 1682 cg = remote.changegroup(fetch, 'pull') |
1681 elif not remote.capable('changegroupsubset'): | 1683 elif not remote.capable('changegroupsubset'): |
1834 ctx)) | 1836 ctx)) |
1835 discovery.checkheads(unfi, remote, outgoing, | 1837 discovery.checkheads(unfi, remote, outgoing, |
1836 remoteheads, newbranch, | 1838 remoteheads, newbranch, |
1837 bool(inc)) | 1839 bool(inc)) |
1838 | 1840 |
1841 # TODO: get bundlecaps from remote | |
1842 bundlecaps = None | |
1839 # create a changegroup from local | 1843 # create a changegroup from local |
1840 if revs is None and not outgoing.excluded: | 1844 if revs is None and not outgoing.excluded: |
1841 # push everything, | 1845 # push everything, |
1842 # use the fast path, no race possible on push | 1846 # use the fast path, no race possible on push |
1843 bundler = changegroup.bundle10() | 1847 bundler = changegroup.bundle10(bundlecaps) |
1844 cg = self._changegroup(outgoing.missing, bundler, | 1848 cg = self._changegroup(outgoing.missing, bundler, |
1845 'push') | 1849 'push') |
1846 else: | 1850 else: |
1847 cg = self.getlocalbundle('push', outgoing) | 1851 cg = self.getlocalbundle('push', outgoing, bundlecaps) |
1848 | 1852 |
1849 # apply changegroup to remote | 1853 # apply changegroup to remote |
1850 if unbundle: | 1854 if unbundle: |
1851 # local repo finds heads on server, finds out what | 1855 # local repo finds heads on server, finds out what |
1852 # revs it must push. once revs transferred, if server | 1856 # revs it must push. once revs transferred, if server |
1989 # We assume that all ancestors of bases are known | 1993 # We assume that all ancestors of bases are known |
1990 common = cl.ancestors([cl.rev(n) for n in bases]) | 1994 common = cl.ancestors([cl.rev(n) for n in bases]) |
1991 bundler = changegroup.bundle10() | 1995 bundler = changegroup.bundle10() |
1992 return self._changegroupsubset(common, csets, heads, bundler, source) | 1996 return self._changegroupsubset(common, csets, heads, bundler, source) |
1993 | 1997 |
1994 def getlocalbundle(self, source, outgoing): | 1998 def getlocalbundle(self, source, outgoing, bundlecaps=None): |
1995 """Like getbundle, but taking a discovery.outgoing as an argument. | 1999 """Like getbundle, but taking a discovery.outgoing as an argument. |
1996 | 2000 |
1997 This is only implemented for local repos and reuses potentially | 2001 This is only implemented for local repos and reuses potentially |
1998 precomputed sets in outgoing.""" | 2002 precomputed sets in outgoing.""" |
1999 if not outgoing.missing: | 2003 if not outgoing.missing: |
2000 return None | 2004 return None |
2001 bundler = changegroup.bundle10() | 2005 bundler = changegroup.bundle10(bundlecaps) |
2002 return self._changegroupsubset(outgoing.common, | 2006 return self._changegroupsubset(outgoing.common, |
2003 outgoing.missing, | 2007 outgoing.missing, |
2004 outgoing.missingheads, | 2008 outgoing.missingheads, |
2005 bundler, | 2009 bundler, |
2006 source) | 2010 source) |
2007 | 2011 |
2008 def getbundle(self, source, heads=None, common=None): | 2012 def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
2009 """Like changegroupsubset, but returns the set difference between the | 2013 """Like changegroupsubset, but returns the set difference between the |
2010 ancestors of heads and the ancestors common. | 2014 ancestors of heads and the ancestors common. |
2011 | 2015 |
2012 If heads is None, use the local heads. If common is None, use [nullid]. | 2016 If heads is None, use the local heads. If common is None, use [nullid]. |
2013 | 2017 |
2021 else: | 2025 else: |
2022 common = [nullid] | 2026 common = [nullid] |
2023 if not heads: | 2027 if not heads: |
2024 heads = cl.heads() | 2028 heads = cl.heads() |
2025 return self.getlocalbundle(source, | 2029 return self.getlocalbundle(source, |
2026 discovery.outgoing(cl, common, heads)) | 2030 discovery.outgoing(cl, common, heads), |
2031 bundlecaps=bundlecaps) | |
2027 | 2032 |
2028 @unfilteredmethod | 2033 @unfilteredmethod |
2029 def _changegroupsubset(self, commonrevs, csets, heads, bundler, source): | 2034 def _changegroupsubset(self, commonrevs, csets, heads, bundler, source): |
2030 | 2035 |
2031 cl = self.changelog | 2036 cl = self.changelog |