|
4 | 4 | import pathlib |
5 | 5 | import re |
6 | 6 | import urllib.parse |
| 7 | +from collections.abc import Sequence |
7 | 8 | from typing import NamedTuple, Optional |
8 | 9 |
|
9 | 10 | from dfetch.log import get_logger |
|
16 | 17 | in_directory, |
17 | 18 | safe_rm, |
18 | 19 | ) |
| 20 | +from dfetch.vcs.patch import filter_patch |
19 | 21 |
|
20 | 22 | logger = get_logger(__name__) |
21 | 23 |
|
@@ -246,7 +248,7 @@ def _fetch_impl(self, version: Version) -> Version: |
246 | 248 | SvnRepo._export(complete_path, rev_arg, self.local_path) |
247 | 249 |
|
248 | 250 | if file_pattern: |
249 | | - for file in find_non_matching_files(self.local_path, file_pattern): |
| 251 | + for file in find_non_matching_files(self.local_path, (file_pattern,)): |
250 | 252 | os.remove(file) |
251 | 253 | if not os.listdir(self.local_path): |
252 | 254 | logger.warning( |
@@ -366,13 +368,18 @@ def current_revision(self) -> str: |
366 | 368 | """Get the current revision of the repo.""" |
367 | 369 | return self._get_last_changed_revision(self.local_path) |
368 | 370 |
|
369 | | - def get_diff(self, old_revision: str, new_revision: Optional[str]) -> str: |
| 371 | + def get_diff( |
| 372 | + self, old_revision: str, new_revision: Optional[str], ignore: Sequence[str] |
| 373 | + ) -> str: |
370 | 374 | """Get the diff between two revisions.""" |
371 | | - cmd = f"svn diff {self.local_path} -r {old_revision}" |
| 375 | + cmd = ["svn", "diff", "--non-interactive", ".", "-r", old_revision] |
372 | 376 | if new_revision: |
373 | | - cmd += f":{new_revision}" |
| 377 | + cmd[-1] += f":{new_revision}" |
374 | 378 |
|
375 | | - return "\n".join(run_on_cmdline(logger, cmd).stdout.decode().splitlines()) |
| 379 | + with in_directory(self.local_path): |
| 380 | + patch_text = run_on_cmdline(logger, cmd).stdout |
| 381 | + |
| 382 | + return filter_patch(patch_text, ignore) |
376 | 383 |
|
377 | 384 | def get_default_branch(self) -> str: |
378 | 385 | """Get the default branch of this repository.""" |
|
0 commit comments