##// END OF EJS Templates
Prefer i in d over d.has_key(i)
Christian Ebert -
r5915:d0576d06 default
parent child Browse files
Show More
@@ -114,11 +114,11 b' def gather_stats(ui, repo, amap, revs=No'
114 who, lines = __gather(ui, repo, node1, node2)
114 who, lines = __gather(ui, repo, node1, node2)
115
115
116 # remap the owner if possible
116 # remap the owner if possible
117 if amap.has_key(who):
117 if who in amap:
118 ui.note("using '%s' alias for '%s'\n" % (amap[who], who))
118 ui.note("using '%s' alias for '%s'\n" % (amap[who], who))
119 who = amap[who]
119 who = amap[who]
120
120
121 if not stats.has_key(who):
121 if not who in stats:
122 stats[who] = 0
122 stats[who] = 0
123 stats[who] += lines
123 stats[who] += lines
124
124
@@ -243,7 +243,7 b' def _overwrite(ui, repo, node=None, expa'
243 mf = ctx.manifest()
243 mf = ctx.manifest()
244 if node is not None: # commit
244 if node is not None: # commit
245 _kwtemplater.commitnode = node
245 _kwtemplater.commitnode = node
246 files = [f for f in ctx.files() if mf.has_key(f)]
246 files = [f for f in ctx.files() if f in mf]
247 notify = ui.debug
247 notify = ui.debug
248 else: # kwexpand/kwshrink
248 else: # kwexpand/kwshrink
249 notify = ui.note
249 notify = ui.note
@@ -418,8 +418,7 b' def patchbomb(ui, repo, *revs, **opts):'
418 fp.close()
418 fp.close()
419 elif opts.get('mbox'):
419 elif opts.get('mbox'):
420 ui.status('Writing ', m['Subject'], ' ...\n')
420 ui.status('Writing ', m['Subject'], ' ...\n')
421 fp = open(opts.get('mbox'),
421 fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+')
422 m.has_key('In-Reply-To') and 'ab+' or 'wb+')
423 date = util.datestr(date=start_time,
422 date = util.datestr(date=start_time,
424 format='%a %b %d %H:%M:%S %Y', timezone=False)
423 format='%a %b %d %H:%M:%S %Y', timezone=False)
425 fp.write('From %s %s\n' % (sender_addr, date))
424 fp.write('From %s %s\n' % (sender_addr, date))
@@ -50,7 +50,7 b' def findcmd(ui, cmd, table):'
50 """Return (aliases, command table entry) for command string."""
50 """Return (aliases, command table entry) for command string."""
51 choice = findpossible(ui, cmd, table)
51 choice = findpossible(ui, cmd, table)
52
52
53 if choice.has_key(cmd):
53 if cmd in choice:
54 return choice[cmd]
54 return choice[cmd]
55
55
56 if len(choice) > 1:
56 if len(choice) > 1:
@@ -235,7 +235,7 b' class dirstate(object):'
235 self._changepath(f, 'n', True)
235 self._changepath(f, 'n', True)
236 s = os.lstat(self._join(f))
236 s = os.lstat(self._join(f))
237 self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime, 0)
237 self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime, 0)
238 if self._copymap.has_key(f):
238 if f in self._copymap:
239 del self._copymap[f]
239 del self._copymap[f]
240
240
241 def normallookup(self, f):
241 def normallookup(self, f):
@@ -58,7 +58,7 b' class filelog(revlog):'
58 if self.parents(node)[0] != nullid:
58 if self.parents(node)[0] != nullid:
59 return False
59 return False
60 m = self._readmeta(node)
60 m = self._readmeta(node)
61 if m and m.has_key("copy"):
61 if m and "copy" in m:
62 return (m["copy"], bin(m["copyrev"]))
62 return (m["copy"], bin(m["copyrev"]))
63 return False
63 return False
64
64
@@ -153,7 +153,7 b' class hgweb(object):'
153 req.url = req.env['SCRIPT_NAME']
153 req.url = req.env['SCRIPT_NAME']
154 if not req.url.endswith('/'):
154 if not req.url.endswith('/'):
155 req.url += '/'
155 req.url += '/'
156 if req.env.has_key('REPO_NAME'):
156 if 'REPO_NAME' in req.env:
157 req.url += req.env['REPO_NAME'] + '/'
157 req.url += req.env['REPO_NAME'] + '/'
158
158
159 if req.env.get('PATH_INFO'):
159 if req.env.get('PATH_INFO'):
@@ -267,7 +267,7 b' class hgweb(object):'
267
267
268 def sessionvars(**map):
268 def sessionvars(**map):
269 fields = []
269 fields = []
270 if req.form.has_key('style'):
270 if 'style' in req.form:
271 style = req.form['style'][0]
271 style = req.form['style'][0]
272 if style != self.config('web', 'style', ''):
272 if style != self.config('web', 'style', ''):
273 fields.append(('style', style))
273 fields.append(('style', style))
@@ -280,7 +280,7 b' class hgweb(object):'
280 # figure out which style to use
280 # figure out which style to use
281
281
282 style = self.config("web", "style", "")
282 style = self.config("web", "style", "")
283 if req.form.has_key('style'):
283 if 'style' in req.form:
284 style = req.form['style'][0]
284 style = req.form['style'][0]
285 mapfile = style_map(self.templatepath, style)
285 mapfile = style_map(self.templatepath, style)
286
286
@@ -863,9 +863,9 b' class hgweb(object):'
863 return util.canonpath(self.repo.root, '', path)
863 return util.canonpath(self.repo.root, '', path)
864
864
865 def changectx(self, req):
865 def changectx(self, req):
866 if req.form.has_key('node'):
866 if 'node' in req.form:
867 changeid = req.form['node'][0]
867 changeid = req.form['node'][0]
868 elif req.form.has_key('manifest'):
868 elif 'manifest' in req.form:
869 changeid = req.form['manifest'][0]
869 changeid = req.form['manifest'][0]
870 else:
870 else:
871 changeid = self.repo.changelog.count() - 1
871 changeid = self.repo.changelog.count() - 1
@@ -881,7 +881,7 b' class hgweb(object):'
881
881
882 def filectx(self, req):
882 def filectx(self, req):
883 path = self.cleanpath(req.form['file'][0])
883 path = self.cleanpath(req.form['file'][0])
884 if req.form.has_key('node'):
884 if 'node' in req.form:
885 changeid = req.form['node'][0]
885 changeid = req.form['node'][0]
886 else:
886 else:
887 changeid = req.form['filenode'][0]
887 changeid = req.form['filenode'][0]
@@ -143,7 +143,7 b' class hgwebdir(object):'
143 def entries(sortcolumn="", descending=False, subdir="", **map):
143 def entries(sortcolumn="", descending=False, subdir="", **map):
144 def sessionvars(**map):
144 def sessionvars(**map):
145 fields = []
145 fields = []
146 if req.form.has_key('style'):
146 if 'style' in req.form:
147 style = req.form['style'][0]
147 style = req.form['style'][0]
148 if style != get('web', 'style', ''):
148 if style != get('web', 'style', ''):
149 fields.append(('style', style))
149 fields.append(('style', style))
@@ -214,7 +214,7 b' class hgwebdir(object):'
214
214
215 sortable = ["name", "description", "contact", "lastchange"]
215 sortable = ["name", "description", "contact", "lastchange"]
216 sortcolumn, descending = self.repos_sorted
216 sortcolumn, descending = self.repos_sorted
217 if req.form.has_key('sort'):
217 if 'sort' in req.form:
218 sortcolumn = req.form['sort'][0]
218 sortcolumn = req.form['sort'][0]
219 descending = sortcolumn.startswith('-')
219 descending = sortcolumn.startswith('-')
220 if descending:
220 if descending:
@@ -262,7 +262,7 b' class hgwebdir(object):'
262 style = self.style
262 style = self.style
263 if style is None:
263 if style is None:
264 style = config('web', 'style', '')
264 style = config('web', 'style', '')
265 if req.form.has_key('style'):
265 if 'style' in req.form:
266 style = req.form['style'][0]
266 style = req.form['style'][0]
267 if self.stripecount is None:
267 if self.stripecount is None:
268 self.stripecount = int(config('web', 'stripes', 1))
268 self.stripecount = int(config('web', 'stripes', 1))
@@ -28,7 +28,7 b' def heads(web, req):'
28
28
29 def branches(web, req):
29 def branches(web, req):
30 nodes = []
30 nodes = []
31 if req.form.has_key('nodes'):
31 if 'nodes' in req.form:
32 nodes = map(bin, req.form['nodes'][0].split(" "))
32 nodes = map(bin, req.form['nodes'][0].split(" "))
33 resp = cStringIO.StringIO()
33 resp = cStringIO.StringIO()
34 for b in web.repo.branches(nodes):
34 for b in web.repo.branches(nodes):
@@ -38,7 +38,7 b' def branches(web, req):'
38 req.write(resp)
38 req.write(resp)
39
39
40 def between(web, req):
40 def between(web, req):
41 if req.form.has_key('pairs'):
41 if 'pairs' in req.form:
42 pairs = [map(bin, p.split("-"))
42 pairs = [map(bin, p.split("-"))
43 for p in req.form['pairs'][0].split(" ")]
43 for p in req.form['pairs'][0].split(" ")]
44 resp = cStringIO.StringIO()
44 resp = cStringIO.StringIO()
@@ -54,7 +54,7 b' def changegroup(web, req):'
54 if not web.allowpull:
54 if not web.allowpull:
55 return
55 return
56
56
57 if req.form.has_key('roots'):
57 if 'roots' in req.form:
58 nodes = map(bin, req.form['roots'][0].split(" "))
58 nodes = map(bin, req.form['roots'][0].split(" "))
59
59
60 z = zlib.compressobj()
60 z = zlib.compressobj()
@@ -74,9 +74,9 b' def changegroupsubset(web, req):'
74 if not web.allowpull:
74 if not web.allowpull:
75 return
75 return
76
76
77 if req.form.has_key('bases'):
77 if 'bases' in req.form:
78 bases = [bin(x) for x in req.form['bases'][0].split(' ')]
78 bases = [bin(x) for x in req.form['bases'][0].split(' ')]
79 if req.form.has_key('heads'):
79 if 'heads' in req.form:
80 heads = [bin(x) for x in req.form['heads'][0].split(' ')]
80 heads = [bin(x) for x in req.form['heads'][0].split(' ')]
81
81
82 z = zlib.compressobj()
82 z = zlib.compressobj()
@@ -10,7 +10,7 b' from mercurial import revlog, util'
10 from common import staticfile
10 from common import staticfile
11
11
12 def log(web, req, tmpl):
12 def log(web, req, tmpl):
13 if req.form.has_key('file') and req.form['file'][0]:
13 if 'file' in req.form and req.form['file'][0]:
14 filelog(web, req, tmpl)
14 filelog(web, req, tmpl)
15 else:
15 else:
16 changelog(web, req, tmpl)
16 changelog(web, req, tmpl)
@@ -48,10 +48,10 b' def file(web, req, tmpl):'
48 req.write(web.manifest(tmpl, web.changectx(req), path))
48 req.write(web.manifest(tmpl, web.changectx(req), path))
49
49
50 def changelog(web, req, tmpl, shortlog = False):
50 def changelog(web, req, tmpl, shortlog = False):
51 if req.form.has_key('node'):
51 if 'node' in req.form:
52 ctx = web.changectx(req)
52 ctx = web.changectx(req)
53 else:
53 else:
54 if req.form.has_key('rev'):
54 if 'rev' in req.form:
55 hi = req.form['rev'][0]
55 hi = req.form['rev'][0]
56 else:
56 else:
57 hi = web.repo.changelog.count() - 1
57 hi = web.repo.changelog.count() - 1
@@ -247,7 +247,7 b' class httprepository(remoterepository):'
247 # will take precedence if found, so drop them
247 # will take precedence if found, so drop them
248 for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
248 for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
249 try:
249 try:
250 if os.environ.has_key(env):
250 if env in os.environ:
251 del os.environ[env]
251 del os.environ[env]
252 except OSError:
252 except OSError:
253 pass
253 pass
@@ -129,7 +129,7 b' class ConnectionManager:'
129 def add(self, host, connection, ready):
129 def add(self, host, connection, ready):
130 self._lock.acquire()
130 self._lock.acquire()
131 try:
131 try:
132 if not self._hostmap.has_key(host): self._hostmap[host] = []
132 if not host in self._hostmap: self._hostmap[host] = []
133 self._hostmap[host].append(connection)
133 self._hostmap[host].append(connection)
134 self._connmap[connection] = host
134 self._connmap[connection] = host
135 self._readymap[connection] = ready
135 self._readymap[connection] = ready
@@ -159,7 +159,7 b' class ConnectionManager:'
159 conn = None
159 conn = None
160 self._lock.acquire()
160 self._lock.acquire()
161 try:
161 try:
162 if self._hostmap.has_key(host):
162 if host in self._hostmap:
163 for c in self._hostmap[host]:
163 for c in self._hostmap[host]:
164 if self._readymap[c]:
164 if self._readymap[c]:
165 self._readymap[c] = 0
165 self._readymap[c] = 0
@@ -998,7 +998,7 b' class localrepository(repo.repository):'
998 mf2keys.sort()
998 mf2keys.sort()
999 getnode = lambda fn: mf1.get(fn, nullid)
999 getnode = lambda fn: mf1.get(fn, nullid)
1000 for fn in mf2keys:
1000 for fn in mf2keys:
1001 if mf1.has_key(fn):
1001 if fn in mf1:
1002 if (mf1.flags(fn) != mf2.flags(fn) or
1002 if (mf1.flags(fn) != mf2.flags(fn) or
1003 (mf1[fn] != mf2[fn] and
1003 (mf1[fn] != mf2[fn] and
1004 (mf2[fn] != "" or fcmp(fn, getnode)))):
1004 (mf2[fn] != "" or fcmp(fn, getnode)))):
@@ -1779,7 +1779,7 b' class localrepository(repo.repository):'
1779 raise util.Abort(_("empty or missing revlog for %s") % fname)
1779 raise util.Abort(_("empty or missing revlog for %s") % fname)
1780 # Toss out the filenodes that the recipient isn't really
1780 # Toss out the filenodes that the recipient isn't really
1781 # missing.
1781 # missing.
1782 if msng_filenode_set.has_key(fname):
1782 if fname in msng_filenode_set:
1783 prune_filenodes(fname, filerevlog)
1783 prune_filenodes(fname, filerevlog)
1784 msng_filenode_lst = msng_filenode_set[fname].keys()
1784 msng_filenode_lst = msng_filenode_set[fname].keys()
1785 else:
1785 else:
@@ -1798,7 +1798,7 b' class localrepository(repo.repository):'
1798 lookup_filenode_link_func(fname))
1798 lookup_filenode_link_func(fname))
1799 for chnk in group:
1799 for chnk in group:
1800 yield chnk
1800 yield chnk
1801 if msng_filenode_set.has_key(fname):
1801 if fname in msng_filenode_set:
1802 # Don't need this anymore, toss it to free memory.
1802 # Don't need this anymore, toss it to free memory.
1803 del msng_filenode_set[fname]
1803 del msng_filenode_set[fname]
1804 # Signal that no more groups are left.
1804 # Signal that no more groups are left.
@@ -82,7 +82,7 b' class templater(object):'
82 '''perform expansion.
82 '''perform expansion.
83 t is name of map element to expand.
83 t is name of map element to expand.
84 map is added elements to use during expansion.'''
84 map is added elements to use during expansion.'''
85 if not self.cache.has_key(t):
85 if not t in self.cache:
86 try:
86 try:
87 self.cache[t] = file(self.map[t]).read()
87 self.cache[t] = file(self.map[t]).read()
88 except IOError, inst:
88 except IOError, inst:
@@ -186,9 +186,9 b' class StatementFindingAstVisitor(compile'
186 return 0
186 return 0
187 # If this line is excluded, or suite_spots maps this line to
187 # If this line is excluded, or suite_spots maps this line to
188 # another line that is exlcuded, then we're excluded.
188 # another line that is exlcuded, then we're excluded.
189 elif self.excluded.has_key(lineno) or \
189 elif lineno in self.excluded or \
190 self.suite_spots.has_key(lineno) and \
190 lineno in self.suite_spots and \
191 self.excluded.has_key(self.suite_spots[lineno][1]):
191 self.suite_spots[lineno][1] in self.excluded:
192 return 0
192 return 0
193 # Otherwise, this is an executable line.
193 # Otherwise, this is an executable line.
194 else:
194 else:
@@ -217,8 +217,8 b' class StatementFindingAstVisitor(compile'
217 lastprev = self.getLastLine(prevsuite)
217 lastprev = self.getLastLine(prevsuite)
218 firstelse = self.getFirstLine(suite)
218 firstelse = self.getFirstLine(suite)
219 for l in range(lastprev+1, firstelse):
219 for l in range(lastprev+1, firstelse):
220 if self.suite_spots.has_key(l):
220 if l in self.suite_spots:
221 self.doSuite(None, suite, exclude=self.excluded.has_key(l))
221 self.doSuite(None, suite, l in exclude=self.excluded)
222 break
222 break
223 else:
223 else:
224 self.doSuite(None, suite)
224 self.doSuite(None, suite)
@@ -353,9 +353,9 b' class coverage:'
353 long_opts = optmap.values()
353 long_opts = optmap.values()
354 options, args = getopt.getopt(argv, short_opts, long_opts)
354 options, args = getopt.getopt(argv, short_opts, long_opts)
355 for o, a in options:
355 for o, a in options:
356 if optmap.has_key(o):
356 if o in optmap:
357 settings[optmap[o]] = 1
357 settings[optmap[o]] = 1
358 elif optmap.has_key(o + ':'):
358 elif o + ':' in optmap:
359 settings[optmap[o + ':']] = a
359 settings[optmap[o + ':']] = a
360 elif o[2:] in long_opts:
360 elif o[2:] in long_opts:
361 settings[o[2:]] = 1
361 settings[o[2:]] = 1
@@ -512,14 +512,14 b' class coverage:'
512
512
513 def merge_data(self, new_data):
513 def merge_data(self, new_data):
514 for file_name, file_data in new_data.items():
514 for file_name, file_data in new_data.items():
515 if self.cexecuted.has_key(file_name):
515 if file_name in self.cexecuted:
516 self.merge_file_data(self.cexecuted[file_name], file_data)
516 self.merge_file_data(self.cexecuted[file_name], file_data)
517 else:
517 else:
518 self.cexecuted[file_name] = file_data
518 self.cexecuted[file_name] = file_data
519
519
520 def merge_file_data(self, cache_data, new_data):
520 def merge_file_data(self, cache_data, new_data):
521 for line_number in new_data.keys():
521 for line_number in new_data.keys():
522 if not cache_data.has_key(line_number):
522 if not line_number in cache_data:
523 cache_data[line_number] = new_data[line_number]
523 cache_data[line_number] = new_data[line_number]
524
524
525 # canonical_filename(filename). Return a canonical filename for the
525 # canonical_filename(filename). Return a canonical filename for the
@@ -527,7 +527,7 b' class coverage:'
527 # normalized case). See [GDR 2001-12-04b, 3.3].
527 # normalized case). See [GDR 2001-12-04b, 3.3].
528
528
529 def canonical_filename(self, filename):
529 def canonical_filename(self, filename):
530 if not self.canonical_filename_cache.has_key(filename):
530 if not filename in self.canonical_filename_cache:
531 f = filename
531 f = filename
532 if os.path.isabs(f) and not os.path.exists(f):
532 if os.path.isabs(f) and not os.path.exists(f):
533 f = os.path.basename(f)
533 f = os.path.basename(f)
@@ -550,7 +550,7 b' class coverage:'
550 # Can't do anything useful with exec'd strings, so skip them.
550 # Can't do anything useful with exec'd strings, so skip them.
551 continue
551 continue
552 f = self.canonical_filename(filename)
552 f = self.canonical_filename(filename)
553 if not self.cexecuted.has_key(f):
553 if not f in self.cexecuted:
554 self.cexecuted[f] = {}
554 self.cexecuted[f] = {}
555 self.cexecuted[f][lineno] = 1
555 self.cexecuted[f][lineno] = 1
556 self.c = {}
556 self.c = {}
@@ -575,7 +575,7 b' class coverage:'
575 # statements that cross lines.
575 # statements that cross lines.
576
576
577 def analyze_morf(self, morf):
577 def analyze_morf(self, morf):
578 if self.analysis_cache.has_key(morf):
578 if morf in self.analysis_cache:
579 return self.analysis_cache[morf]
579 return self.analysis_cache[morf]
580 filename = self.morf_filename(morf)
580 filename = self.morf_filename(morf)
581 ext = os.path.splitext(filename)[1]
581 ext = os.path.splitext(filename)[1]
@@ -752,13 +752,13 b' class coverage:'
752 def analysis2(self, morf):
752 def analysis2(self, morf):
753 filename, statements, excluded, line_map = self.analyze_morf(morf)
753 filename, statements, excluded, line_map = self.analyze_morf(morf)
754 self.canonicalize_filenames()
754 self.canonicalize_filenames()
755 if not self.cexecuted.has_key(filename):
755 if not filename in self.cexecuted:
756 self.cexecuted[filename] = {}
756 self.cexecuted[filename] = {}
757 missing = []
757 missing = []
758 for line in statements:
758 for line in statements:
759 lines = line_map.get(line, [line, line])
759 lines = line_map.get(line, [line, line])
760 for l in range(lines[0], lines[1]+1):
760 for l in range(lines[0], lines[1]+1):
761 if self.cexecuted[filename].has_key(l):
761 if l in self.cexecuted[filename]:
762 break
762 break
763 else:
763 else:
764 missing.append(line)
764 missing.append(line)
General Comments 0
You need to be logged in to leave comments. Login now