comparison hglib/client.py @ 87:5661d5f7e39b

client: make varargs ordering py2.4-compatible
author Matt Mackall <mpm@selenic.com>
date Thu, 17 Nov 2011 12:54:37 -0600
parents ca5f8f43e585
children 351d2799f145
comparison
equal deleted inserted replaced
86:f98d6e234cd9 87:5661d5f7e39b
161 Return whether all given files were added. 161 Return whether all given files were added.
162 """ 162 """
163 if not isinstance(files, list): 163 if not isinstance(files, list):
164 files = [files] 164 files = [files]
165 165
166 args = cmdbuilder('add', *files, n=dryrun, S=subrepos, I=include, X=exclude) 166 args = cmdbuilder('add', n=dryrun, S=subrepos, I=include, X=exclude,
167 *files)
167 168
168 eh = util.reterrorhandler(args) 169 eh = util.reterrorhandler(args)
169 self.rawcommand(args, eh=eh) 170 self.rawcommand(args, eh=eh)
170 171
171 return bool(eh) 172 return bool(eh)
193 Return True if all files are successfully added. 194 Return True if all files are successfully added.
194 """ 195 """
195 if not isinstance(files, list): 196 if not isinstance(files, list):
196 files = [files] 197 files = [files]
197 198
198 args = cmdbuilder('addremove', *files, s=similarity, n=dryrun, I=include, 199 args = cmdbuilder('addremove', s=similarity, n=dryrun, I=include,
199 X=exclude) 200 X=exclude, *files)
200 201
201 eh = util.reterrorhandler(args) 202 eh = util.reterrorhandler(args)
202 self.rawcommand(args, eh=eh) 203 self.rawcommand(args, eh=eh)
203 204
204 return bool(eh) 205 return bool(eh)
225 separated string according to the given options. 226 separated string according to the given options.
226 """ 227 """
227 if not isinstance(files, list): 228 if not isinstance(files, list):
228 files = [files] 229 files = [files]
229 230
230 args = cmdbuilder('annotate', *files, r=rev, no_follow=nofollow, a=text, 231 args = cmdbuilder('annotate', r=rev, no_follow=nofollow, a=text,
231 u=user, f=file, d=date, n=number, c=changeset, l=line, 232 u=user, f=file, d=date, n=number, c=changeset,
232 v=verbose, I=include, X=exclude) 233 l=line, v=verbose, I=include, X=exclude, *files)
233 234
234 out = self.rawcommand(args) 235 out = self.rawcommand(args)
235 236
236 for line in out.splitlines(): 237 for line in out.splitlines():
237 yield tuple(line.split(': ', 1)) 238 yield tuple(line.split(': ', 1))
435 436
436 "%s" basename of file being printed 437 "%s" basename of file being printed
437 "%d" dirname of file being printed, or '.' if in repository root 438 "%d" dirname of file being printed, or '.' if in repository root
438 "%p" root-relative path name of file being printed 439 "%p" root-relative path name of file being printed
439 """ 440 """
440 args = cmdbuilder('cat', *files, r=rev, o=output) 441 args = cmdbuilder('cat', r=rev, o=output, *files)
441 out = self.rawcommand(args) 442 out = self.rawcommand(args)
442 443
443 if not output: 444 if not output:
444 return out 445 return out
445 446
499 return (section, key, value) 500 return (section, key, value)
500 501
501 if not isinstance(names, list): 502 if not isinstance(names, list):
502 names = [names] 503 names = [names]
503 504
504 args = cmdbuilder('showconfig', *names, u=untrusted, debug=showsource) 505 args = cmdbuilder('showconfig', u=untrusted, debug=showsource, *names)
505 out = self.rawcommand(args) 506 out = self.rawcommand(args)
506 507
507 conf = [] 508 conf = []
508 if showsource: 509 if showsource:
509 out = util.skiplines(out, 'read config from: ') 510 out = util.skiplines(out, 'read config from: ')
549 """ 550 """
550 if not isinstance(source, list): 551 if not isinstance(source, list):
551 source = [source] 552 source = [source]
552 553
553 source.append(dest) 554 source.append(dest)
554 args = cmdbuilder('copy', *source, A=after, f=force, n=dryrun, 555 args = cmdbuilder('copy', A=after, f=force, n=dryrun,
555 I=include, X=exclude) 556 I=include, X=exclude, *source)
556 557
557 eh = util.reterrorhandler(args) 558 eh = util.reterrorhandler(args)
558 self.rawcommand(args, eh=eh) 559 self.rawcommand(args, eh=eh)
559 560
560 return bool(eh) 561 return bool(eh)
583 exclude - exclude names matching the given patterns 584 exclude - exclude names matching the given patterns
584 """ 585 """
585 if change and revs: 586 if change and revs:
586 raise ValueError('cannot specify both change and rev') 587 raise ValueError('cannot specify both change and rev')
587 588
588 args = cmdbuilder('diff', *files, r=revs, c=change, 589 args = cmdbuilder('diff', r=revs, c=change,
589 a=text, g=git, nodates=nodates, 590 a=text, g=git, nodates=nodates,
590 p=showfunction, reverse=reverse, 591 p=showfunction, reverse=reverse,
591 w=ignoreallspace, b=ignorespacechange, 592 w=ignoreallspace, b=ignorespacechange,
592 B=ignoreblanklines, U=unified, stat=stat, 593 B=ignoreblanklines, U=unified, stat=stat,
593 S=subrepos, I=include, X=exclude) 594 S=subrepos, I=include, X=exclude, *files)
594 595
595 return self.rawcommand(args) 596 return self.rawcommand(args)
596 597
597 def export(self, revs, output=None, switchparent=False, text=False, git=False, 598 def export(self, revs, output=None, switchparent=False, text=False, git=False,
598 nodates=False): 599 nodates=False):
617 git - use git extended diff format 618 git - use git extended diff format
618 nodates - omit dates from diff headers 619 nodates - omit dates from diff headers
619 """ 620 """
620 if not isinstance(revs, list): 621 if not isinstance(revs, list):
621 revs = [revs] 622 revs = [revs]
622 args = cmdbuilder('export', *revs, o=output, switch_parent=switchparent, 623 args = cmdbuilder('export', o=output, switch_parent=switchparent,
623 a=text, g=git, nodates=nodates) 624 a=text, g=git, nodates=nodates, *revs)
624 625
625 out = self.rawcommand(args) 626 out = self.rawcommand(args)
626 627
627 if output is None: 628 if output is None:
628 return out 629 return out
641 exclude - exclude names matching the given patterns 642 exclude - exclude names matching the given patterns
642 """ 643 """
643 if not isinstance(files, list): 644 if not isinstance(files, list):
644 files = [files] 645 files = [files]
645 646
646 args = cmdbuilder('forget', *files, I=include, X=exclude) 647 args = cmdbuilder('forget', I=include, X=exclude, *files)
647 648
648 eh = util.reterrorhandler(args) 649 eh = util.reterrorhandler(args)
649 self.rawcommand(args, eh=eh) 650 self.rawcommand(args, eh=eh)
650 651
651 return bool(eh) 652 return bool(eh)
675 exclude - exclude names matching the given patterns 676 exclude - exclude names matching the given patterns
676 """ 677 """
677 if not isinstance(files, list): 678 if not isinstance(files, list):
678 files = [files] 679 files = [files]
679 680
680 args = cmdbuilder('grep', *[pattern] + files, all=all, a=text, f=follow, 681 args = cmdbuilder('grep', all=all, a=text, f=follow, i=ignorecase,
681 i=ignorecase, l=fileswithmatches, n=line, u=user, d=date, 682 l=fileswithmatches, n=line, u=user, d=date,
682 I=include, X=exclude) 683 I=include, X=exclude, *[pattern] + files)
683 args.append('-0') 684 args.append('-0')
684 685
685 def eh(ret, out, err): 686 def eh(ret, out, err):
686 if ret != 1: 687 if ret != 1:
687 raise error.CommandError(args, ret, out, err) 688 raise error.CommandError(args, ret, out, err)
717 closed - normal and closed branch heads. 718 closed - normal and closed branch heads.
718 """ 719 """
719 if not isinstance(rev, list): 720 if not isinstance(rev, list):
720 rev = [rev] 721 rev = [rev]
721 722
722 args = cmdbuilder('heads', *rev, r=startrev, t=topological, c=closed, 723 args = cmdbuilder('heads', r=startrev, t=topological, c=closed,
723 template=templates.changeset) 724 template=templates.changeset, *rev)
724 725
725 def eh(ret, out, err): 726 def eh(ret, out, err):
726 if ret != 1: 727 if ret != 1:
727 raise error.CommandError(args, ret, out, err) 728 raise error.CommandError(args, ret, out, err)
728 return '' 729 return ''
789 else: 790 else:
790 stdin = False 791 stdin = False
791 prompt = None 792 prompt = None
792 input = None 793 input = None
793 794
794 args = cmdbuilder('import', *patches, strip=strip, force=force, 795 args = cmdbuilder('import', strip=strip, force=force,
795 nocommit=nocommit, bypass=bypass, exact=exact, 796 nocommit=nocommit, bypass=bypass, exact=exact,
796 importbranch=importbranch, message=message, 797 importbranch=importbranch, message=message,
797 date=date, user=user, similarity=similarity, _=stdin) 798 date=date, user=user, similarity=similarity, _=stdin,
799 *patches)
798 800
799 self.rawcommand(args, prompt=prompt, input=input) 801 self.rawcommand(args, prompt=prompt, input=input)
800 802
801 def incoming(self, revrange=None, path=None, force=False, newest=False, 803 def incoming(self, revrange=None, path=None, force=False, newest=False,
802 bundle=None, bookmarks=False, branch=None, limit=None, 804 bundle=None, bookmarks=False, branch=None, limit=None,
885 limit - limit number of changes displayed 887 limit - limit number of changes displayed
886 nomerges - do not show merges 888 nomerges - do not show merges
887 include - include names matching the given patterns 889 include - include names matching the given patterns
888 exclude - exclude names matching the given patterns 890 exclude - exclude names matching the given patterns
889 """ 891 """
890 args = cmdbuilder('log', *files, template=templates.changeset, 892 args = cmdbuilder('log', template=templates.changeset,
891 r=revrange, f=follow, follow_first=followfirst, 893 r=revrange, f=follow, follow_first=followfirst,
892 d=date, C=copies, k=keyword, removed=removed, 894 d=date, C=copies, k=keyword, removed=removed,
893 m=onlymerges, u=user, b=branch, P=prune, h=hidden, 895 m=onlymerges, u=user, b=branch, P=prune, h=hidden,
894 l=limit, M=nomerges, I=include, X=exclude) 896 l=limit, M=nomerges, I=include, X=exclude, *files)
895 897
896 out = self.rawcommand(args) 898 out = self.rawcommand(args)
897 out = out.split('\0')[:-1] 899 out = out.split('\0')[:-1]
898 900
899 return self._parserevs(out) 901 return self._parserevs(out)
978 """ 980 """
979 if not isinstance(source, list): 981 if not isinstance(source, list):
980 source = [source] 982 source = [source]
981 983
982 source.append(dest) 984 source.append(dest)
983 args = cmdbuilder('move', *source, A=after, f=force, n=dryrun, 985 args = cmdbuilder('move', A=after, f=force, n=dryrun,
984 I=include, X=exclude) 986 I=include, X=exclude, *source)
985 987
986 eh = util.reterrorhandler(args) 988 eh = util.reterrorhandler(args)
987 self.rawcommand(args, eh=eh) 989 self.rawcommand(args, eh=eh)
988 990
989 return bool(eh) 991 return bool(eh)
1150 exclude - exclude names matching the given patterns 1152 exclude - exclude names matching the given patterns
1151 """ 1153 """
1152 if not isinstance(files, list): 1154 if not isinstance(files, list):
1153 files = [files] 1155 files = [files]
1154 1156
1155 args = cmdbuilder('remove', *files, A=after, f=force, I=include, X=exclude) 1157 args = cmdbuilder('remove', A=after, f=force, I=include, X=exclude,
1158 *files)
1156 1159
1157 eh = util.reterrorhandler(args) 1160 eh = util.reterrorhandler(args)
1158 self.rawcommand(args, eh=eh) 1161 self.rawcommand(args, eh=eh)
1159 1162
1160 return bool(eh) 1163 return bool(eh)
1177 exclude - exclude names matching the given patterns 1180 exclude - exclude names matching the given patterns
1178 """ 1181 """
1179 if not isinstance(file, list): 1182 if not isinstance(file, list):
1180 file = [file] 1183 file = [file]
1181 1184
1182 args = cmdbuilder('resolve', *file, a=all, l=listfiles, m=mark, u=unmark, 1185 args = cmdbuilder('resolve', a=all, l=listfiles, m=mark, u=unmark,
1183 t=tool, I=include, X=exclude) 1186 t=tool, I=include, X=exclude, *file)
1184 1187
1185 out = self.rawcommand(args) 1188 out = self.rawcommand(args)
1186 1189
1187 if listfiles: 1190 if listfiles:
1188 l = [] 1191 l = []
1218 dryrun - do not perform actions, just print output 1221 dryrun - do not perform actions, just print output
1219 """ 1222 """
1220 if not isinstance(files, list): 1223 if not isinstance(files, list):
1221 files = [files] 1224 files = [files]
1222 1225
1223 args = cmdbuilder('revert', *files, r=rev, a=all, d=date, 1226 args = cmdbuilder('revert', r=rev, a=all, d=date,
1224 no_backup=nobackup, n=dryrun, I=include, X=exclude) 1227 no_backup=nobackup, n=dryrun, I=include, X=exclude,
1228 *files)
1225 1229
1226 eh = util.reterrorhandler(args) 1230 eh = util.reterrorhandler(args)
1227 self.rawcommand(args, eh=eh) 1231 self.rawcommand(args, eh=eh)
1228 1232
1229 return bool(eh) 1233 return bool(eh)
1307 user - record the specified user as committer 1311 user - record the specified user as committer
1308 """ 1312 """
1309 if not isinstance(names, list): 1313 if not isinstance(names, list):
1310 names = [names] 1314 names = [names]
1311 1315
1312 args = cmdbuilder('tag', *names, r=rev, m=message, f=force, l=local, 1316 args = cmdbuilder('tag', r=rev, m=message, f=force, l=local,
1313 remove=remove, d=date, u=user) 1317 remove=remove, d=date, u=user, *names)
1314 1318
1315 self.rawcommand(args) 1319 self.rawcommand(args)
1316 1320
1317 def tags(self): 1321 def tags(self):
1318 """ 1322 """