Mercurial > public > mercurial-scm > python-hglib
comparison hglib/client.py @ 50:bd7dfd94b0d9
client: use util.reterrorhandler
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Thu, 18 Aug 2011 16:20:23 +0300 |
parents | 82d927ac1329 |
children | c52383a550fb |
comparison
equal
deleted
inserted
replaced
49:3d7e0325ba1c | 50:bd7dfd94b0d9 |
---|---|
153 if not isinstance(files, list): | 153 if not isinstance(files, list): |
154 files = [files] | 154 files = [files] |
155 | 155 |
156 args = cmdbuilder('add', *files, n=dryrun, S=subrepos, I=include, X=exclude) | 156 args = cmdbuilder('add', *files, n=dryrun, S=subrepos, I=include, X=exclude) |
157 | 157 |
158 # we could use Python 3 nonlocal here... | 158 eh = util.reterrorhandler(args) |
159 warnings = [False] | 159 self.rawcommand(args, eh=eh) |
160 | 160 |
161 def eh(ret, out, err): | 161 return bool(eh) |
162 if ret == 1: | |
163 warnings[0] = True | |
164 else: | |
165 raise error.CommandError(args, ret, out, err) | |
166 | |
167 self.rawcommand(args, eh=eh) | |
168 return not warnings[0] | |
169 | 162 |
170 def addremove(self, files=[], similarity=None, dryrun=False, include=None, | 163 def addremove(self, files=[], similarity=None, dryrun=False, include=None, |
171 exclude=None): | 164 exclude=None): |
172 if not isinstance(files, list): | 165 if not isinstance(files, list): |
173 files = [files] | 166 files = [files] |
174 | 167 |
175 args = cmdbuilder('addremove', *files, s=similarity, n=dryrun, I=include, | 168 args = cmdbuilder('addremove', *files, s=similarity, n=dryrun, I=include, |
176 X=exclude) | 169 X=exclude) |
177 | 170 |
178 # we could use Python 3 nonlocal here... | 171 eh = util.reterrorhandler(args) |
179 warnings = [False] | 172 self.rawcommand(args, eh=eh) |
180 | 173 |
181 def eh(ret, out, err): | 174 return bool(eh) |
182 if ret == 1: | |
183 warnings[0] = True | |
184 else: | |
185 raise error.CommandError(args, ret, out, err) | |
186 | |
187 self.rawcommand(args, eh=eh) | |
188 return not warnings[0] | |
189 | 175 |
190 def backout(self, rev, merge=False, parent=None, tool=None, message=None, | 176 def backout(self, rev, merge=False, parent=None, tool=None, message=None, |
191 logfile=None, date=None, user=None): | 177 logfile=None, date=None, user=None): |
192 if message and logfile: | 178 if message and logfile: |
193 raise ValueError("cannot specify both a message and a logfile") | 179 raise ValueError("cannot specify both a message and a logfile") |
330 | 316 |
331 source.append(dest) | 317 source.append(dest) |
332 args = cmdbuilder('copy', *source, A=after, f=force, n=dryrun, | 318 args = cmdbuilder('copy', *source, A=after, f=force, n=dryrun, |
333 I=include, X=exclude) | 319 I=include, X=exclude) |
334 | 320 |
335 # we could use Python 3 nonlocal here... | 321 eh = util.reterrorhandler(args) |
336 warnings = [False] | 322 self.rawcommand(args, eh=eh) |
337 | 323 |
338 def eh(ret, out, err): | 324 return bool(eh) |
339 if ret == 1: | |
340 warnings[0] = True | |
341 else: | |
342 raise error.CommandError(args, ret, out, err) | |
343 | |
344 self.rawcommand(args, eh=eh) | |
345 return not warnings[0] | |
346 | 325 |
347 def forget(self, files, include=None, exclude=None): | 326 def forget(self, files, include=None, exclude=None): |
348 if not isinstance(files, list): | 327 if not isinstance(files, list): |
349 files = [files] | 328 files = [files] |
350 | 329 |
351 args = cmdbuilder('forget', *files, I=include, X=exclude) | 330 args = cmdbuilder('forget', *files, I=include, X=exclude) |
352 | 331 |
353 # we could use Python 3 nonlocal here... | 332 eh = util.reterrorhandler(args) |
354 warnings = [False] | 333 self.rawcommand(args, eh=eh) |
355 | 334 |
356 def eh(ret, out, err): | 335 return bool(eh) |
357 if ret == 1: | |
358 warnings[0] = True | |
359 else: | |
360 raise error.CommandError(args, ret, out, err) | |
361 | |
362 out = self.rawcommand(args, eh=eh) | |
363 return not warnings[0] | |
364 | 336 |
365 def diff(self, files=[], revs=[], change=None, text=False, | 337 def diff(self, files=[], revs=[], change=None, text=False, |
366 git=False, nodates=False, showfunction=False, reverse=False, | 338 git=False, nodates=False, showfunction=False, reverse=False, |
367 ignoreallspace=False, ignorespacechange=False, ignoreblanklines=False, | 339 ignoreallspace=False, ignorespacechange=False, ignoreblanklines=False, |
368 unified=None, stat=False, subrepos=False, include=None, exclude=None): | 340 unified=None, stat=False, subrepos=False, include=None, exclude=None): |
490 | 462 |
491 source.append(dest) | 463 source.append(dest) |
492 args = cmdbuilder('move', *source, A=after, f=force, n=dryrun, | 464 args = cmdbuilder('move', *source, A=after, f=force, n=dryrun, |
493 I=include, X=exclude) | 465 I=include, X=exclude) |
494 | 466 |
495 # we could use Python 3 nonlocal here... | 467 eh = util.reterrorhandler(args) |
496 warnings = [False] | 468 self.rawcommand(args, eh=eh) |
497 | 469 |
498 def eh(ret, out, err): | 470 return bool(eh) |
499 if ret == 1: | |
500 warnings[0] = True | |
501 else: | |
502 raise error.CommandError(args, ret, out, err) | |
503 | |
504 self.rawcommand(args, eh=eh) | |
505 return not warnings[0] | |
506 | 471 |
507 def outgoing(self, revrange=None, path=None, force=False, newest=False, | 472 def outgoing(self, revrange=None, path=None, force=False, newest=False, |
508 bookmarks=False, branch=None, limit=None, nomerges=False, | 473 bookmarks=False, branch=None, limit=None, nomerges=False, |
509 subrepos=False): | 474 subrepos=False): |
510 """ | 475 """ |
565 branch=None, ssh=None, remotecmd=None, insecure=False, tool=None): | 530 branch=None, ssh=None, remotecmd=None, insecure=False, tool=None): |
566 args = cmdbuilder('pull', source, r=rev, u=update, f=force, B=bookmark, | 531 args = cmdbuilder('pull', source, r=rev, u=update, f=force, B=bookmark, |
567 b=branch, e=ssh, remotecmd=remotecmd, insecure=insecure, | 532 b=branch, e=ssh, remotecmd=remotecmd, insecure=insecure, |
568 t=tool) | 533 t=tool) |
569 | 534 |
570 # we could use Python 3 nonlocal here... | 535 eh = util.reterrorhandler(args) |
571 success = [True] | 536 self.rawcommand(args, eh=eh) |
572 | 537 |
573 def eh(ret, out, err): | 538 return bool(eh) |
574 if ret == 1: | |
575 success[0] = False | |
576 else: | |
577 raise error.CommandError(args, ret, out, err) | |
578 | |
579 self.rawcommand(args, eh=eh) | |
580 return success[0] | |
581 | 539 |
582 def push(self, dest=None, rev=None, force=False, bookmark=None, branch=None, | 540 def push(self, dest=None, rev=None, force=False, bookmark=None, branch=None, |
583 newbranch=False, ssh=None, remotecmd=None, insecure=False): | 541 newbranch=False, ssh=None, remotecmd=None, insecure=False): |
584 args = cmdbuilder('push', dest, r=rev, f=force, B=bookmark, b=branch, | 542 args = cmdbuilder('push', dest, r=rev, f=force, B=bookmark, b=branch, |
585 new_branch=newbranch, e=ssh, remotecmd=remotecmd, | 543 new_branch=newbranch, e=ssh, remotecmd=remotecmd, |
586 insecure=insecure) | 544 insecure=insecure) |
587 | 545 |
588 # we could use Python 3 nonlocal here... | 546 eh = util.reterrorhandler(args) |
589 pushed = [True] | 547 self.rawcommand(args, eh=eh) |
590 | 548 |
591 def eh(ret, out, err): | 549 return bool(eh) |
592 if ret == 1: | |
593 pushed[0] = False | |
594 else: | |
595 raise error.CommandError(args, ret, out, err) | |
596 | |
597 self.rawcommand(args, eh=eh) | |
598 return pushed[0] | |
599 | 550 |
600 def remove(self, files, after=False, force=False, include=None, exclude=None): | 551 def remove(self, files, after=False, force=False, include=None, exclude=None): |
601 if not isinstance(files, list): | 552 if not isinstance(files, list): |
602 files = [files] | 553 files = [files] |
603 | 554 |
604 args = cmdbuilder('remove', *files, A=after, f=force, I=include, X=exclude) | 555 args = cmdbuilder('remove', *files, A=after, f=force, I=include, X=exclude) |
605 | 556 |
606 # we could use Python 3 nonlocal here... | 557 eh = util.reterrorhandler(args) |
607 warnings = [False] | 558 self.rawcommand(args, eh=eh) |
608 | 559 |
609 def eh(ret, out, err): | 560 return bool(eh) |
610 if ret == 1: | |
611 warnings[0] = True | |
612 else: | |
613 raise error.CommandError(args, ret, out, err) | |
614 | |
615 out = self.rawcommand(args, eh=eh) | |
616 return not warnings[0] | |
617 | 561 |
618 def revert(self, files, rev=None, all=False, date=None, nobackup=False, | 562 def revert(self, files, rev=None, all=False, date=None, nobackup=False, |
619 dryrun=False, include=None, exclude=None): | 563 dryrun=False, include=None, exclude=None): |
620 if not isinstance(files, list): | 564 if not isinstance(files, list): |
621 files = [files] | 565 files = [files] |
622 | 566 |
623 args = cmdbuilder('revert', *files, r=rev, a=all, d=date, | 567 args = cmdbuilder('revert', *files, r=rev, a=all, d=date, |
624 no_backup=nobackup, n=dryrun, I=include, X=exclude) | 568 no_backup=nobackup, n=dryrun, I=include, X=exclude) |
625 | 569 |
626 # we could use Python 3 nonlocal here... | 570 eh = util.reterrorhandler(args) |
627 warnings = [False] | 571 self.rawcommand(args, eh=eh) |
628 | 572 |
629 def eh(ret, out, err): | 573 return bool(eh) |
630 if ret == 1: | |
631 warnings[0] = True | |
632 else: | |
633 raise error.CommandError(args, ret, out, err) | |
634 | |
635 out = self.rawcommand(args, eh=eh) | |
636 return not warnings[0] | |
637 | 574 |
638 def root(self): | 575 def root(self): |
639 return self.rawcommand(['root']).rstrip() | 576 return self.rawcommand(['root']).rstrip() |
640 | 577 |
641 def status(self, rev=None, change=None, all=False, modified=False, added=False, | 578 def status(self, rev=None, change=None, all=False, modified=False, added=False, |