Patchwork [1,of,6] patch: rename pathstrip to pathtransform

login
register
mail settings
Submitter Siddharth Agarwal
Date March 7, 2015, 8:44 a.m.
Message ID <7a5ce9323351fa75a348.1425717883@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7921/
State Accepted
Headers show

Comments

Siddharth Agarwal - March 7, 2015, 8:44 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1425705150 28800
#      Fri Mar 06 21:12:30 2015 -0800
# Node ID 7a5ce9323351fa75a3488efa31b91358d81d8f89
# Parent  02d7b5cd373bbb4e8263dad9bfbf9c4c3b0e4e3a
patch: rename pathstrip to pathtransform

In upcoming patches we'll not just strip path components but also add new ones.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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)