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