1010# --------------------------------------------------------------------------- #
1111# User-facing API
1212# --------------------------------------------------------------------------- #
13- def text_to_patch (text : str , orig : Dict [str , str ]) -> Tuple [Patch , int ]:
13+ def text_to_patch (text : str , orig : Dict [str , str ], rootpath : Optional [ pathlib . Path ] = None ) -> Tuple [Patch , int ]:
1414 """Improved version with better splitlines handling."""
1515 lines = text .splitlines ()
1616
@@ -37,7 +37,7 @@ def text_to_patch(text: str, orig: Dict[str, str]) -> Tuple[Patch, int]:
3737 if not lines or not Parser ._norm (lines [- 1 ]) == "*** End Patch" :
3838 raise DiffError (f"Invalid patch text - must end with '*** End Patch'. Found: '{ lines [- 1 ] if lines else 'empty' } '" )
3939
40- parser = Parser (current_files = orig , lines = lines , index = 1 )
40+ parser = Parser (current_files = orig , lines = lines , index = 1 , rootpath = rootpath )
4141 parser .parse ()
4242 return parser .patch , parser .fuzz
4343
@@ -138,7 +138,7 @@ def process_patch(
138138 path = str (root_path / path )
139139 orig_files [path ] = open_fn (path )
140140
141- patch , _fuzz = text_to_patch (text , orig_files )
141+ patch , _fuzz = text_to_patch (text , orig_files , rootpath = root_path )
142142 commit = patch_to_commit (patch , orig_files )
143143
144144 apply_commit (commit , write_fn , remove_fn , exists_fn )
0 commit comments