# HG changeset patch # User Brodie Rao # Date 1285218151 18000 # Node ID 4f8067c9472952251d4b5a5979f7b59af92381c5 # Parent 8eedf53547b81794db7b02c1c83c99b19c86321f cleanup: use x in (a, b) instead of x == a or x == b diff -r 8eedf53547b8 -r 4f8067c94729 hgext/convert/p4.py --- a/hgext/convert/p4.py Thu Sep 23 10:59:21 2010 +0200 +++ b/hgext/convert/p4.py Thu Sep 23 00:02:31 2010 -0500 @@ -177,7 +177,7 @@ 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/ancestor.py --- a/mercurial/ancestor.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/ancestor.py Thu Sep 23 00:02:31 2010 -0500 @@ -34,7 +34,7 @@ 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/dagparser.py --- a/mercurial/dagparser.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/dagparser.py Thu Sep 23 00:02:31 2010 -0500 @@ -219,7 +219,7 @@ yield 'n', (r, [p1]) p1 = r r += 1 - elif c == '*' or c == '/': + elif c in '*/': if c == '*': c = nextch() c, pref = nextstring(c) diff -r 8eedf53547b8 -r 4f8067c94729 mercurial/dirstate.py --- a/mercurial/dirstate.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/dirstate.py Thu Sep 23 00:02:31 2010 -0500 @@ -531,7 +531,7 @@ 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/help.py --- a/mercurial/help.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/help.py Thu Sep 23 00:02:31 2010 -0500 @@ -25,7 +25,7 @@ break start = line[:3] - if start == '"""' or start == "'''": + if start in ('"""', "'''"): line = line[3:] while line: if line.rstrip().endswith(start): diff -r 8eedf53547b8 -r 4f8067c94729 mercurial/merge.py --- a/mercurial/merge.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/merge.py Thu Sep 23 00:02:31 2010 -0500 @@ -496,7 +496,7 @@ 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/pure/diffhelpers.py --- a/mercurial/pure/diffhelpers.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/pure/diffhelpers.py Thu Sep 23 00:02:31 2010 -0500 @@ -41,9 +41,9 @@ 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/revset.py --- a/mercurial/revset.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/revset.py Thu Sep 23 00:02:31 2010 -0500 @@ -87,7 +87,7 @@ # 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 @@ '-' + 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/simplemerge.py --- a/mercurial/simplemerge.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/simplemerge.py Thu Sep 23 00:02:31 2010 -0500 @@ -110,7 +110,7 @@ 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 @@ 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 @@ 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/util.py --- a/mercurial/util.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/util.py Thu Sep 23 00:02:31 2010 -0500 @@ -640,7 +640,7 @@ # 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 @@ 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 -r 8eedf53547b8 -r 4f8067c94729 mercurial/win32.py --- a/mercurial/win32.py Thu Sep 23 10:59:21 2010 +0200 +++ b/mercurial/win32.py Thu Sep 23 00:02:31 2010 -0500 @@ -50,7 +50,7 @@ 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