Show More
@@ -106,7 +106,9 b' def push(repo, remote, force=False, revs' | |||||
106 | pushop.repo.prepushoutgoinghooks(pushop.repo, |
|
106 | pushop.repo.prepushoutgoinghooks(pushop.repo, | |
107 | pushop.remote, |
|
107 | pushop.remote, | |
108 | pushop.outgoing) |
|
108 | pushop.outgoing) | |
109 | _pushchangeset(pushop) |
|
109 | if pushop.remote.capable('bundle2'): | |
|
110 | _pushbundle2(pushop) | |||
|
111 | else: | |||
110 | _pushcomputecommonheads(pushop) |
|
112 | _pushcomputecommonheads(pushop) | |
111 | _pushsyncphase(pushop) |
|
113 | _pushsyncphase(pushop) | |
112 | _pushobsolete(pushop) |
|
114 | _pushobsolete(pushop) | |
@@ -172,6 +174,35 b' def _pushcheckoutgoing(pushop):' | |||||
172 | newbm) |
|
174 | newbm) | |
173 | return True |
|
175 | return True | |
174 |
|
176 | |||
|
177 | def _pushbundle2(pushop): | |||
|
178 | """push data to the remote using bundle2 | |||
|
179 | ||||
|
180 | The only currently supported type of data is changegroup but this will | |||
|
181 | evolve in the future.""" | |||
|
182 | # Send known head to the server for race detection. | |||
|
183 | bundler = bundle2.bundle20(pushop.ui) | |||
|
184 | if not pushop.force: | |||
|
185 | part = bundle2.bundlepart('CHECK:HEADS', data=iter(pushop.remoteheads)) | |||
|
186 | bundler.addpart(part) | |||
|
187 | # add the changegroup bundle | |||
|
188 | cg = changegroup.getlocalbundle(pushop.repo, 'push', pushop.outgoing) | |||
|
189 | def cgchunks(cg=cg): | |||
|
190 | yield 'HG10UN' | |||
|
191 | for c in cg.getchunks(): | |||
|
192 | yield c | |||
|
193 | cgpart = bundle2.bundlepart('CHANGEGROUP', data=cgchunks()) | |||
|
194 | bundler.addpart(cgpart) | |||
|
195 | stream = util.chunkbuffer(bundler.getchunks()) | |||
|
196 | sent = bundle2.unbundle20(pushop.repo.ui, stream) | |||
|
197 | reply = pushop.remote.unbundle(sent, ['force'], 'push') | |||
|
198 | try: | |||
|
199 | op = bundle2.processbundle(pushop.repo, reply) | |||
|
200 | except KeyError, exc: | |||
|
201 | raise util.Abort('missing support for %s' % exc) | |||
|
202 | cgreplies = op.records.getreplies(cgpart.id) | |||
|
203 | assert len(cgreplies['changegroup']) == 1 | |||
|
204 | pushop.ret = cgreplies['changegroup'][0]['return'] | |||
|
205 | ||||
175 | def _pushchangeset(pushop): |
|
206 | def _pushchangeset(pushop): | |
176 | """Make the actual push of changeset bundle to remote repo""" |
|
207 | """Make the actual push of changeset bundle to remote repo""" | |
177 | outgoing = pushop.outgoing |
|
208 | outgoing = pushop.outgoing | |
@@ -637,11 +668,22 b' def unbundle(repo, cg, heads, source, ur' | |||||
637 |
|
668 | |||
638 | If the push was raced as PushRaced exception is raised.""" |
|
669 | If the push was raced as PushRaced exception is raised.""" | |
639 | r = 0 |
|
670 | r = 0 | |
|
671 | # need a transaction when processing a bundle2 stream | |||
|
672 | tr = None | |||
640 | lock = repo.lock() |
|
673 | lock = repo.lock() | |
641 | try: |
|
674 | try: | |
642 | check_heads(repo, heads, 'uploading changes') |
|
675 | check_heads(repo, heads, 'uploading changes') | |
643 | # push can proceed |
|
676 | # push can proceed | |
644 | r = changegroup.addchangegroup(repo, cg, source, url) |
|
677 | if util.safehasattr(cg, 'params'): | |
|
678 | tr = repo.transaction('unbundle') | |||
|
679 | ret = bundle2.processbundle(repo, cg, lambda: tr) | |||
|
680 | tr.close() | |||
|
681 | stream = util.chunkbuffer(ret.reply.getchunks()) | |||
|
682 | r = bundle2.unbundle20(repo.ui, stream) | |||
|
683 | else: | |||
|
684 | r = changegroup.addchangegroup(repo, cg, source, url) | |||
645 | finally: |
|
685 | finally: | |
|
686 | if tr is not None: | |||
|
687 | tr.release() | |||
646 | lock.release() |
|
688 | lock.release() | |
647 | return r |
|
689 | return r |
@@ -668,11 +668,21 b' clone --pull' | |||||
668 |
|
668 | |||
669 | pull |
|
669 | pull | |
670 |
|
670 | |||
671 | $ hg -R other pull |
|
671 | $ hg -R other pull -r 24b6387c8c8c | |
672 | pulling from $TESTTMP/main (glob) |
|
672 | pulling from $TESTTMP/main (glob) | |
673 | searching for changes |
|
673 | searching for changes | |
674 | adding changesets |
|
674 | adding changesets | |
675 | adding manifests |
|
675 | adding manifests | |
676 | adding file changes |
|
676 | adding file changes | |
677 |
added |
|
677 | added 1 changesets with 1 changes to 1 files (+1 heads) | |
678 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
678 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
|
679 | ||||
|
680 | push | |||
|
681 | ||||
|
682 | $ hg -R main push other --rev eea13746799a | |||
|
683 | pushing to other | |||
|
684 | searching for changes | |||
|
685 | adding changesets | |||
|
686 | adding manifests | |||
|
687 | adding file changes | |||
|
688 | added 1 changesets with 0 changes to 0 files (-1 heads) |
General Comments 0
You need to be logged in to leave comments.
Login now