##// END OF EJS Templates
cleanup: use x in (a, b) instead of x == a or x == b
Brodie Rao -
r12387:4f8067c9 default
parent child Browse files
Show More
@@ -177,7 +177,7 b' class p4_source(converter_source):'
177 elif "k" in flags:
177 elif "k" in flags:
178 keywords = self.re_keywords
178 keywords = self.re_keywords
179
179
180 elif code == "text" or code == "binary":
180 elif code in ("text", "binary"):
181 contents += data
181 contents += data
182
182
183 if mode is None:
183 if mode is None:
@@ -34,7 +34,7 b' def ancestor(a, b, pfunc):'
34 visit.pop()
34 visit.pop()
35 else:
35 else:
36 for p in pl:
36 for p in pl:
37 if p == a or p == b: # did we find a or b as a parent?
37 if p in (a, b): # did we find a or b as a parent?
38 return p # we're done
38 return p # we're done
39 if p not in depth:
39 if p not in depth:
40 visit.append(p)
40 visit.append(p)
@@ -219,7 +219,7 b' def parsedag(desc):'
219 yield 'n', (r, [p1])
219 yield 'n', (r, [p1])
220 p1 = r
220 p1 = r
221 r += 1
221 r += 1
222 elif c == '*' or c == '/':
222 elif c in '*/':
223 if c == '*':
223 if c == '*':
224 c = nextch()
224 c = nextch()
225 c, pref = nextstring(c)
225 c, pref = nextstring(c)
@@ -531,7 +531,7 b' class dirstate(object):'
531 match.dir(nf)
531 match.dir(nf)
532 if not dirignore(nf):
532 if not dirignore(nf):
533 wadd(nf)
533 wadd(nf)
534 elif kind == regkind or kind == lnkkind:
534 elif kind in (regkind, lnkkind):
535 results[nf] = st
535 results[nf] = st
536 else:
536 else:
537 badfn(ff, badtype(kind))
537 badfn(ff, badtype(kind))
@@ -25,7 +25,7 b' def moduledoc(file):'
25 break
25 break
26
26
27 start = line[:3]
27 start = line[:3]
28 if start == '"""' or start == "'''":
28 if start in ('"""', "'''"):
29 line = line[3:]
29 line = line[3:]
30 while line:
30 while line:
31 if line.rstrip().endswith(start):
31 if line.rstrip().endswith(start):
@@ -496,7 +496,7 b' def update(repo, node, branchmerge, forc'
496 raise util.Abort(_("outstanding uncommitted changes "
496 raise util.Abort(_("outstanding uncommitted changes "
497 "(use 'hg status' to list changes)"))
497 "(use 'hg status' to list changes)"))
498 elif not overwrite:
498 elif not overwrite:
499 if pa == p1 or pa == p2: # linear
499 if pa in (p1, p2): # linear
500 pass # all good
500 pass # all good
501 elif wc.files() or wc.deleted():
501 elif wc.files() or wc.deleted():
502 raise util.Abort(_("crosses branches (use 'hg merge' to merge "
502 raise util.Abort(_("crosses branches (use 'hg merge' to merge "
@@ -41,9 +41,9 b' def fix_newline(hunk, a, b):'
41 hline = l[:-1]
41 hline = l[:-1]
42 c = hline[0]
42 c = hline[0]
43
43
44 if c == " " or c == "+":
44 if c in " +":
45 b[-1] = hline[1:]
45 b[-1] = hline[1:]
46 if c == " " or c == "-":
46 if c in " -":
47 a[-1] = hline
47 a[-1] = hline
48 hunk[-1] = hline
48 hunk[-1] = hline
49 return 0
49 return 0
@@ -87,7 +87,7 b' def tokenize(program):'
87 # helpers
87 # helpers
88
88
89 def getstring(x, err):
89 def getstring(x, err):
90 if x and (x[0] == 'string' or x[0] == 'symbol'):
90 if x and x[0] in ('string', 'symbol'):
91 return x[1]
91 return x[1]
92 raise error.ParseError(err)
92 raise error.ParseError(err)
93
93
@@ -537,7 +537,7 b' def optimize(x, small):'
537 '-' + getstring(x[1], _("can't negate that"))), small)
537 '-' + getstring(x[1], _("can't negate that"))), small)
538 elif op in 'string symbol negate':
538 elif op in 'string symbol negate':
539 return smallbonus, x # single revisions are small
539 return smallbonus, x # single revisions are small
540 elif op == 'and' or op == 'dagrange':
540 elif op in ('and', 'dagrange'):
541 wa, ta = optimize(x[1], True)
541 wa, ta = optimize(x[1], True)
542 wb, tb = optimize(x[2], True)
542 wb, tb = optimize(x[2], True)
543 w = min(wa, wb)
543 w = min(wa, wb)
@@ -110,7 +110,7 b' class Merge3Text(object):'
110 if what == 'unchanged':
110 if what == 'unchanged':
111 for i in range(t[1], t[2]):
111 for i in range(t[1], t[2]):
112 yield self.base[i]
112 yield self.base[i]
113 elif what == 'a' or what == 'same':
113 elif what in ('a', 'same'):
114 for i in range(t[1], t[2]):
114 for i in range(t[1], t[2]):
115 yield self.a[i]
115 yield self.a[i]
116 elif what == 'b':
116 elif what == 'b':
@@ -142,7 +142,7 b' class Merge3Text(object):'
142 if what == 'unchanged':
142 if what == 'unchanged':
143 for i in range(t[1], t[2]):
143 for i in range(t[1], t[2]):
144 yield 'u | ' + self.base[i]
144 yield 'u | ' + self.base[i]
145 elif what == 'a' or what == 'same':
145 elif what in ('a', 'same'):
146 for i in range(t[1], t[2]):
146 for i in range(t[1], t[2]):
147 yield what[0] + ' | ' + self.a[i]
147 yield what[0] + ' | ' + self.a[i]
148 elif what == 'b':
148 elif what == 'b':
@@ -181,7 +181,7 b' class Merge3Text(object):'
181 what = t[0]
181 what = t[0]
182 if what == 'unchanged':
182 if what == 'unchanged':
183 yield what, self.base[t[1]:t[2]]
183 yield what, self.base[t[1]:t[2]]
184 elif what == 'a' or what == 'same':
184 elif what in ('a', 'same'):
185 yield what, self.a[t[1]:t[2]]
185 yield what, self.a[t[1]:t[2]]
186 elif what == 'b':
186 elif what == 'b':
187 yield what, self.b[t[1]:t[2]]
187 yield what, self.b[t[1]:t[2]]
@@ -640,7 +640,7 b' def fspath(name, root):'
640 # If name is absolute, make it relative
640 # If name is absolute, make it relative
641 if name.lower().startswith(root.lower()):
641 if name.lower().startswith(root.lower()):
642 l = len(root)
642 l = len(root)
643 if name[l] == os.sep or name[l] == os.altsep:
643 if name[l] in (os.sep, os.altsep):
644 l = l + 1
644 l = l + 1
645 name = name[l:]
645 name = name[l:]
646
646
@@ -1008,7 +1008,7 b' def strdate(string, format, defaults=[])'
1008 hours = int(tz[1:3])
1008 hours = int(tz[1:3])
1009 minutes = int(tz[3:5])
1009 minutes = int(tz[3:5])
1010 return -sign * (hours * 60 + minutes) * 60
1010 return -sign * (hours * 60 + minutes) * 60
1011 if tz == "GMT" or tz == "UTC":
1011 if tz in ("GMT", "UTC"):
1012 return 0
1012 return 0
1013 return None
1013 return None
1014
1014
@@ -50,7 +50,7 b' def nlinks(pathname):'
50 if not dirname:
50 if not dirname:
51 dirname = '.'
51 dirname = '.'
52 dt = win32file.GetDriveType(dirname + '\\')
52 dt = win32file.GetDriveType(dirname + '\\')
53 if dt == 4 or dt == 1:
53 if dt in (4, 1):
54 # Fake hardlink to force COW for network drives
54 # Fake hardlink to force COW for network drives
55 links = 2
55 links = 2
56 return links
56 return links
General Comments 0
You need to be logged in to leave comments. Login now