cmdutil: replace sys.maxint with None as default value in loglimit
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Mon, 14 Dec 2009 00:32:29 +0900
changeset 10111 27457d31ae3f
parent 10110 9ed13f718e53
child 10113 f76984a27b3d
child 10164 4e8a6959e846
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.
hgext/graphlog.py
mercurial/cmdutil.py
mercurial/commands.py
mercurial/graphmod.py
--- a/hgext/graphlog.py	Mon Dec 21 12:18:43 2009 +0200
+++ b/hgext/graphlog.py	Mon Dec 14 00:32:29 2009 +0900
@@ -250,7 +250,8 @@
     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 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)
 
--- a/mercurial/cmdutil.py	Mon Dec 21 12:18:43 2009 +0200
+++ b/mercurial/cmdutil.py	Mon Dec 14 00:32:29 2009 +0900
@@ -95,7 +95,7 @@
             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):
--- a/mercurial/commands.py	Mon Dec 21 12:18:43 2009 +0200
+++ b/mercurial/commands.py	Mon Dec 14 00:32:29 2009 +0900
@@ -1924,7 +1924,7 @@
         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 @@
     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:
--- a/mercurial/graphmod.py	Mon Dec 21 12:18:43 2009 +0200
+++ b/mercurial/graphmod.py	Mon Dec 14 00:32:29 2009 +0900
@@ -17,7 +17,6 @@
 Data depends on type.
 """
 
-import sys
 from mercurial.node import nullrev
 
 CHANGESET = 'C'
@@ -37,7 +36,7 @@
         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