##// END OF EJS Templates
Removed tabs and trailing whitespace in python files
Thomas Arendsen Hein -
r5760:0145f9af default
parent child Browse files
Show More
@@ -57,7 +57,7 b' def convert(ui, src, dest=None, revmapfi'
57 57 exclude path/to/file
58 58
59 59 rename from/file to/file
60
60
61 61 The 'include' directive causes a file, or all files under a
62 62 directory, to be included in the destination repository, and the
63 63 exclusion of all other files and dirs not explicitely included.
@@ -104,13 +104,13 b' class converter_source(object):'
104 104
105 105 def getchangedfiles(self, rev, i):
106 106 """Return the files changed by rev compared to parent[i].
107
107
108 108 i is an index selecting one of the parents of rev. The return
109 109 value should be the list of files that are different in rev and
110 110 this parent.
111 111
112 112 If rev has no parents, i is None.
113
113
114 114 This function is only needed to support --filemap
115 115 """
116 116 raise NotImplementedError()
@@ -279,7 +279,7 b' class mapfile(dict):'
279 279 self.order.append(key)
280 280 super(mapfile, self).__setitem__(key, value)
281 281 fp.close()
282
282
283 283 def __setitem__(self, key, value):
284 284 if self.fp is None:
285 285 try:
@@ -208,7 +208,7 b' class svn_source(converter_source):'
208 208 self.heads.append(brev)
209 209
210 210 if oldmodule:
211 self.tags = '%s/%s' % (oldmodule, tags)
211 self.tags = '%s/%s' % (oldmodule, tags)
212 212 else:
213 213 self.tags = '/%s' % tags
214 214
@@ -714,7 +714,7 b' class svn_sink(converter_sink, commandli'
714 714
715 715 def join(self, name):
716 716 return os.path.join(self.wc, '.svn', name)
717
717
718 718 def revmapfile(self):
719 719 return self.join('hg-shamap')
720 720
@@ -750,7 +750,7 b' class svn_sink(converter_sink, commandli'
750 750 if not path.startswith('/'):
751 751 path = '/' + path
752 752 path = 'file://' + path
753
753
754 754 ui.status(_('initializing svn wc %r\n') % os.path.basename(wcpath))
755 755 self.run0('checkout', path, wcpath)
756 756
@@ -849,7 +849,7 b' class svn_sink(converter_sink, commandli'
849 849 if files:
850 850 self.run('add', quiet=True, *files)
851 851 return files
852
852
853 853 def tidy_dirs(self, names):
854 854 dirs = list(self.dirs_of(names))
855 855 dirs.sort(reverse=True)
@@ -13,7 +13,7 b''
13 13 # querying of information, and an extension to mercurial named hgk.py,
14 14 # which provides hooks for hgk to get information. hgk can be found in
15 15 # the contrib directory, and hgk.py can be found in the hgext
16 # directory.
16 # directory.
17 17 #
18 18 # To load the hgext.py extension, add it to your .hgrc file (you have
19 19 # to use your global $HOME/.hgrc file, not one in a repository). You
@@ -309,10 +309,10 b' def revlist(ui, repo, *revs, **opts):'
309 309 def config(ui, repo, **opts):
310 310 """print extension options"""
311 311 def writeopt(name, value):
312 ui.write('k=%s\nv=%s\n' % (name, value))
312 ui.write('k=%s\nv=%s\n' % (name, value))
313 313
314 314 writeopt('vdiff', ui.config('hgk', 'vdiff', ''))
315
315
316 316
317 317 def view(ui, repo, *etc, **opts):
318 318 "start interactive history viewer"
@@ -773,10 +773,10 b' class changeset_templater(changeset_prin'
773 773 def showcopies(**args):
774 774 c = [{'name': x[0], 'source': x[1]} for x in copies]
775 775 return showlist('file_copy', c, plural='file_copies', **args)
776
776
777 777 files = []
778 778 def getfiles():
779 if not files:
779 if not files:
780 780 files[:] = self.repo.status(
781 781 log.parents(changenode)[0], changenode)[:3]
782 782 return files
@@ -717,7 +717,7 b' def debuginstall(ui):'
717 717 ui.write(_(" (Current patch tool may be incompatible with patch,"
718 718 " or misconfigured. Please check your .hgrc file)\n"))
719 719 else:
720 ui.write(_(" Internal patcher failure, please report this error"
720 ui.write(_(" Internal patcher failure, please report this error"
721 721 " to http://www.selenic.com/mercurial/bts\n"))
722 722 problems += patchproblems
723 723
@@ -1702,7 +1702,7 b' def manifest(ui, repo, node=None, rev=No'
1702 1702 The manifest is the list of files being version controlled. If no revision
1703 1703 is given then the first parent of the working directory is used.
1704 1704
1705 With -v flag, print file permissions, symlink and executable bits. With
1705 With -v flag, print file permissions, symlink and executable bits. With
1706 1706 --debug flag, print file revision hashes.
1707 1707 """
1708 1708
@@ -483,7 +483,7 b' class workingctx(changectx):'
483 483 return self._manifest.flags(path)
484 484 except KeyError:
485 485 return ''
486
486
487 487 pnode = self._parents[0].changeset()[0]
488 488 orig = self._repo.dirstate.copies().get(path, path)
489 489 node, flag = self._repo.manifest.find(pnode, orig)
@@ -21,7 +21,7 b' def _statusmessage(code):'
21 21 from BaseHTTPServer import BaseHTTPRequestHandler
22 22 responses = BaseHTTPRequestHandler.responses
23 23 return responses.get(code, ('Error', 'Unknown error'))[0]
24
24
25 25 def statusmessage(code):
26 26 return '%d %s' % (code, _statusmessage(code))
27 27
@@ -75,7 +75,7 b' class hgwebdir(object):'
75 75 try:
76 76
77 77 virtual = req.env.get("PATH_INFO", "").strip('/')
78
78
79 79 # a static file
80 80 if virtual.startswith('static/') or 'static' in req.form:
81 81 static = os.path.join(templater.templatepath(), 'static')
@@ -122,7 +122,7 b' class hgwebdir(object):'
122 122 # prefixes not found
123 123 tmpl = self.templater(req)
124 124 req.respond(404, tmpl("notfound", repo=virtual))
125
125
126 126 except ErrorResponse, err:
127 127 tmpl = self.templater(req)
128 128 req.respond(err.code, tmpl('error', error=err.message or ''))
@@ -173,7 +173,7 b' class hgwebdir(object):'
173 173
174 174 parts = [req.env['PATH_INFO'], name]
175 175 if req.env['SCRIPT_NAME']:
176 parts.insert(0, req.env['SCRIPT_NAME'])
176 parts.insert(0, req.env['SCRIPT_NAME'])
177 177 url = ('/'.join(parts).replace("//", "/")) + '/'
178 178
179 179 # update time with local timezone
@@ -58,7 +58,7 b' class wsgirequest(object):'
58 58 except socket.error, inst:
59 59 if inst[0] != errno.ECONNRESET:
60 60 raise
61
61
62 62 def write(self, *things):
63 63 self.respond('200 Script output follows', *things)
64 64
@@ -86,7 +86,7 b' class wsgirequest(object):'
86 86 self.header(headers)
87 87
88 88 def wsgiapplication(app_maker):
89 application = app_maker()
90 def run_wsgi(env, respond):
91 application(env, respond)
92 return run_wsgi
89 application = app_maker()
90 def run_wsgi(env, respond):
91 application(env, respond)
92 return run_wsgi
@@ -288,7 +288,7 b' class localrepository(repo.repository):'
288 288 '''
289 289
290 290 self.tags()
291
291
292 292 return self._tagstypecache.get(tagname)
293 293
294 294 def _hgtagsnodes(self):
@@ -818,7 +818,7 b' def selectfile(afile_orig, bfile_orig, h'
818 818 fname = (afile in bfile) and afile or bfile
819 819 elif gooda:
820 820 fname = afile
821
821
822 822 if not fname:
823 823 if not nullb:
824 824 fname = (afile in bfile) and afile or bfile
@@ -826,7 +826,7 b' def selectfile(afile_orig, bfile_orig, h'
826 826 fname = afile
827 827 else:
828 828 raise PatchError(_("undefined source and destination files"))
829
829
830 830 return fname, missing
831 831
832 832 class linereader:
@@ -1029,7 +1029,7 b' def applydiff(ui, fp, changed, strip=1, '
1029 1029 for gp in gitpatches:
1030 1030 if gp.op in ('COPY', 'RENAME'):
1031 1031 copyfile(gp.oldpath, gp.path)
1032 changed[gp.path] = (gp.op, gp)
1032 changed[gp.path] = (gp.op, gp)
1033 1033 else:
1034 1034 raise util.Abort(_('unsupported parser state: %s') % state)
1035 1035
@@ -1709,7 +1709,7 b' def uirepr(s):'
1709 1709
1710 1710 def hidepassword(url):
1711 1711 '''replaces the password in the url string by three asterisks (***)
1712
1712
1713 1713 >>> hidepassword('http://www.example.com/some/path#fragment')
1714 1714 'http://www.example.com/some/path#fragment'
1715 1715 >>> hidepassword('http://me@www.example.com/some/path#fragment')
@@ -105,20 +105,20 b' class StatementFindingAstVisitor(compile'
105 105 self.excluded = excluded
106 106 self.suite_spots = suite_spots
107 107 self.excluding_suite = 0
108
108
109 109 def doRecursive(self, node):
110 110 for n in node.getChildNodes():
111 111 self.dispatch(n)
112 112
113 113 visitStmt = visitModule = doRecursive
114
114
115 115 def doCode(self, node):
116 116 if hasattr(node, 'decorators') and node.decorators:
117 117 self.dispatch(node.decorators)
118 118 self.recordAndDispatch(node.code)
119 119 else:
120 120 self.doSuite(node, node.code)
121
121
122 122 visitFunction = visitClass = doCode
123 123
124 124 def getFirstLine(self, node):
@@ -138,14 +138,14 b' class StatementFindingAstVisitor(compile'
138 138 for n in node.getChildNodes():
139 139 lineno = max(lineno, self.getLastLine(n))
140 140 return lineno
141
141
142 142 def doStatement(self, node):
143 143 self.recordLine(self.getFirstLine(node))
144 144
145 145 visitAssert = visitAssign = visitAssTuple = visitPrint = \
146 146 visitPrintnl = visitRaise = visitSubscript = visitDecorators = \
147 147 doStatement
148
148
149 149 def visitPass(self, node):
150 150 # Pass statements have weird interactions with docstrings. If this
151 151 # pass statement is part of one of those pairs, claim that the statement
@@ -154,10 +154,10 b' class StatementFindingAstVisitor(compile'
154 154 if l:
155 155 lines = self.suite_spots.get(l, [l,l])
156 156 self.statements[lines[1]] = 1
157
157
158 158 def visitDiscard(self, node):
159 159 # Discard nodes are statements that execute an expression, but then
160 # discard the results. This includes function calls, so we can't
160 # discard the results. This includes function calls, so we can't
161 161 # ignore them all. But if the expression is a constant, the statement
162 162 # won't be "executed", so don't count it now.
163 163 if node.expr.__class__.__name__ != 'Const':
@@ -171,7 +171,7 b' class StatementFindingAstVisitor(compile'
171 171 return self.recordLine(self.getFirstLine(node))
172 172 else:
173 173 return 0
174
174
175 175 def recordLine(self, lineno):
176 176 # Returns a bool, whether the line is included or excluded.
177 177 if lineno:
@@ -195,9 +195,9 b' class StatementFindingAstVisitor(compile'
195 195 self.statements[lineno] = 1
196 196 return 1
197 197 return 0
198
198
199 199 default = recordNodeLine
200
200
201 201 def recordAndDispatch(self, node):
202 202 self.recordNodeLine(node)
203 203 self.dispatch(node)
@@ -208,7 +208,7 b' class StatementFindingAstVisitor(compile'
208 208 self.excluding_suite = 1
209 209 self.recordAndDispatch(body)
210 210 self.excluding_suite = exsuite
211
211
212 212 def doPlainWordSuite(self, prevsuite, suite):
213 213 # Finding the exclude lines for else's is tricky, because they aren't
214 214 # present in the compiler parse tree. Look at the previous suite,
@@ -222,11 +222,11 b' class StatementFindingAstVisitor(compile'
222 222 break
223 223 else:
224 224 self.doSuite(None, suite)
225
225
226 226 def doElse(self, prevsuite, node):
227 227 if node.else_:
228 228 self.doPlainWordSuite(prevsuite, node.else_)
229
229
230 230 def visitFor(self, node):
231 231 self.doSuite(node, node.body)
232 232 self.doElse(node.body, node)
@@ -256,14 +256,14 b' class StatementFindingAstVisitor(compile'
256 256 else:
257 257 self.doSuite(a, h)
258 258 self.doElse(node.handlers[-1][2], node)
259
259
260 260 def visitTryFinally(self, node):
261 261 self.doSuite(node, node.body)
262 262 self.doPlainWordSuite(node.body, node.final)
263
263
264 264 def visitWith(self, node):
265 265 self.doSuite(node, node.body)
266
266
267 267 def visitGlobal(self, node):
268 268 # "global" statements don't execute like others (they don't call the
269 269 # trace function), so don't record their line numbers.
@@ -283,7 +283,7 b' class coverage:'
283 283 # A dictionary with an entry for (Python source file name, line number
284 284 # in that file) if that line has been executed.
285 285 c = {}
286
286
287 287 # A map from canonical Python source file name to a dictionary in
288 288 # which there's an entry for each line number that has been
289 289 # executed.
@@ -311,12 +311,12 b' class coverage:'
311 311 self.relative_dir = os.path.normcase(os.path.abspath(os.curdir)+os.sep)
312 312 self.exclude('# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]')
313 313
314 # t(f, x, y). This method is passed to sys.settrace as a trace function.
315 # See [van Rossum 2001-07-20b, 9.2] for an explanation of sys.settrace and
314 # t(f, x, y). This method is passed to sys.settrace as a trace function.
315 # See [van Rossum 2001-07-20b, 9.2] for an explanation of sys.settrace and
316 316 # the arguments and return value of the trace function.
317 317 # See [van Rossum 2001-07-20a, 3.2] for a description of frame and code
318 318 # objects.
319
319
320 320 def t(self, f, w, unused): #pragma: no cover
321 321 if w == 'line':
322 322 #print "Executing %s @ %d" % (f.f_code.co_filename, f.f_lineno)
@@ -324,7 +324,7 b' class coverage:'
324 324 for c in self.cstack:
325 325 c[(f.f_code.co_filename, f.f_lineno)] = 1
326 326 return self.t
327
327
328 328 def help(self, error=None): #pragma: no cover
329 329 if error:
330 330 print error
@@ -376,14 +376,14 b' class coverage:'
376 376 args_needed = (settings.get('execute')
377 377 or settings.get('annotate')
378 378 or settings.get('report'))
379 action = (settings.get('erase')
379 action = (settings.get('erase')
380 380 or settings.get('collect')
381 381 or args_needed)
382 382 if not action:
383 383 help_fn("You must specify at least one of -e, -x, -c, -r, or -a.")
384 384 if not args_needed and args:
385 385 help_fn("Unexpected arguments: %s" % " ".join(args))
386
386
387 387 self.parallel_mode = settings.get('parallel-mode')
388 388 self.get_ready()
389 389
@@ -401,7 +401,7 b' class coverage:'
401 401 self.collect()
402 402 if not args:
403 403 args = self.cexecuted.keys()
404
404
405 405 ignore_errors = settings.get('ignore-errors')
406 406 show_missing = settings.get('show-missing')
407 407 directory = settings.get('directory=')
@@ -421,7 +421,7 b' class coverage:'
421 421 self.usecache = usecache
422 422 if cache_file and not self.cache:
423 423 self.cache_default = cache_file
424
424
425 425 def get_ready(self, parallel_mode=False):
426 426 if self.usecache and not self.cache:
427 427 self.cache = os.environ.get(self.cache_env, self.cache_default)
@@ -429,7 +429,7 b' class coverage:'
429 429 self.cache += "." + gethostname() + "." + str(os.getpid())
430 430 self.restore()
431 431 self.analysis_cache = {}
432
432
433 433 def start(self, parallel_mode=False):
434 434 self.get_ready()
435 435 if self.nesting == 0: #pragma: no cover
@@ -437,7 +437,7 b' class coverage:'
437 437 if hasattr(threading, 'settrace'):
438 438 threading.settrace(self.t)
439 439 self.nesting += 1
440
440
441 441 def stop(self):
442 442 self.nesting -= 1
443 443 if self.nesting == 0: #pragma: no cover
@@ -461,7 +461,7 b' class coverage:'
461 461 def begin_recursive(self):
462 462 self.cstack.append(self.c)
463 463 self.xstack.append(self.exclude_re)
464
464
465 465 def end_recursive(self):
466 466 self.c = self.cstack.pop()
467 467 self.exclude_re = self.xstack.pop()
@@ -541,7 +541,7 b' class coverage:'
541 541 self.canonical_filename_cache[filename] = cf
542 542 return self.canonical_filename_cache[filename]
543 543
544 # canonicalize_filenames(). Copy results from "c" to "cexecuted",
544 # canonicalize_filenames(). Copy results from "c" to "cexecuted",
545 545 # canonicalizing filenames on the way. Clear the "c" map.
546 546
547 547 def canonicalize_filenames(self):
@@ -573,7 +573,7 b' class coverage:'
573 573 # in the source code, (3) a list of lines of excluded statements,
574 574 # and (4), a map of line numbers to multi-line line number ranges, for
575 575 # statements that cross lines.
576
576
577 577 def analyze_morf(self, morf):
578 578 if self.analysis_cache.has_key(morf):
579 579 return self.analysis_cache[morf]
@@ -600,26 +600,26 b' class coverage:'
600 600 if len(tree) == 3 and type(tree[2]) == type(1):
601 601 return tree[2]
602 602 tree = tree[1]
603
603
604 604 def last_line_of_tree(self, tree):
605 605 while True:
606 606 if len(tree) == 3 and type(tree[2]) == type(1):
607 607 return tree[2]
608 608 tree = tree[-1]
609
609
610 610 def find_docstring_pass_pair(self, tree, spots):
611 611 for i in range(1, len(tree)):
612 612 if self.is_string_constant(tree[i]) and self.is_pass_stmt(tree[i+1]):
613 613 first_line = self.first_line_of_tree(tree[i])
614 614 last_line = self.last_line_of_tree(tree[i+1])
615 615 self.record_multiline(spots, first_line, last_line)
616
616
617 617 def is_string_constant(self, tree):
618 618 try:
619 619 return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.expr_stmt
620 620 except:
621 621 return False
622
622
623 623 def is_pass_stmt(self, tree):
624 624 try:
625 625 return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.pass_stmt
@@ -629,7 +629,7 b' class coverage:'
629 629 def record_multiline(self, spots, i, j):
630 630 for l in range(i, j+1):
631 631 spots[l] = (i, j)
632
632
633 633 def get_suite_spots(self, tree, spots):
634 634 """ Analyze a parse tree to find suite introducers which span a number
635 635 of lines.
@@ -671,7 +671,7 b' class coverage:'
671 671 # treat them differently, especially in the common case of a
672 672 # function with a doc string and a single pass statement.
673 673 self.find_docstring_pass_pair(tree[i], spots)
674
674
675 675 elif tree[i][0] == symbol.simple_stmt:
676 676 first_line = self.first_line_of_tree(tree[i])
677 677 last_line = self.last_line_of_tree(tree[i])
@@ -696,7 +696,7 b' class coverage:'
696 696 tree = parser.suite(text+'\n\n').totuple(1)
697 697 self.get_suite_spots(tree, suite_spots)
698 698 #print "Suite spots:", suite_spots
699
699
700 700 # Use the compiler module to parse the text and find the executable
701 701 # statements. We add newlines to be impervious to final partial lines.
702 702 statements = {}
@@ -806,7 +806,7 b' class coverage:'
806 806 else:
807 807 globbed.append(morf)
808 808 morfs = globbed
809
809
810 810 morfs = self.filter_by_prefix(morfs, omit_prefixes)
811 811 morfs.sort(self.morf_name_compare)
812 812
@@ -873,7 +873,7 b' class coverage:'
873 873 except:
874 874 if not ignore_errors:
875 875 raise
876
876
877 877 def annotate_file(self, filename, statements, excluded, missing, directory=None):
878 878 source = open(filename, 'r')
879 879 if directory:
@@ -901,7 +901,7 b' class coverage:'
901 901 if self.blank_re.match(line):
902 902 dest.write(' ')
903 903 elif self.else_re.match(line):
904 # Special logic for lines containing only 'else:'.
904 # Special logic for lines containing only 'else:'.
905 905 # See [GDR 2001-12-04b, 3.2].
906 906 if i >= len(statements) and j >= len(missing):
907 907 dest.write('! ')
@@ -925,40 +925,40 b' class coverage:'
925 925 the_coverage = coverage()
926 926
927 927 # Module functions call methods in the singleton object.
928 def use_cache(*args, **kw):
928 def use_cache(*args, **kw):
929 929 return the_coverage.use_cache(*args, **kw)
930 930
931 def start(*args, **kw):
931 def start(*args, **kw):
932 932 return the_coverage.start(*args, **kw)
933 933
934 def stop(*args, **kw):
934 def stop(*args, **kw):
935 935 return the_coverage.stop(*args, **kw)
936 936
937 def erase(*args, **kw):
937 def erase(*args, **kw):
938 938 return the_coverage.erase(*args, **kw)
939 939
940 def begin_recursive(*args, **kw):
940 def begin_recursive(*args, **kw):
941 941 return the_coverage.begin_recursive(*args, **kw)
942 942
943 def end_recursive(*args, **kw):
943 def end_recursive(*args, **kw):
944 944 return the_coverage.end_recursive(*args, **kw)
945 945
946 def exclude(*args, **kw):
946 def exclude(*args, **kw):
947 947 return the_coverage.exclude(*args, **kw)
948 948
949 def analysis(*args, **kw):
949 def analysis(*args, **kw):
950 950 return the_coverage.analysis(*args, **kw)
951 951
952 def analysis2(*args, **kw):
952 def analysis2(*args, **kw):
953 953 return the_coverage.analysis2(*args, **kw)
954 954
955 def report(*args, **kw):
955 def report(*args, **kw):
956 956 return the_coverage.report(*args, **kw)
957 957
958 def annotate(*args, **kw):
958 def annotate(*args, **kw):
959 959 return the_coverage.annotate(*args, **kw)
960 960
961 def annotate_file(*args, **kw):
961 def annotate_file(*args, **kw):
962 962 return the_coverage.annotate_file(*args, **kw)
963 963
964 964 # Save coverage data when Python exits. (The atexit module wasn't
@@ -1033,7 +1033,7 b" if __name__ == '__main__':"
1033 1033 # Thanks, Allen.
1034 1034 #
1035 1035 # 2005-12-02 NMB Call threading.settrace so that all threads are measured.
1036 # Thanks Martin Fuzzey. Add a file argument to report so that reports can be
1036 # Thanks Martin Fuzzey. Add a file argument to report so that reports can be
1037 1037 # captured to a different destination.
1038 1038 #
1039 1039 # 2005-12-03 NMB coverage.py can now measure itself.
@@ -541,7 +541,7 b' def run_tests(tests):'
541 541 fp = os.fdopen(options.child, 'w')
542 542 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed))
543 543 for s in skips:
544 fp.write("%s %s\n" % s)
544 fp.write("%s %s\n" % s)
545 545 fp.close()
546 546 else:
547 547 print
General Comments 0
You need to be logged in to leave comments. Login now