Patchwork D8324: py3: use integer division in histedit

login
register
mail settings
Submitter phabricator
Date March 25, 2020, 6:42 a.m.
Message ID <differential-rev-PHID-DREV-mvaimf4jbjp3v7tua6lv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45876/
State Superseded
Headers show

Comments

phabricator - March 25, 2020, 6:42 a.m.
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Histedit uses the `/` operator, which does type conversion to float in
  Python 3 instead of integer division likeon Python 2. Let's preserve
  the Python 2 behavior by importing and using the `//` operator.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8324

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -190,7 +190,7 @@ 
 
 """
 
-from __future__ import absolute_import
+from __future__ import absolute_import, division
 
 # chistedit dependencies that are not available everywhere
 try:
@@ -1267,7 +1267,7 @@ 
     num_lines = len(mode_state[b'patchcontents'])
     page_height = state[b'page_height']
     unit = page_height if unit == b'page' else 1
-    num_pages = 1 + (num_lines - 1) / page_height
+    num_pages = 1 + (num_lines - 1) // page_height
     max_offset = (num_pages - 1) * page_height
     newline = mode_state[b'line_offset'] + delta * unit
     mode_state[b'line_offset'] = max(0, min(max_offset, newline))