patch: rename pathstrip to pathtransform
authorSiddharth Agarwal <sid0@fb.com>
Fri, 06 Mar 2015 21:12:30 -0800
changeset 24242 3acb83c6c0f1
parent 24241 e7baf88c29c3
child 24243 daee2039dd11
patch: rename pathstrip to pathtransform In upcoming patches we'll not just strip path components but also add new ones.
mercurial/patch.py
--- a/mercurial/patch.py	Wed Feb 18 23:17:52 2015 +0900
+++ b/mercurial/patch.py	Fri Mar 06 21:12:30 2015 -0800
@@ -1087,7 +1087,7 @@
             return s
     return s[:i]
 
-def pathstrip(path, strip):
+def pathtransform(path, strip):
     pathlen = len(path)
     i = 0
     if strip == 0:
@@ -1110,9 +1110,9 @@
     nullb = bfile_orig == "/dev/null"
     create = nulla and hunk.starta == 0 and hunk.lena == 0
     remove = nullb and hunk.startb == 0 and hunk.lenb == 0
-    abase, afile = pathstrip(afile_orig, strip)
+    abase, afile = pathtransform(afile_orig, strip)
     gooda = not nulla and backend.exists(afile)
-    bbase, bfile = pathstrip(bfile_orig, strip)
+    bbase, bfile = pathtransform(bfile_orig, strip)
     if afile == bfile:
         goodb = gooda
     else:
@@ -1352,7 +1352,7 @@
                eolmode='strict'):
 
     def pstrip(p):
-        return pathstrip(p, strip - 1)[1]
+        return pathtransform(p, strip - 1)[1]
 
     rejects = 0
     err = 0
@@ -1541,9 +1541,9 @@
             if state == 'file':
                 afile, bfile, first_hunk, gp = values
                 if gp:
-                    gp.path = pathstrip(gp.path, strip - 1)[1]
+                    gp.path = pathtransform(gp.path, strip - 1)[1]
                     if gp.oldpath:
-                        gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1]
+                        gp.oldpath = pathtransform(gp.oldpath, strip - 1)[1]
                 else:
                     gp = makepatchmeta(backend, afile, bfile, first_hunk, strip)
                 changed.add(gp.path)