Mercurial > public > mercurial-scm > hg
comparison mercurial/sparse.py @ 52697:f3762eafed66
typing: add some type annotations to the `merge.mergeresult` class
The generated type annotations around `filemap()` and `files()` were slightly
modified by the pyupgrade series culminating in 70a75d379daf. This module is
way more complicated than the other changes, but these weren't too bad to figure
out.
The typing caught a trivial issue in `sparse`- it was passing an empty data list
to `addfile()` for the `ACTION_REMOVE` case, instead of a tuple or None.
`merge.manifestmerge()` calls this function with None for the data, so 1) it has
to be typed as optional, and 2) is safe to pass None in the sparse code.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 13 Jan 2025 12:24:33 -0500 |
parents | 24ee91ba9aa8 |
children |
comparison
equal
deleted
inserted
replaced
52696:10e7adbffa8c | 52697:f3762eafed66 |
---|---|
546 # Drop files that are newly excluded, or that still exist in | 546 # Drop files that are newly excluded, or that still exist in |
547 # the dirstate. | 547 # the dirstate. |
548 elif (old and not new) or (not old and not new and file in dirstate): | 548 elif (old and not new) or (not old and not new and file in dirstate): |
549 dropped.append(file) | 549 dropped.append(file) |
550 if file not in pending: | 550 if file not in pending: |
551 mresult.addfile(file, mergestatemod.ACTION_REMOVE, [], b'') | 551 mresult.addfile(file, mergestatemod.ACTION_REMOVE, None, b'') |
552 | 552 |
553 # Verify there are no pending changes in newly included files | 553 # Verify there are no pending changes in newly included files |
554 abort = False | 554 abort = False |
555 for file in lookup: | 555 for file in lookup: |
556 repo.ui.warn(_(b"pending changes to '%s'\n") % file) | 556 repo.ui.warn(_(b"pending changes to '%s'\n") % file) |