diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py --- a/contrib/synthrepo.py +++ b/contrib/synthrepo.py @@ -359,7 +359,10 @@ def synthesize(ui, repo, descpath, **opt files.iterkeys(), filectxfn, ui.username(), '%d %d' % util.makedate()) initnode = mc.commit() - hexfn = ui.debugflag and hex or short + if ui.debugflag: + hexfn = hex + else: + hexfn = short ui.status(_('added commit %s with %d files\n') % (hexfn(initnode), len(files))) @@ -475,7 +478,10 @@ def renamedirs(dirs, words): if dirpath in replacements: return replacements[dirpath] head, _ = os.path.split(dirpath) - head = head and rename(head) or '' + if head: + head = rename(head) + else: + head = '' renamed = os.path.join(head, wordgen.next()) replacements[dirpath] = renamed return renamed diff --git a/hgext/convert/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -31,7 +31,10 @@ class MissingTool(Exception): def checktool(exe, name=None, abort=True): name = name or exe if not util.findexe(exe): - exc = abort and util.Abort or MissingTool + if abort: + exc = util.Abort + else: + exc = MissingTool raise exc(_('cannot find required "%s" tool') % name) class NoRepo(Exception): diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py +++ b/hgext/convert/convcmd.py @@ -515,7 +515,11 @@ def convert(ui, src, dest=None, revmapfi sortmode = [m for m in sortmodes if opts.get(m)] if len(sortmode) > 1: raise util.Abort(_('more than one sort mode specified')) - sortmode = sortmode and sortmode[0] or defaultsort + if sortmode: + sortmode = sortmode[0] + else: + sortmode = defaultsort + if sortmode == 'sourcesort' and not srcc.hasnativeorder(): raise util.Abort(_('--sourcesort is not supported by this data source')) if sortmode == 'closesort' and not srcc.hasnativeclose(): diff --git a/hgext/convert/gnuarch.py b/hgext/convert/gnuarch.py --- a/hgext/convert/gnuarch.py +++ b/hgext/convert/gnuarch.py @@ -209,7 +209,10 @@ class gnuarch_source(converter_source, c mode = os.lstat(os.path.join(self.tmppath, name)).st_mode if stat.S_ISLNK(mode): data = os.readlink(os.path.join(self.tmppath, name)) - mode = mode and 'l' or '' + if mode: + mode = 'l' + else: + mode = '' else: data = open(os.path.join(self.tmppath, name), 'rb').read() mode = (mode & 0111) and 'x' or '' diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -87,7 +87,10 @@ class mercurial_sink(converter_sink): if not branch: branch = 'default' pbranches = [(b[0], b[1] and b[1] or 'default') for b in pbranches] - pbranch = pbranches and pbranches[0][1] or 'default' + if pbranches: + pbranch = pbranches[0][1] + else: + pbranch = 'default' branchpath = os.path.join(self.path, branch) if setbranch: diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -871,8 +871,16 @@ class svn_source(converter_source): if self.ui.configbool('convert', 'localtimezone'): date = makedatetimestamp(date[0]) - log = message and self.recode(message) or '' - author = author and self.recode(author) or '' + if message: + log = self.recode(message) + else: + log = '' + + if author: + author = self.recode(author) + else: + author = '' + try: branch = self.module.split("/")[-1] if branch == self.trunkname: @@ -1118,7 +1126,10 @@ class svn_sink(converter_sink, commandli self.opener = scmutil.opener(self.wc) self.wopener = scmutil.opener(self.wc) self.childmap = mapfile(ui, self.join('hg-childmap')) - self.is_exec = util.checkexec(self.wc) and util.isexec or None + if util.checkexec(self.wc): + self.is_exec = util.isexec + else: + self.is_exec = None if created: hook = os.path.join(created, 'hooks', 'pre-revprop-change') diff --git a/hgext/hgcia.py b/hgext/hgcia.py --- a/hgext/hgcia.py +++ b/hgext/hgcia.py @@ -121,7 +121,10 @@ class ciamsg(object): return patch.diffstat(pbuf.lines) or '' def logmsg(self): - diffstat = self.cia.diffstat and self.diffstat() or '' + if self.cia.diffstat: + diffstat = self.diffstat() + else: + diffstat = '' self.cia.ui.pushbuffer() self.cia.templater.show(self.ctx, changes=self.ctx.changeset(), baseurl=self.cia.ui.config('web', 'baseurl'), @@ -199,7 +202,10 @@ class hgcia(object): style = self.ui.config('cia', 'style') template = self.ui.config('cia', 'template') if not template: - template = self.diffstat and self.dstemplate or self.deftemplate + if self.diffstat: + template = self.dstemplate + else: + template = self.deftemplate template = templater.parsestring(template, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, template, style, False) diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -506,7 +506,10 @@ def files(ui, repo, *pats, **opts): kwt = kwtools['templater'] wctx = repo[None] status = _status(ui, repo, wctx, kwt, *pats, **opts) - cwd = pats and repo.getcwd() or '' + if pats: + cwd = repo.getcwd() + else: + cwd = '' files = [] if not opts.get('unknown') or opts.get('all'): files = sorted(status.modified + status.added + status.clean) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -418,7 +418,10 @@ class queue(object): gitmode = ui.configbool('mq', 'git', None) if gitmode is None: raise error.ConfigError - self.gitmode = gitmode and 'yes' or 'no' + if gitmode: + self.gitmode = 'yes' + else: + self.gitmode = 'no' except error.ConfigError: self.gitmode = ui.config('mq', 'git', 'auto').lower() self.plainmode = ui.configbool('mq', 'plain', False) @@ -610,7 +613,11 @@ class queue(object): return True, '' def explainpushable(self, idx, all_patches=False): - write = all_patches and self.ui.write or self.ui.warn + if all_patches: + write = self.ui.write + else: + write = self.ui.warn + if all_patches or self.ui.verbose: if isinstance(idx, str): idx = self.series.index(idx) @@ -1825,7 +1832,11 @@ class queue(object): self.ui.write(pfx) if summary: ph = patchheader(self.join(patchname), self.plainmode) - msg = ph.message and ph.message[0] or '' + if ph.message: + msg = ph.message[0] + else: + msg = '' + if self.ui.formatted(): width = self.ui.termwidth() - len(pfx) - len(patchname) - 2 if width > 0: @@ -2228,7 +2239,10 @@ def unapplied(ui, repo, patch=None, **op ui.write(_("all patches applied\n")) return 1 - length = opts.get('first') and 1 or None + if opts.get('first'): + length = 1 + else: + length = None q.qseries(repo, start=start, length=length, status='U', summary=opts.get('summary')) @@ -2454,7 +2468,11 @@ def top(ui, repo, **opts): Returns 0 on success.""" q = repo.mq - t = q.applied and q.seriesend(True) or 0 + if q.applied: + t = q.seriesend(True) + else: + t = 0 + if t: q.qseries(repo, start=t - 1, length=1, status='A', summary=opts.get('summary')) diff --git a/hgext/notify.py b/hgext/notify.py --- a/hgext/notify.py +++ b/hgext/notify.py @@ -340,7 +340,10 @@ class notifier(object): maxdiff = int(self.ui.config('notify', 'maxdiff', 300)) prev = ctx.p1().node() - ref = ref and ref.node() or ctx.node() + if ref: + ref = ref.node() + else: + ref = ctx.node() chunks = patch.diff(self.repo, prev, ref, opts=patch.diffallopts(self.ui)) difflines = ''.join(chunks).splitlines() diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -489,7 +489,10 @@ def patchbomb(ui, repo, *revs, **opts): if outgoing or bundle: if len(revs) > 1: raise util.Abort(_("too many destinations")) - dest = revs and revs[0] or None + if revs: + dest = revs[0] + else: + dest = None revs = [] if rev: diff --git a/i18n/polib.py b/i18n/polib.py --- a/i18n/polib.py +++ b/i18n/polib.py @@ -437,8 +437,15 @@ class _BaseFile(list): # the keys are sorted in the .mo file def cmp(_self, other): # msgfmt compares entries with msgctxt if it exists - self_msgid = _self.msgctxt and _self.msgctxt or _self.msgid - other_msgid = other.msgctxt and other.msgctxt or other.msgid + if _self.msgctxt: + self_msgid = _self.msgctxt + else: + self_msgid = _self.msgid + + if other.msgctxt: + other_msgid = other.msgctxt + else: + other_msgid = other.msgid if self_msgid > other_msgid: return 1 elif self_msgid < other_msgid: diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -435,7 +435,10 @@ def diff(ui, dst, src): diff = sorted(set(smarks) - set(dmarks)) for k in diff: - mark = ui.debugflag and smarks[k] or smarks[k][:12] + if ui.debugflag: + mark = smarks[k] + else: + mark = smarks[k][:12] ui.write(" %-25s %s\n" % (k, mark)) if len(diff) <= 0: diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -426,7 +426,10 @@ def getremotechanges(ui, repo, other, on rheads = None else: cg = other.changegroupsubset(incoming, rheads, 'incoming') - bundletype = localrepo and "HG10BZ" or "HG10UN" + if localrepo: + bundletype = "HG10BZ" + else: + bundletype = "HG10UN" fname = bundle = changegroup.writebundle(ui, cg, bundlename, bundletype) # keep written bundle? if bundlename: diff --git a/mercurial/byterange.py b/mercurial/byterange.py --- a/mercurial/byterange.py +++ b/mercurial/byterange.py @@ -274,7 +274,11 @@ class FTPRangeHandler(urllib2.FTPHandler dirs = dirs[1:] try: fw = self.connect_ftp(user, passwd, host, port, dirs) - type = file and 'I' or 'D' + if file: + type = 'I' + else: + type = 'D' + for attr in attrs: attr, value = splitattr(attr) if attr.lower() == 'type' and \ diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -398,7 +398,10 @@ def makefileobj(repo, pat, node=None, de writable = mode not in ('r', 'rb') if not pat or pat == '-': - fp = writable and repo.ui.fout or repo.ui.fin + if writable: + fp = repo.ui.fout + else: + fp = repo.ui.fin if util.safehasattr(fp, 'fileno'): return os.fdopen(os.dup(fp.fileno()), mode) else: @@ -474,7 +477,10 @@ def copy(ui, repo, pats, opts, rename=Fa def walkpat(pat): srcs = [] - badstates = after and '?' or '?r' + if after: + badstates = '?' + else: + badstates = '?r' m = scmutil.match(repo[None], [pat], opts, globbed=True) for abs in repo.walk(m): state = repo.dirstate[abs] @@ -693,7 +699,10 @@ def service(opts, parentfn=None, initfn= def writepid(pid): if opts['pid_file']: - mode = appendpid and 'a' or 'w' + if appendpid: + mode = 'a' + else: + mode = 'w' fp = open(opts['pid_file'], mode) fp.write(str(pid) + '\n') fp.close() @@ -929,7 +938,11 @@ def export(repo, revs, template='hg-%h.p branch = ctx.branch() if switch_parent: parents.reverse() - prev = (parents and parents[0]) or nullid + + if parents: + prev = parents[0] + else: + prev = nullid shouldclose = False if not fp and len(template) > 0: @@ -1067,7 +1080,10 @@ class changeset_printer(object): log = self.repo.changelog date = util.datestr(ctx.date()) - hexfunc = self.ui.debugflag and hex or short + if self.ui.debugflag: + hexfunc = hex + else: + hexfunc = short parents = [(p, hexfunc(log.node(p))) for p in self._meaningful_parentrevs(log, rev)] @@ -1866,7 +1882,10 @@ def _makelogrevset(repo, pats, opts, rev opts = dict(opts) # follow or not follow? follow = opts.get('follow') or opts.get('follow_first') - followfirst = opts.get('follow_first') and 1 or 0 + if opts.get('follow_first'): + followfirst = 1 + else: + followfirst = 0 # --follow with FILE behaviour depends on revs... it = iter(revs) startrev = it.next() diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -277,7 +277,10 @@ def annotate(ui, repo, *pats, **opts): opts['file'] = True fm = ui.formatter('annotate', opts) - datefunc = ui.quiet and util.shortdate or util.datestr + if ui.quiet: + datefunc = util.shortdate + else: + datefunc = util.datestr hexfn = fm.hexfunc opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser), @@ -664,7 +667,10 @@ def bisect(ui, repo, rev=None, extra=Non # one of the parent was not checked. parents = repo[nodes[0]].parents() if len(parents) > 1: - side = good and state['bad'] or state['good'] + if good: + side = state['bad'] + else: + side = state['good'] num = len(set(i.node() for i in parents) & set(side)) if num == 1: return parents[0].ancestor(parents[1]) @@ -3670,7 +3676,10 @@ def grep(ui, repo, pattern, *pats, **opt def display(fn, ctx, pstates, states): rev = ctx.rev() - datefunc = ui.quiet and util.shortdate or util.datestr + if ui.quiet: + datefunc = util.shortdate + else: + datefunc = util.datestr found = False @util.cachefunc def binary(): @@ -3946,7 +3955,10 @@ def identify(ui, repo, source=None, rev= raise util.Abort(_("there is no Mercurial repository here " "(.hg not found)")) - hexfunc = ui.debugflag and hex or short + if ui.debugflag: + hexfunc = hex + else: + hexfunc = short default = not (num or id or branch or tags or bookmarks) output = [] revs = [] @@ -4342,7 +4354,10 @@ def locate(ui, repo, *pats, **opts): Returns 0 if a match is found, 1 otherwise. """ - end = opts.get('print0') and '\0' or '\n' + if opts.get('print0'): + end = '\0' + else: + end = '\n' rev = scmutil.revsingle(repo, opts.get('rev'), None).node() ret = 1 @@ -4506,7 +4521,10 @@ def log(ui, repo, *pats, **opts): rename = getrenamed(fn, rev) if rename: copies.append((fn, rename[0])) - revmatchfn = filematcher and filematcher(ctx.rev()) or None + if filematcher: + revmatchfn = filematcher(ctx.rev()) + else: + revmatchfn = None displayer.show(ctx, copies=copies, matchfn=revmatchfn) if displayer.flush(rev): count += 1 @@ -5550,7 +5568,10 @@ def serve(ui, repo, **opts): if opts.get('port'): opts['port'] = util.getport(opts.get('port')) - baseui = repo and repo.baseui or ui + if repo: + baseui = repo.baseui + else: + baseui = ui optlist = ("name templates style address port prefix ipv6" " accesslog errorlog certificate encoding") for o in optlist.split(): @@ -5700,15 +5721,25 @@ def status(ui, repo, *pats, **opts): else: node1, node2 = scmutil.revpair(repo, revs) - cwd = (pats and repo.getcwd()) or '' - end = opts.get('print0') and '\0' or '\n' + if pats: + cwd = repo.getcwd() + else: + cwd = '' + + if opts.get('print0'): + end = '\0' + else: + end = '\n' copy = {} states = 'modified added removed deleted unknown ignored clean'.split() show = [k for k in states if opts.get(k)] if opts.get('all'): show += ui.quiet and (states[:4] + ['clean']) or states if not show: - show = ui.quiet and states[:4] or states[:5] + if ui.quiet: + show = states[:4] + else: + show = states[:5] stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), 'ignored' in show, 'clean' in show, 'unknown' in show, @@ -6029,7 +6060,11 @@ def tag(ui, repo, name1, *names, **opts) rev_ = opts['rev'] message = opts.get('message') if opts.get('remove'): - expectedtype = opts.get('local') and 'local' or 'global' + if opts.get('local'): + expectedtype = 'local' + else: + expectedtype = 'global' + for n in names: if not repo.tagtype(n): raise util.Abort(_("tag '%s' does not exist") % n) diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -963,7 +963,11 @@ class basefilectx(object): def ancestors(self, followfirst=False): visit = {} c = self - cut = followfirst and 1 or None + if followfirst: + cut = 1 + else: + cut = None + while True: for parent in c.parents()[:cut]: visit[(parent.linkrev(), parent.filenode())] = parent @@ -1755,7 +1759,11 @@ class memctx(committablectx): # "filectxfn" for performance (e.g. converting from another VCS) self._filectxfn = util.cachefunc(filectxfn) - self._extra = extra and extra.copy() or {} + if extra: + self._extra = extra.copy() + else: + self._extra = {} + if self._extra.get('branch', '') == '': self._extra['branch'] = 'default' diff --git a/mercurial/dagutil.py b/mercurial/dagutil.py --- a/mercurial/dagutil.py +++ b/mercurial/dagutil.py @@ -88,7 +88,10 @@ class genericdag(basedag): '''generic implementations for DAGs''' def ancestorset(self, starts, stops=None): - stops = stops and set(stops) or set() + if stops: + stops = set(stops) + else: + stops = set() seen = set() pending = list(starts) while pending: @@ -179,7 +182,10 @@ class revlogdag(revlogbaseddag): def ancestorset(self, starts, stops=None): rlog = self._revlog idx = rlog.index - stops = stops and set(stops) or set() + if stops: + stops = set(stops) + else: + stops = set() seen = set() pending = list(starts) while pending: diff --git a/mercurial/discovery.py b/mercurial/discovery.py --- a/mercurial/discovery.py +++ b/mercurial/discovery.py @@ -218,7 +218,10 @@ def _oldheadssummary(repo, remoteheads, r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing) newheads = list(c.node() for c in r) # set some unsynced head to issue the "unsynced changes" warning - unsynced = inc and set([None]) or set() + if inc: + unsynced = set([None]) + else: + unsynced = set() return {None: (oldheads, newheads, unsynced)} def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False, diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -34,7 +34,11 @@ def addbranchrevs(lrepo, other, branches else: y = None return x, y - revs = revs and list(revs) or [] + if revs: + revs = list(revs) + else: + revs = [] + if not peer.capable('branchmap'): if branches: raise util.Abort(_("remote branch lookup not supported")) diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -90,7 +90,10 @@ def rawfile(web, req, tmpl): if guessmime: mt = mimetypes.guess_type(path)[0] if mt is None: - mt = util.binary(text) and 'application/binary' or 'text/plain' + if util.binary(text): + mt = 'application/binary' + else: + mt = 'text/plain' if mt.startswith('text/'): mt += '; charset="%s"' % encoding.encoding @@ -365,7 +368,11 @@ def changelog(web, req, tmpl, shortlog=F entry['parity'] = parity.next() yield entry - revcount = shortlog and web.maxshortchanges or web.maxchanges + if shortlog: + revcount = web.maxshortchanges + else: + revcount = web.maxchanges + if 'revcount' in req.form: try: revcount = int(req.form.get('revcount', [revcount])[0]) @@ -783,8 +790,12 @@ def filediff(web, req, tmpl): style = req.form['style'][0] diffs = webutil.diffs(web.repo, tmpl, ctx, None, [path], parity, style) - rename = fctx and webutil.renamelink(fctx) or [] - ctx = fctx and fctx or ctx + if fctx: + rename = webutil.renamelink(fctx) + ctx = fctx + else: + rename = [] + ctx = ctx return tmpl("filediff", file=path, node=hex(n), diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -373,7 +373,10 @@ def diffs(repo, tmpl, ctx, basectx, file diffopts = patch.diffopts(repo.ui, untrusted=True) if basectx is None: parents = ctx.parents() - node1 = parents and parents[0].node() or nullid + if parents: + node1 = parents[0].node() + else: + node1 = nullid else: node1 = basectx.node() node2 = ctx.node() diff --git a/mercurial/httpclient/__init__.py b/mercurial/httpclient/__init__.py --- a/mercurial/httpclient/__init__.py +++ b/mercurial/httpclient/__init__.py @@ -330,7 +330,10 @@ class HTTPConnection(object): elif use_ssl is None: use_ssl = (port == 443) elif port is None: - port = (use_ssl and 443 or 80) + if use_ssl: + port = 443 + else: + port = 80 self.port = port if use_ssl and not socketutil.have_ssl: raise Exception('ssl requested but unavailable on this Python') diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -523,7 +523,11 @@ class localrepository(object): if prevtags and prevtags[-1] != '\n': fp.write('\n') for name in names: - m = munge and munge(name) or name + if munge: + m = munge(name) + else: + m = name + if (self._tagscache.tagtypes and name in self._tagscache.tagtypes): old = self.tags().get(name, nullid) @@ -893,7 +897,11 @@ class localrepository(object): def currenttransaction(self): """return the current transaction or None if non exists""" - tr = self._transref and self._transref() or None + if self._transref: + tr = self._transref() + else: + tr = None + if tr and tr.running(): return tr return None @@ -913,7 +921,10 @@ class localrepository(object): self._writejournal(desc) renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] - rp = report and report or self.ui.warn + if report: + rp = report + else: + rp = self.ui.warn vfsmap = {'plain': self.vfs} # root of .hg/ # we must avoid cyclic reference between repo and transaction. reporef = weakref.ref(self) diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -259,8 +259,17 @@ def extract(ui, fileobj): if not diffs_seen: os.unlink(tmpname) return None, message, user, date, branch, None, None, None - p1 = parents and parents.pop(0) or None - p2 = parents and parents.pop(0) or None + + if parents: + p1 = parents.pop(0) + else: + p1 = None + + if parents: + p2 = parents.pop(0) + else: + p2 = None + return tmpname, message, user, date, branch, nodeid, p1, p2 class patchmeta(object): @@ -1489,13 +1498,19 @@ def makepatchmeta(backend, afile_orig, b fname = None if not missing: if gooda and goodb: - fname = isbackup and afile or bfile + if isbackup: + fname = afile + else: + fname = bfile elif gooda: fname = afile if not fname: if not nullb: - fname = isbackup and afile or bfile + if isbackup: + fname = afile + else: + fname = bfile elif not nulla: fname = afile else: @@ -2070,7 +2085,10 @@ def diff(repo, node1=None, node2=None, m if not modified and not added and not removed: return [] - hexfunc = repo.ui.debugflag and hex or short + if repo.ui.debugflag: + hexfunc = hex + else: + hexfunc = short revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node] copy = {} diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -18,7 +18,10 @@ import repoview def _revancestors(repo, revs, followfirst): """Like revlog.ancestors(), but supports followfirst.""" - cut = followfirst and 1 or None + if followfirst: + cut = 1 + else: + cut = None cl = repo.changelog def iterate(): @@ -49,7 +52,10 @@ def _revancestors(repo, revs, followfirs def _revdescendants(repo, revs, followfirst): """Like revlog.descendants() but supports followfirst.""" - cut = followfirst and 1 or None + if followfirst: + cut = 1 + else: + cut = None def iterate(): cl = repo.changelog diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -656,7 +656,10 @@ class templater(object): self.mapfile = mapfile or 'template' self.cache = cache.copy() self.map = {} - self.base = (mapfile and os.path.dirname(mapfile)) or '' + if mapfile: + self.base = os.path.dirname(mapfile) + else: + self.base = '' self.filters = templatefilters.filters.copy() self.filters.update(filters) self.defaults = defaults diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1836,7 +1836,10 @@ class TestRunner(object): compiler = '' if self.options.compiler: compiler = '--compiler ' + self.options.compiler - pure = self.options.pure and "--pure" or "" + if self.options.pure: + pure = "--pure" + else: + pure = "" py3 = '' if sys.version_info[0] == 3: py3 = '--c2to3'