diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py --- a/hgext/convert/p4.py +++ b/hgext/convert/p4.py @@ -177,7 +177,7 @@ class p4_source(converter_source): elif "k" in flags: keywords = self.re_keywords - elif code == "text" or code == "binary": + elif code in ("text", "binary"): contents += data if mode is None: diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py --- a/mercurial/ancestor.py +++ b/mercurial/ancestor.py @@ -34,7 +34,7 @@ def ancestor(a, b, pfunc): visit.pop() else: for p in pl: - if p == a or p == b: # did we find a or b as a parent? + if p in (a, b): # did we find a or b as a parent? return p # we're done if p not in depth: visit.append(p) diff --git a/mercurial/dagparser.py b/mercurial/dagparser.py --- a/mercurial/dagparser.py +++ b/mercurial/dagparser.py @@ -219,7 +219,7 @@ def parsedag(desc): yield 'n', (r, [p1]) p1 = r r += 1 - elif c == '*' or c == '/': + elif c in '*/': if c == '*': c = nextch() c, pref = nextstring(c) diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -531,7 +531,7 @@ class dirstate(object): match.dir(nf) if not dirignore(nf): wadd(nf) - elif kind == regkind or kind == lnkkind: + elif kind in (regkind, lnkkind): results[nf] = st else: badfn(ff, badtype(kind)) diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -25,7 +25,7 @@ def moduledoc(file): break start = line[:3] - if start == '"""' or start == "'''": + if start in ('"""', "'''"): line = line[3:] while line: if line.rstrip().endswith(start): diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -496,7 +496,7 @@ def update(repo, node, branchmerge, forc raise util.Abort(_("outstanding uncommitted changes " "(use 'hg status' to list changes)")) elif not overwrite: - if pa == p1 or pa == p2: # linear + if pa in (p1, p2): # linear pass # all good elif wc.files() or wc.deleted(): raise util.Abort(_("crosses branches (use 'hg merge' to merge " diff --git a/mercurial/pure/diffhelpers.py b/mercurial/pure/diffhelpers.py --- a/mercurial/pure/diffhelpers.py +++ b/mercurial/pure/diffhelpers.py @@ -41,9 +41,9 @@ def fix_newline(hunk, a, b): hline = l[:-1] c = hline[0] - if c == " " or c == "+": + if c in " +": b[-1] = hline[1:] - if c == " " or c == "-": + if c in " -": a[-1] = hline hunk[-1] = hline return 0 diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -87,7 +87,7 @@ def tokenize(program): # helpers def getstring(x, err): - if x and (x[0] == 'string' or x[0] == 'symbol'): + if x and x[0] in ('string', 'symbol'): return x[1] raise error.ParseError(err) @@ -537,7 +537,7 @@ def optimize(x, small): '-' + getstring(x[1], _("can't negate that"))), small) elif op in 'string symbol negate': return smallbonus, x # single revisions are small - elif op == 'and' or op == 'dagrange': + elif op in ('and', 'dagrange'): wa, ta = optimize(x[1], True) wb, tb = optimize(x[2], True) w = min(wa, wb) diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py --- a/mercurial/simplemerge.py +++ b/mercurial/simplemerge.py @@ -110,7 +110,7 @@ class Merge3Text(object): if what == 'unchanged': for i in range(t[1], t[2]): yield self.base[i] - elif what == 'a' or what == 'same': + elif what in ('a', 'same'): for i in range(t[1], t[2]): yield self.a[i] elif what == 'b': @@ -142,7 +142,7 @@ class Merge3Text(object): if what == 'unchanged': for i in range(t[1], t[2]): yield 'u | ' + self.base[i] - elif what == 'a' or what == 'same': + elif what in ('a', 'same'): for i in range(t[1], t[2]): yield what[0] + ' | ' + self.a[i] elif what == 'b': @@ -181,7 +181,7 @@ class Merge3Text(object): what = t[0] if what == 'unchanged': yield what, self.base[t[1]:t[2]] - elif what == 'a' or what == 'same': + elif what in ('a', 'same'): yield what, self.a[t[1]:t[2]] elif what == 'b': yield what, self.b[t[1]:t[2]] diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -640,7 +640,7 @@ def fspath(name, root): # If name is absolute, make it relative if name.lower().startswith(root.lower()): l = len(root) - if name[l] == os.sep or name[l] == os.altsep: + if name[l] in (os.sep, os.altsep): l = l + 1 name = name[l:] @@ -1008,7 +1008,7 @@ def strdate(string, format, defaults=[]) hours = int(tz[1:3]) minutes = int(tz[3:5]) return -sign * (hours * 60 + minutes) * 60 - if tz == "GMT" or tz == "UTC": + if tz in ("GMT", "UTC"): return 0 return None diff --git a/mercurial/win32.py b/mercurial/win32.py --- a/mercurial/win32.py +++ b/mercurial/win32.py @@ -50,7 +50,7 @@ def nlinks(pathname): if not dirname: dirname = '.' dt = win32file.GetDriveType(dirname + '\\') - if dt == 4 or dt == 1: + if dt in (4, 1): # Fake hardlink to force COW for network drives links = 2 return links