diff options
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. |