Use explicit integer division
Found by running the test suite with the -3 flag to show places where
we have int / int division that can be replaced with int // int.
--- a/hgext/convert/common.py Sun Jan 08 17:57:25 2012 +0100
+++ b/hgext/convert/common.py Sun Jan 08 18:15:54 2012 +0100
@@ -339,7 +339,7 @@
# Since ARG_MAX is for command line _and_ environment, lower our limit
# (and make happy Windows shells while doing this).
- return argmax / 2 - 1
+ return argmax // 2 - 1
def limit_arglist(self, arglist, cmd, closestdin, *args, **kwargs):
cmdlen = len(self._cmdline(cmd, closestdin, *args, **kwargs))
--- a/mercurial/dirstate.py Sun Jan 08 17:57:25 2012 +0100
+++ b/mercurial/dirstate.py Sun Jan 08 18:15:54 2012 +0100
@@ -49,7 +49,7 @@
self._rootdir = os.path.join(root, '')
self._dirty = False
self._dirtypl = False
- self._lastnormaltime = None
+ self._lastnormaltime = 0
self._ui = ui
@propertycache
@@ -251,7 +251,7 @@
"_ignore"):
if a in self.__dict__:
delattr(self, a)
- self._lastnormaltime = None
+ self._lastnormaltime = 0
self._dirty = False
def copy(self, source, dest):
@@ -415,7 +415,7 @@
delattr(self, "_dirs")
self._copymap = {}
self._pl = [nullid, nullid]
- self._lastnormaltime = None
+ self._lastnormaltime = 0
self._dirty = True
def rebuild(self, parent, files):
@@ -463,7 +463,7 @@
write(f)
st.write(cs.getvalue())
st.close()
- self._lastnormaltime = None
+ self._lastnormaltime = 0
self._dirty = self._dirtypl = False
def _dirignore(self, f):
--- a/mercurial/httpconnection.py Sun Jan 08 17:57:25 2012 +0100
+++ b/mercurial/httpconnection.py Sun Jan 08 18:15:54 2012 +0100
@@ -38,7 +38,7 @@
self.write = self._data.write
self.length = os.fstat(self._data.fileno()).st_size
self._pos = 0
- self._total = self.length / 1024 * 2
+ self._total = self.length // 1024 * 2
def read(self, *args, **kwargs):
try:
@@ -51,7 +51,7 @@
# requires authentication. Since we can't know until we try
# once whether authentication will be required, just lie to
# the user and maybe the push succeeds suddenly at 50%.
- self.ui.progress(_('sending'), self._pos / 1024,
+ self.ui.progress(_('sending'), self._pos // 1024,
unit=_('kb'), total=self._total)
return ret
--- a/mercurial/posix.py Sun Jan 08 17:57:25 2012 +0100
+++ b/mercurial/posix.py Sun Jan 08 18:15:54 2012 +0100
@@ -438,6 +438,8 @@
def cacheable(self):
return bool(self.stat.st_ino)
+ __hash__ = object.__hash__
+
def __eq__(self, other):
try:
return self.stat == other.stat
--- a/mercurial/revset.py Sun Jan 08 17:57:25 2012 +0100
+++ b/mercurial/revset.py Sun Jan 08 18:15:54 2012 +0100
@@ -1108,7 +1108,7 @@
return '(0-0)' # a minimal way to represent an empty set
if l == 1:
return argtype(t, s[0])
- m = l / 2
+ m = l // 2
return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
ret = ''