45 > @bundle2.parthandler('test:ping') |
45 > @bundle2.parthandler('test:ping') |
46 > def pinghandler(op, part): |
46 > def pinghandler(op, part): |
47 > op.ui.write('received ping request (id %i)\n' % part.id) |
47 > op.ui.write('received ping request (id %i)\n' % part.id) |
48 > if op.reply is not None and 'ping-pong' in op.reply.capabilities: |
48 > if op.reply is not None and 'ping-pong' in op.reply.capabilities: |
49 > op.ui.write_err('replying to ping request (id %i)\n' % part.id) |
49 > op.ui.write_err('replying to ping request (id %i)\n' % part.id) |
50 > rpart = bundle2.bundlepart('test:pong', |
50 > op.reply.newpart('test:pong', [('in-reply-to', str(part.id))]) |
51 > [('in-reply-to', str(part.id))]) |
|
52 > op.reply.addpart(rpart) |
|
53 > |
51 > |
54 > @bundle2.parthandler('test:debugreply') |
52 > @bundle2.parthandler('test:debugreply') |
55 > def debugreply(op, part): |
53 > def debugreply(op, part): |
56 > """print data about the capacity of the bundle reply""" |
54 > """print data about the capacity of the bundle reply""" |
57 > if op.reply is None: |
55 > if op.reply is None: |
81 > except ValueError, exc: |
79 > except ValueError, exc: |
82 > raise util.Abort('%s' % exc) |
80 > raise util.Abort('%s' % exc) |
83 > |
81 > |
84 > if opts['reply']: |
82 > if opts['reply']: |
85 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville' |
83 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville' |
86 > bundler.addpart(bundle2.bundlepart('b2x:replycaps', data=capsstring)) |
84 > bundler.newpart('b2x:replycaps', data=capsstring) |
87 > |
85 > |
88 > if opts['pushrace']: |
86 > if opts['pushrace']: |
89 > dummynode = '01234567890123456789' |
87 > dummynode = '01234567890123456789' |
90 > bundler.addpart(bundle2.bundlepart('b2x:check:heads', data=dummynode)) |
88 > bundler.newpart('b2x:check:heads', data=dummynode) |
91 > |
89 > |
92 > revs = opts['rev'] |
90 > revs = opts['rev'] |
93 > if 'rev' in opts: |
91 > if 'rev' in opts: |
94 > revs = scmutil.revrange(repo, opts['rev']) |
92 > revs = scmutil.revrange(repo, opts['rev']) |
95 > if revs: |
93 > if revs: |
97 > bundled = repo.revs('%ld::%ld', revs, revs) |
95 > bundled = repo.revs('%ld::%ld', revs, revs) |
98 > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)] |
96 > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)] |
99 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)] |
97 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)] |
100 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing) |
98 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing) |
101 > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None) |
99 > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None) |
102 > part = bundle2.bundlepart('b2x:changegroup', data=cg.getchunks()) |
100 > bundler.newpart('b2x:changegroup', data=cg.getchunks()) |
103 > bundler.addpart(part) |
|
104 > |
101 > |
105 > if opts['parts']: |
102 > if opts['parts']: |
106 > part = bundle2.bundlepart('test:empty') |
103 > bundler.newpart('test:empty') |
107 > bundler.addpart(part) |
|
108 > # add a second one to make sure we handle multiple parts |
104 > # add a second one to make sure we handle multiple parts |
109 > part = bundle2.bundlepart('test:empty') |
105 > bundler.newpart('test:empty') |
110 > bundler.addpart(part) |
106 > bundler.newpart('test:song', data=ELEPHANTSSONG) |
111 > part = bundle2.bundlepart('test:song', data=ELEPHANTSSONG) |
107 > bundler.newpart('test:debugreply') |
112 > bundler.addpart(part) |
108 > bundler.newpart('test:math', |
113 > part = bundle2.bundlepart('test:debugreply') |
|
114 > bundler.addpart(part) |
|
115 > part = bundle2.bundlepart('test:math', |
|
116 > [('pi', '3.14'), ('e', '2.72')], |
109 > [('pi', '3.14'), ('e', '2.72')], |
117 > [('cooking', 'raw')], |
110 > [('cooking', 'raw')], |
118 > '42') |
111 > '42') |
119 > bundler.addpart(part) |
|
120 > if opts['unknown']: |
112 > if opts['unknown']: |
121 > part = bundle2.bundlepart('test:UNKNOWN', |
113 > bundler.newpart('test:UNKNOWN', data='some random content') |
122 > data='some random content') |
|
123 > bundler.addpart(part) |
|
124 > if opts['parts']: |
114 > if opts['parts']: |
125 > part = bundle2.bundlepart('test:ping') |
115 > bundler.newpart('test:ping') |
126 > bundler.addpart(part) |
|
127 > |
116 > |
128 > if path is None: |
117 > if path is None: |
129 > file = sys.stdout |
118 > file = sys.stdout |
130 > else: |
119 > else: |
131 > file = open(path, 'w') |
120 > file = open(path, 'w') |
936 > def _pushbundle2failpart(orig, pushop, bundler): |
925 > def _pushbundle2failpart(orig, pushop, bundler): |
937 > extradata = orig(pushop, bundler) |
926 > extradata = orig(pushop, bundler) |
938 > reason = pushop.ui.config('failpush', 'reason', None) |
927 > reason = pushop.ui.config('failpush', 'reason', None) |
939 > part = None |
928 > part = None |
940 > if reason == 'abort': |
929 > if reason == 'abort': |
941 > part = bundle2.bundlepart('test:abort') |
930 > bundler.newpart('test:abort') |
942 > if reason == 'unknown': |
931 > if reason == 'unknown': |
943 > part = bundle2.bundlepart('TEST:UNKNOWN') |
932 > bundler.newpart('TEST:UNKNOWN') |
944 > if reason == 'race': |
933 > if reason == 'race': |
945 > # 20 Bytes of crap |
934 > # 20 Bytes of crap |
946 > part = bundle2.bundlepart('b2x:check:heads', data='01234567890123456789') |
935 > bundler.newpart('b2x:check:heads', data='01234567890123456789') |
947 > if part is not None: |
|
948 > bundler.addpart(part) |
|
949 > return extradata |
936 > return extradata |
950 > |
937 > |
951 > @bundle2.parthandler("test:abort") |
938 > @bundle2.parthandler("test:abort") |
952 > def handleabort(op, part): |
939 > def handleabort(op, part): |
953 > raise util.Abort('Abandon ship!', hint="don't panic") |
940 > raise util.Abort('Abandon ship!', hint="don't panic") |