diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -163,6 +163,8 @@ pypats = [
     (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
     (r' [=!]=\s+(True|False|None)',
      "comparison with singleton, use 'is' or 'is not' instead"),
+    (r'^\s*(while|if) [01]:',
+     "use True/False for constant Boolean expression"),
     (r'opener\([^)]*\).read\(',
      "use opener.read() instead"),
     (r'opener\([^)]*\).write\(',
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -8,7 +8,7 @@ def timer(func, title=None):
     results = []
     begin = time.time()
     count = 0
-    while 1:
+    while True:
         ostart = os.times()
         cstart = time.time()
         r = func()
diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py
--- a/hgext/convert/cvs.py
+++ b/hgext/convert/cvs.py
@@ -227,7 +227,7 @@ class convert_cvs(converter_source):
 
         data = ""
         mode = None
-        while 1:
+        while True:
             line = self.readp.readline()
             if line.startswith("Created ") or line.startswith("Updated "):
                 self.readp.readline() # path
diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py
+++ b/hgext/zeroconf/Zeroconf.py
@@ -591,7 +591,7 @@ class DNSIncoming(object):
 		next = -1
 		first = off
 
-		while 1:
+		while True:
 			len = ord(self.data[off])
 			off += 1
 			if len == 0:
@@ -939,7 +939,7 @@ class Reaper(threading.Thread):
 		self.start()
 
 	def run(self):
-		while 1:
+		while True:
 			self.zeroconf.wait(10 * 1000)
 			if globals()['_GLOBAL_DONE']:
 				return
@@ -1003,7 +1003,7 @@ class ServiceBrowser(threading.Thread):
 		self.zeroconf.notifyAll()
 
 	def run(self):
-		while 1:
+		while True:
 			event = None
 			now = currentTimeMillis()
 			if len(self.list) == 0 and self.nextTime > now:
diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py
--- a/mercurial/ancestor.py
+++ b/mercurial/ancestor.py
@@ -76,7 +76,7 @@ def ancestor(a, b, pfunc):
     # increment each ancestor list until it is closer to root than
     # the other, or they match
     try:
-        while 1:
+        while True:
             if gx[0] == gy[0]:
                 for v in gx[1]:
                     if v in gy[1]:
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -33,7 +33,7 @@ class bundlerevlog(revlog.revlog):
         self.basemap = {}
         n = len(self)
         chain = None
-        while 1:
+        while True:
             chunkdata = bundle.deltachunk(chain)
             if not chunkdata:
                 break
@@ -185,7 +185,7 @@ class bundlerepository(localrepo.localre
 
             try:
                 fptemp.write("HG10UN")
-                while 1:
+                while True:
                     chunk = self.bundle.read(2**18)
                     if not chunk:
                         break
@@ -232,13 +232,13 @@ class bundlerepository(localrepo.localre
     def file(self, f):
         if not self.bundlefilespos:
             self.bundle.seek(self.filestart)
-            while 1:
+            while True:
                 chunkdata = self.bundle.filelogheader()
                 if not chunkdata:
                     break
                 fname = chunkdata['filename']
                 self.bundlefilespos[fname] = self.bundle.tell()
-                while 1:
+                while True:
                     c = self.bundle.deltachunk(None)
                     if not c:
                         break
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -91,7 +91,7 @@ def writebundle(cg, filename, bundletype
         while not empty or count <= 2:
             empty = True
             count += 1
-            while 1:
+            while True:
                 chunk = getchunk(cg)
                 if not chunk:
                     break
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1342,7 +1342,7 @@ def debugbundle(ui, bundlepath, all=None
             def showchunks(named):
                 ui.write("\n%s\n" % named)
                 chain = None
-                while 1:
+                while True:
                     chunkdata = gen.deltachunk(chain)
                     if not chunkdata:
                         break
@@ -1361,7 +1361,7 @@ def debugbundle(ui, bundlepath, all=None
             showchunks("changelog")
             chunkdata = gen.manifestheader()
             showchunks("manifest")
-            while 1:
+            while True:
                 chunkdata = gen.filelogheader()
                 if not chunkdata:
                     break
@@ -1370,7 +1370,7 @@ def debugbundle(ui, bundlepath, all=None
         else:
             chunkdata = gen.changelogheader()
             chain = None
-            while 1:
+            while True:
                 chunkdata = gen.deltachunk(chain)
                 if not chunkdata:
                     break
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -134,7 +134,7 @@ def copies(repo, c1, c2, ca, checkdirs=F
             if f2r is None:
                 f2 = g2.next()
 
-            while 1:
+            while True:
                 f1r, f2r = f1.rev(), f2.rev()
                 if f1r > f2r:
                     f1 = g1.next()
diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py
+++ b/mercurial/hgweb/protocol.py
@@ -33,7 +33,7 @@ class webproto(object):
         args = self.req.form.copy()
         chunks = []
         i = 1
-        while 1:
+        while True:
             h = self.req.env.get('HTTP_X_HGARG_' + str(i))
             if h is None:
                 break
@@ -50,7 +50,7 @@ class webproto(object):
         sys.stderr = sys.stdout = cStringIO.StringIO()
     def groupchunks(self, cg):
         z = zlib.compressobj()
-        while 1:
+        while True:
             chunk = cg.read(4096)
             if not chunk:
                 break
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -507,7 +507,7 @@ class HTTPResponse(httplib.HTTPResponse)
     def readlines(self, sizehint = 0):
         total = 0
         list = []
-        while 1:
+        while True:
             line = self.readline()
             if not line:
                 break
@@ -654,7 +654,7 @@ def continuity(url):
 
     fo = urllib2.urlopen(url)
     foo = ''
-    while 1:
+    while True:
         f = fo.readline()
         if f:
             foo = foo + f
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1309,7 +1309,7 @@ class localrepository(repo.repository):
         b = []
         for n in nodes:
             t = n
-            while 1:
+            while True:
                 p = self.changelog.parents(n)
                 if p[1] != nullid or p[0] == nullid:
                     b.append((t, n, p[0], p[1]))
@@ -1777,7 +1777,7 @@ class localrepository(repo.repository):
             pr.total = efiles
             source.callback = None
 
-            while 1:
+            while True:
                 chunkdata = source.filelogheader()
                 if not chunkdata:
                     break
diff --git a/mercurial/lock.py b/mercurial/lock.py
--- a/mercurial/lock.py
+++ b/mercurial/lock.py
@@ -51,7 +51,7 @@ class lock(object):
 
     def lock(self):
         timeout = self.timeout
-        while 1:
+        while True:
             try:
                 self.trylock()
                 return 1
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -346,7 +346,7 @@ class linereader(object):
         return self.fp.readline()
 
     def __iter__(self):
-        while 1:
+        while True:
             l = self.readline()
             if not l:
                 break
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1151,7 +1151,7 @@ class revlog(object):
         try:
             # loop through our set of deltas
             chain = None
-            while 1:
+            while True:
                 chunkdata = bundle.deltachunk(chain)
                 if not chunkdata:
                     break
diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py
--- a/mercurial/sshrepo.py
+++ b/mercurial/sshrepo.py
@@ -88,7 +88,7 @@ class sshrepository(wireproto.wirereposi
                 break
 
     def readerr(self):
-        while 1:
+        while True:
             size = util.fstat(self.pipee).st_size
             if size == 0:
                 break
@@ -148,7 +148,7 @@ class sshrepository(wireproto.wirereposi
         r = self._call(cmd, **args)
         if r:
             return '', r
-        while 1:
+        while True:
             d = fp.read(4096)
             if not d:
                 break
@@ -193,7 +193,7 @@ class sshrepository(wireproto.wirereposi
         d = self._call("addchangegroup")
         if d:
             self._abort(error.RepoError(_("push refused: %s") % d))
-        while 1:
+        while True:
             d = cg.read(4096)
             if not d:
                 break
diff --git a/tests/md5sum.py b/tests/md5sum.py
--- a/tests/md5sum.py
+++ b/tests/md5sum.py
@@ -29,7 +29,7 @@ for filename in sys.argv[1:]:
 
     m = md5()
     try:
-        while 1:
+        while True:
             data = fp.read(8192)
             if not data:
                 break
diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -95,7 +95,7 @@ class ProxyHandler (BaseHTTPServer.BaseH
         iw = [self.connection, soc]
         ow = []
         count = 0
-        while 1:
+        while True:
             count += 1
             (ins, _, exs) = select.select(iw, ow, iw, 3)
             if exs: