diff options
| author | Jack Neus <jackneus@google.com> | 2021-07-20 20:52:33 +0000 |
|---|---|---|
| committer | Jack Neus <jackneus@google.com> | 2021-07-23 18:03:11 +0000 |
| commit | 6ea0caea86f4c6b1f934b682a3aa7722e98a46f9 (patch) | |
| tree | f54707aa6778f60078aef727210669f22f87de4e /project.py | |
| parent | 8e983bbc0f5f48aa38d0e1c5a37766ce121d28eb (diff) | |
| download | git-repo-6ea0caea86f4c6b1f934b682a3aa7722e98a46f9.tar.gz | |
repo: properly handle remote annotations in manifest_xml
BUG=b:192664812
TEST=tests/
Change-Id: I1aa50260f4a00d3cebbd531141e1626825e70127
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312643
Tested-by: Jack Neus <jackneus@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 20 |
1 files changed, 18 insertions, 2 deletions
| @@ -251,13 +251,29 @@ class DiffColoring(Coloring): | |||
| 251 | self.fail = self.printer('fail', fg='red') | 251 | self.fail = self.printer('fail', fg='red') |
| 252 | 252 | ||
| 253 | 253 | ||
| 254 | class _Annotation(object): | 254 | class Annotation(object): |
| 255 | 255 | ||
| 256 | def __init__(self, name, value, keep): | 256 | def __init__(self, name, value, keep): |
| 257 | self.name = name | 257 | self.name = name |
| 258 | self.value = value | 258 | self.value = value |
| 259 | self.keep = keep | 259 | self.keep = keep |
| 260 | 260 | ||
| 261 | def __eq__(self, other): | ||
| 262 | if not isinstance(other, Annotation): | ||
| 263 | return False | ||
| 264 | return self.__dict__ == other.__dict__ | ||
| 265 | |||
| 266 | def __lt__(self, other): | ||
| 267 | # This exists just so that lists of Annotation objects can be sorted, for | ||
| 268 | # use in comparisons. | ||
| 269 | if not isinstance(other, Annotation): | ||
| 270 | raise ValueError('comparison is not between two Annotation objects') | ||
| 271 | if self.name == other.name: | ||
| 272 | if self.value == other.value: | ||
| 273 | return self.keep < other.keep | ||
| 274 | return self.value < other.value | ||
| 275 | return self.name < other.name | ||
| 276 | |||
| 261 | 277 | ||
| 262 | def _SafeExpandPath(base, subpath, skipfinal=False): | 278 | def _SafeExpandPath(base, subpath, skipfinal=False): |
| 263 | """Make sure |subpath| is completely safe under |base|. | 279 | """Make sure |subpath| is completely safe under |base|. |
| @@ -1448,7 +1464,7 @@ class Project(object): | |||
| 1448 | self.linkfiles.append(_LinkFile(self.worktree, src, topdir, dest)) | 1464 | self.linkfiles.append(_LinkFile(self.worktree, src, topdir, dest)) |
| 1449 | 1465 | ||
| 1450 | def AddAnnotation(self, name, value, keep): | 1466 | def AddAnnotation(self, name, value, keep): |
| 1451 | self.annotations.append(_Annotation(name, value, keep)) | 1467 | self.annotations.append(Annotation(name, value, keep)) |
| 1452 | 1468 | ||
| 1453 | def DownloadPatchSet(self, change_id, patch_id): | 1469 | def DownloadPatchSet(self, change_id, patch_id): |
| 1454 | """Download a single patch set of a single change to FETCH_HEAD. | 1470 | """Download a single patch set of a single change to FETCH_HEAD. |
