diff options
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 55 |
1 files changed, 23 insertions, 32 deletions
| @@ -390,22 +390,17 @@ def _SafeExpandPath(base, subpath, skipfinal=False): | |||
| 390 | return path | 390 | return path |
| 391 | 391 | ||
| 392 | 392 | ||
| 393 | class _CopyFile: | 393 | class _CopyFile(NamedTuple): |
| 394 | """Container for <copyfile> manifest element.""" | 394 | """Container for <copyfile> manifest element.""" |
| 395 | 395 | ||
| 396 | def __init__(self, git_worktree, src, topdir, dest): | 396 | # Absolute path to the git project checkout. |
| 397 | """Register a <copyfile> request. | 397 | git_worktree: str |
| 398 | 398 | # Relative path under |git_worktree| of file to read. | |
| 399 | Args: | 399 | src: str |
| 400 | git_worktree: Absolute path to the git project checkout. | 400 | # Absolute path to the top of the repo client checkout. |
| 401 | src: Relative path under |git_worktree| of file to read. | 401 | topdir: str |
| 402 | topdir: Absolute path to the top of the repo client checkout. | 402 | # Relative path under |topdir| of file to write. |
| 403 | dest: Relative path under |topdir| of file to write. | 403 | dest: str |
| 404 | """ | ||
| 405 | self.git_worktree = git_worktree | ||
| 406 | self.topdir = topdir | ||
| 407 | self.src = src | ||
| 408 | self.dest = dest | ||
| 409 | 404 | ||
| 410 | def _Copy(self): | 405 | def _Copy(self): |
| 411 | src = _SafeExpandPath(self.git_worktree, self.src) | 406 | src = _SafeExpandPath(self.git_worktree, self.src) |
| @@ -439,22 +434,17 @@ class _CopyFile: | |||
| 439 | logger.error("error: Cannot copy file %s to %s", src, dest) | 434 | logger.error("error: Cannot copy file %s to %s", src, dest) |
| 440 | 435 | ||
| 441 | 436 | ||
| 442 | class _LinkFile: | 437 | class _LinkFile(NamedTuple): |
| 443 | """Container for <linkfile> manifest element.""" | 438 | """Container for <linkfile> manifest element.""" |
| 444 | 439 | ||
| 445 | def __init__(self, git_worktree, src, topdir, dest): | 440 | # Absolute path to the git project checkout. |
| 446 | """Register a <linkfile> request. | 441 | git_worktree: str |
| 447 | 442 | # Target of symlink relative to path under |git_worktree|. | |
| 448 | Args: | 443 | src: str |
| 449 | git_worktree: Absolute path to the git project checkout. | 444 | # Absolute path to the top of the repo client checkout. |
| 450 | src: Target of symlink relative to path under |git_worktree|. | 445 | topdir: str |
| 451 | topdir: Absolute path to the top of the repo client checkout. | 446 | # Relative path under |topdir| of symlink to create. |
| 452 | dest: Relative path under |topdir| of symlink to create. | 447 | dest: str |
| 453 | """ | ||
| 454 | self.git_worktree = git_worktree | ||
| 455 | self.topdir = topdir | ||
| 456 | self.src = src | ||
| 457 | self.dest = dest | ||
| 458 | 448 | ||
| 459 | def __linkIt(self, relSrc, absDest): | 449 | def __linkIt(self, relSrc, absDest): |
| 460 | # Link file if it does not exist or is out of date. | 450 | # Link file if it does not exist or is out of date. |
| @@ -633,8 +623,9 @@ class Project: | |||
| 633 | self.subprojects = [] | 623 | self.subprojects = [] |
| 634 | 624 | ||
| 635 | self.snapshots = {} | 625 | self.snapshots = {} |
| 636 | self.copyfiles = [] | 626 | # Use dicts to dedupe while maintaining declared order. |
| 637 | self.linkfiles = [] | 627 | self.copyfiles = {} |
| 628 | self.linkfiles = {} | ||
| 638 | self.annotations = [] | 629 | self.annotations = [] |
| 639 | self.dest_branch = dest_branch | 630 | self.dest_branch = dest_branch |
| 640 | 631 | ||
| @@ -1794,7 +1785,7 @@ class Project: | |||
| 1794 | Paths should have basic validation run on them before being queued. | 1785 | Paths should have basic validation run on them before being queued. |
| 1795 | Further checking will be handled when the actual copy happens. | 1786 | Further checking will be handled when the actual copy happens. |
| 1796 | """ | 1787 | """ |
| 1797 | self.copyfiles.append(_CopyFile(self.worktree, src, topdir, dest)) | 1788 | self.copyfiles[_CopyFile(self.worktree, src, topdir, dest)] = True |
| 1798 | 1789 | ||
| 1799 | def AddLinkFile(self, src, dest, topdir): | 1790 | def AddLinkFile(self, src, dest, topdir): |
| 1800 | """Mark |dest| to create a symlink (relative to |topdir|) pointing to | 1791 | """Mark |dest| to create a symlink (relative to |topdir|) pointing to |
| @@ -1805,7 +1796,7 @@ class Project: | |||
| 1805 | Paths should have basic validation run on them before being queued. | 1796 | Paths should have basic validation run on them before being queued. |
| 1806 | Further checking will be handled when the actual link happens. | 1797 | Further checking will be handled when the actual link happens. |
| 1807 | """ | 1798 | """ |
| 1808 | self.linkfiles.append(_LinkFile(self.worktree, src, topdir, dest)) | 1799 | self.linkfiles[_LinkFile(self.worktree, src, topdir, dest)] = True |
| 1809 | 1800 | ||
| 1810 | def AddAnnotation(self, name, value, keep): | 1801 | def AddAnnotation(self, name, value, keep): |
| 1811 | self.annotations.append(Annotation(name, value, keep)) | 1802 | self.annotations.append(Annotation(name, value, keep)) |
