##// END OF EJS Templates
use __contains__, index or split instead of str.find...
Benoit Boissinot -
r2579:0875cda0 default
parent child Browse files
Show More
@@ -231,7 +231,7 b' def revrange(ui, repo, revs):'
231 231 """Yield revision as strings from a list of revision specifications."""
232 232 seen = {}
233 233 for spec in revs:
234 if spec.find(revrangesep) >= 0:
234 if revrangesep in spec:
235 235 start, end = spec.split(revrangesep, 1)
236 236 start = revfix(repo, start, 0)
237 237 end = revfix(repo, end, repo.changelog.count() - 1)
@@ -2742,7 +2742,7 b' def tag(ui, repo, name, rev_=None, **opt'
2742 2742
2743 2743 disallowed = (revrangesep, '\r', '\n')
2744 2744 for c in disallowed:
2745 if name.find(c) >= 0:
2745 if c in name:
2746 2746 raise util.Abort(_("%s cannot be used in a tag name") % repr(c))
2747 2747
2748 2748 repo.hook('pretag', throw=True, node=r, tag=name,
@@ -34,14 +34,14 b' class filelog(revlog):'
34 34 t = self.revision(node)
35 35 if not t.startswith('\1\n'):
36 36 return t
37 s = t.find('\1\n', 2)
37 s = t.index('\1\n', 2)
38 38 return t[s+2:]
39 39
40 40 def readmeta(self, node):
41 41 t = self.revision(node)
42 42 if not t.startswith('\1\n'):
43 43 return {}
44 s = t.find('\1\n', 2)
44 s = t.index('\1\n', 2)
45 45 mt = t[2:s]
46 46 m = {}
47 47 for l in mt.splitlines():
@@ -61,8 +61,7 b' def repository(ui, path=None, create=0):'
61 61 if not path: path = ''
62 62 scheme = path
63 63 if scheme:
64 c = scheme.find(':')
65 scheme = c >= 0 and scheme[:c]
64 scheme = scheme.split(":", 1)[0]
66 65 ctor = schemes.get(scheme) or schemes['file']
67 66 if create:
68 67 try:
@@ -462,7 +462,7 b' class hgweb(object):'
462 462 continue
463 463 remain = f[l:]
464 464 if "/" in remain:
465 short = remain[:remain.find("/") + 1] # bleah
465 short = remain[:remain.index("/") + 1] # bleah
466 466 files[short] = (f, None)
467 467 else:
468 468 short = os.path.basename(remain)
@@ -85,14 +85,14 b' class lock(object):'
85 85 # see if locker is alive. if locker is on this machine but
86 86 # not alive, we can safely break lock.
87 87 locker = util.readlock(self.f)
88 c = locker.find(':')
89 if c == -1:
88 try:
89 host, pid = locker.split(":", 1)
90 except ValueError:
90 91 return locker
91 host = locker[:c]
92 92 if host != self.host:
93 93 return locker
94 94 try:
95 pid = int(locker[c+1:])
95 pid = int(pid)
96 96 except:
97 97 return locker
98 98 if util.testpid(pid):
@@ -76,7 +76,7 b' class ui(object):'
76 76 if root is None:
77 77 root = os.path.expanduser('~')
78 78 for name, path in self.configitems("paths"):
79 if path and path.find("://") == -1 and not os.path.isabs(path):
79 if path and "://" not in path and not os.path.isabs(path):
80 80 self.cdata.set("paths", name, os.path.join(root, path))
81 81
82 82 def setconfig(self, section, name, val):
@@ -208,7 +208,7 b' class ui(object):'
208 208
209 209 def expandpath(self, loc, default=None):
210 210 """Return repository location relative to cwd or from [paths]"""
211 if loc.find("://") != -1 or os.path.exists(loc):
211 if "://" in loc or os.path.exists(loc):
212 212 return loc
213 213
214 214 path = self.config("paths", loc)
@@ -620,7 +620,7 b' else:'
620 620 def parse_patch_output(output_line):
621 621 """parses the output produced by patch and returns the file name"""
622 622 pf = output_line[14:]
623 if pf.startswith("'") and pf.endswith("'") and pf.find(" ") >= 0:
623 if pf.startswith("'") and pf.endswith("'") and " " in pf:
624 624 pf = pf[1:-1] # Remove the quotes
625 625 return pf
626 626
General Comments 0
You need to be logged in to leave comments. Login now