summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorJack Neus <jackneus@google.com>2021-07-20 20:52:33 +0000
committerJack Neus <jackneus@google.com>2021-07-23 18:03:11 +0000
commit6ea0caea86f4c6b1f934b682a3aa7722e98a46f9 (patch)
treef54707aa6778f60078aef727210669f22f87de4e /project.py
parent8e983bbc0f5f48aa38d0e1c5a37766ce121d28eb (diff)
downloadgit-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.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/project.py b/project.py
index a55e7600..fe88a505 100644
--- a/project.py
+++ b/project.py
@@ -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
254class _Annotation(object): 254class 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
262def _SafeExpandPath(base, subpath, skipfinal=False): 278def _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.