# HG changeset patch # User Nicolas Dumazet # Date 2009-12-13 15:32:29 # Node ID 27457d31ae3f3b466edb784fe0ea0a14a917f812 # Parent 9ed13f718e535ab4199e8cad02905f164e975674 cmdutil: replace sys.maxint with None as default value in loglimit Semantically, it is better to use None over any other value when there is "no value". Using maxint in this context is quite hackish, and is not forward compatible. diff --git a/hgext/graphlog.py b/hgext/graphlog.py --- a/hgext/graphlog.py +++ b/hgext/graphlog.py @@ -250,7 +250,8 @@ def graphlog(ui, repo, path=None, **opts if path: # could be reset in canonpath revdag = graphmod.filerevs(repo, path, start, stop, limit) else: - stop = max(stop, start - limit + 1) + if limit is not None: + stop = max(stop, start - limit + 1) revdag = graphmod.revisions(repo, start, stop) displayer = show_changeset(ui, repo, opts, buffered=True) @@ -260,7 +261,7 @@ def graphlog(ui, repo, path=None, **opts def graphrevs(repo, nodes, opts): limit = cmdutil.loglimit(opts) nodes.reverse() - if limit < sys.maxint: + if limit is not None: nodes = nodes[:limit] return graphmod.nodes(repo, nodes) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -95,7 +95,7 @@ def loglimit(opts): raise util.Abort(_('limit must be a positive integer')) if limit <= 0: raise util.Abort(_('limit must be positive')) else: - limit = sys.maxint + limit = None return limit def remoteui(src, opts): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1924,7 +1924,7 @@ def incoming(ui, repo, source="default", displayer = cmdutil.show_changeset(ui, other, opts) count = 0 for n in o: - if count >= limit: + if limit is not None and count >= limit: break parents = [p for p in other.changelog.parents(n) if p != nullid] if opts.get('no_merges') and len(parents) == 2: @@ -2179,7 +2179,7 @@ def outgoing(ui, repo, dest=None, **opts displayer = cmdutil.show_changeset(ui, repo, opts) count = 0 for n in o: - if count >= limit: + if limit is not None and count >= limit: break parents = [p for p in repo.changelog.parents(n) if p != nullid] if opts.get('no_merges') and len(parents) == 2: diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py --- a/mercurial/graphmod.py +++ b/mercurial/graphmod.py @@ -17,7 +17,6 @@ context of the graph returned. Type is a Data depends on type. """ -import sys from mercurial.node import nullrev CHANGESET = 'C' @@ -37,7 +36,7 @@ def revisions(repo, start, stop): yield (cur, CHANGESET, ctx, sorted(parents)) cur -= 1 -def filerevs(repo, path, start, stop, limit=sys.maxint): +def filerevs(repo, path, start, stop, limit=None): """file cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples This generator function walks through the revision history of a single