Skip to content
Snippets Groups Projects
Commit daee2039 authored by Siddharth Agarwal's avatar Siddharth Agarwal
Browse files

patch.pathtransform: add doctests

In upcoming patches we're going to make this function more complex, so add some
unit tests for it.
parent 3acb83c6
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -19,6 +19,7 @@
testmod('mercurial.hgweb.hgwebdir_mod')
testmod('mercurial.match')
testmod('mercurial.minirst')
testmod('mercurial.patch')
testmod('mercurial.pathutil')
testmod('mercurial.revset')
testmod('mercurial.store')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment