20 > from mercurial import scmutil |
20 > from mercurial import scmutil |
21 > from mercurial import discovery |
21 > from mercurial import discovery |
22 > from mercurial import changegroup |
22 > from mercurial import changegroup |
23 > from mercurial import error |
23 > from mercurial import error |
24 > from mercurial import obsolete |
24 > from mercurial import obsolete |
25 > from mercurial import pycompat |
|
26 > from mercurial import registrar |
25 > from mercurial import registrar |
|
26 > from mercurial.utils import procutil |
27 > |
27 > |
28 > |
28 > |
29 > try: |
29 > try: |
30 > import msvcrt |
30 > import msvcrt |
31 > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
31 > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
146 > yield b'first line\n' |
146 > yield b'first line\n' |
147 > raise RuntimeError('Someone set up us the bomb!') |
147 > raise RuntimeError('Someone set up us the bomb!') |
148 > bundler.newpart(b'output', data=genraise(), mandatory=False) |
148 > bundler.newpart(b'output', data=genraise(), mandatory=False) |
149 > |
149 > |
150 > if path is None: |
150 > if path is None: |
151 > file = pycompat.stdout |
151 > file = procutil.stdout |
152 > else: |
152 > else: |
153 > file = open(path, 'wb') |
153 > file = open(path, 'wb') |
154 > |
154 > |
155 > if opts['timeout']: |
155 > if opts['timeout']: |
156 > bundler.newpart(b'test:song', data=ELEPHANTSSONG, mandatory=False) |
156 > bundler.newpart(b'test:song', data=ELEPHANTSSONG, mandatory=False) |
179 > try: |
179 > try: |
180 > tr = None |
180 > tr = None |
181 > lock = repo.lock() |
181 > lock = repo.lock() |
182 > tr = repo.transaction(b'processbundle') |
182 > tr = repo.transaction(b'processbundle') |
183 > try: |
183 > try: |
184 > unbundler = bundle2.getunbundler(ui, pycompat.stdin) |
184 > unbundler = bundle2.getunbundler(ui, procutil.stdin) |
185 > op = bundle2.processbundle(repo, unbundler, lambda: tr) |
185 > op = bundle2.processbundle(repo, unbundler, lambda: tr) |
186 > tr.close() |
186 > tr.close() |
187 > except error.BundleValueError as exc: |
187 > except error.BundleValueError as exc: |
188 > raise error.Abort(b'missing support for %s' % exc) |
188 > raise error.Abort(b'missing support for %s' % exc) |
189 > except error.PushRaced as exc: |
189 > except error.PushRaced as exc: |
190 > raise error.Abort(b'push race: %s' % exc) |
190 > raise error.Abort(b'push race: %s' % exc) |
191 > finally: |
191 > finally: |
192 > if tr is not None: |
192 > if tr is not None: |
193 > tr.release() |
193 > tr.release() |
194 > lock.release() |
194 > lock.release() |
195 > remains = pycompat.stdin.read() |
195 > remains = procutil.stdin.read() |
196 > ui.write(b'%i unread bytes\n' % len(remains)) |
196 > ui.write(b'%i unread bytes\n' % len(remains)) |
197 > if op.records[b'song']: |
197 > if op.records[b'song']: |
198 > totalverses = sum(r[b'verses'] for r in op.records[b'song']) |
198 > totalverses = sum(r[b'verses'] for r in op.records[b'song']) |
199 > ui.write(b'%i total verses sung\n' % totalverses) |
199 > ui.write(b'%i total verses sung\n' % totalverses) |
200 > for rec in op.records[b'changegroup']: |
200 > for rec in op.records[b'changegroup']: |
205 > file.write(chunk) |
205 > file.write(chunk) |
206 > |
206 > |
207 > @command(b'statbundle2', [], b'') |
207 > @command(b'statbundle2', [], b'') |
208 > def cmdstatbundle2(ui, repo): |
208 > def cmdstatbundle2(ui, repo): |
209 > """print statistic on the bundle2 container read from stdin""" |
209 > """print statistic on the bundle2 container read from stdin""" |
210 > unbundler = bundle2.getunbundler(ui, pycompat.stdin) |
210 > unbundler = bundle2.getunbundler(ui, procutil.stdin) |
211 > try: |
211 > try: |
212 > params = unbundler.params |
212 > params = unbundler.params |
213 > except error.BundleValueError as exc: |
213 > except error.BundleValueError as exc: |
214 > raise error.Abort(b'unknown parameters: %s' % exc) |
214 > raise error.Abort(b'unknown parameters: %s' % exc) |
215 > ui.write(b'options count: %i\n' % len(params)) |
215 > ui.write(b'options count: %i\n' % len(params)) |