Patchwork [1,of,3] convert: inline strutil.rfindall()

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 14, 2016, 3:03 p.m.
Message ID <ca58647f2190444e6e26.1481727795@mimosa>
Download mbox | patch
Permalink /patch/17907/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 14, 2016, 3:03 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1476604723 -32400
#      Sun Oct 16 16:58:43 2016 +0900
# Node ID ca58647f2190444e6e26d9346021ae7b7eff33da
# Parent  86ea43fbbc8f64a4ca5cf74fa5ae92a2036aca10
convert: inline strutil.rfindall()

This is the only place where strutil is used. I don't think it's worth to
keep the strutil module, so inline it.

Also, strutil.rfindall() appears to have off-by-one error. 'end = c - 1' is
wrong because 'end' is exclusive.

Patch

diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -14,7 +14,6 @@  from mercurial import (
     error,
     pycompat,
     scmutil,
-    strutil,
     util,
 )
 
@@ -1239,7 +1238,8 @@  class svn_sink(converter_sink, commandli
         for f in files:
             if os.path.isdir(self.wjoin(f)):
                 dirs.add(f)
-            for i in strutil.rfindall(f, '/'):
+            i = len(f)
+            for i in iter(lambda: f.rfind('/', 0, i), -1):
                 dirs.add(f[:i])
         return dirs