mercurial/patch.py
changeset 24243 daee2039dd11
parent 24242 3acb83c6c0f1
child 24244 5918bb365c72
--- a/mercurial/patch.py	Fri Mar 06 21:12:30 2015 -0800
+++ b/mercurial/patch.py	Fri Mar 06 21:48:40 2015 -0800
@@ -1088,6 +1088,22 @@
     return s[:i]
 
 def pathtransform(path, strip):
+    '''turn a path from a patch into a path suitable for the repository
+
+    Returns (stripped components, path in repository).
+
+    >>> pathtransform('a/b/c', 0)
+    ('', 'a/b/c')
+    >>> pathtransform('   a/b/c   ', 0)
+    ('', '   a/b/c')
+    >>> pathtransform('   a/b/c   ', 2)
+    ('a/b/', 'c')
+    >>> pathtransform('   a//b/c   ', 2)
+    ('a//b/', 'c')
+    >>> pathtransform('a/b/c', 3)
+    Traceback (most recent call last):
+    PatchError: unable to strip away 1 of 3 dirs from a/b/c
+    '''
     pathlen = len(path)
     i = 0
     if strip == 0: