##// END OF EJS Templates
patch.pathtransform: add doctests...
Siddharth Agarwal -
r24243:daee2039 default
parent child Browse files
Show More
@@ -1088,6 +1088,22 b' def parsefilename(str):'
1088 return s[:i]
1088 return s[:i]
1089
1089
1090 def pathtransform(path, strip):
1090 def pathtransform(path, strip):
1091 '''turn a path from a patch into a path suitable for the repository
1092
1093 Returns (stripped components, path in repository).
1094
1095 >>> pathtransform('a/b/c', 0)
1096 ('', 'a/b/c')
1097 >>> pathtransform(' a/b/c ', 0)
1098 ('', ' a/b/c')
1099 >>> pathtransform(' a/b/c ', 2)
1100 ('a/b/', 'c')
1101 >>> pathtransform(' a//b/c ', 2)
1102 ('a//b/', 'c')
1103 >>> pathtransform('a/b/c', 3)
1104 Traceback (most recent call last):
1105 PatchError: unable to strip away 1 of 3 dirs from a/b/c
1106 '''
1091 pathlen = len(path)
1107 pathlen = len(path)
1092 i = 0
1108 i = 0
1093 if strip == 0:
1109 if strip == 0:
@@ -19,6 +19,7 b" testmod('mercurial.hg')"
19 testmod('mercurial.hgweb.hgwebdir_mod')
19 testmod('mercurial.hgweb.hgwebdir_mod')
20 testmod('mercurial.match')
20 testmod('mercurial.match')
21 testmod('mercurial.minirst')
21 testmod('mercurial.minirst')
22 testmod('mercurial.patch')
22 testmod('mercurial.pathutil')
23 testmod('mercurial.pathutil')
23 testmod('mercurial.revset')
24 testmod('mercurial.revset')
24 testmod('mercurial.store')
25 testmod('mercurial.store')
General Comments 0
You need to be logged in to leave comments. Login now