Mercurial > hg
comparison mercurial/cmdutil.py @ 31134:c22253c4c1b8
revert: remove set(mf) because it's O(manifest)
The revert code had a 'set(manifest)' line in it, which has a runtime equivalent
to the size of the manifest. With alternative manifest implementations, like
treemanifest, this can be extra expensive. Let's rewrite it to be O(changes)
instead of O(manifest size).
author | Durham Goode <durham@fb.com> |
---|---|
date | Wed, 01 Mar 2017 19:51:05 -0800 |
parents | a113284f54a0 |
children | accdd5e62066 |
comparison
equal
deleted
inserted
replaced
31133:23080c03a604 | 31134:c22253c4c1b8 |
---|---|
2974 unknown = set(changes.unknown) | 2974 unknown = set(changes.unknown) |
2975 unknown.update(changes.ignored) | 2975 unknown.update(changes.ignored) |
2976 clean = set(changes.clean) | 2976 clean = set(changes.clean) |
2977 modadded = set() | 2977 modadded = set() |
2978 | 2978 |
2979 # split between files known in target manifest and the others | |
2980 smf = set(mf) | |
2981 | |
2982 # determine the exact nature of the deleted changesets | 2979 # determine the exact nature of the deleted changesets |
2983 deladded = _deleted - smf | 2980 deladded = set(_deleted) |
2981 for path in _deleted: | |
2982 if path in mf: | |
2983 deladded.remove(path) | |
2984 deleted = _deleted - deladded | 2984 deleted = _deleted - deladded |
2985 | 2985 |
2986 # We need to account for the state of the file in the dirstate, | 2986 # We need to account for the state of the file in the dirstate, |
2987 # even when we revert against something else than parent. This will | 2987 # even when we revert against something else than parent. This will |
2988 # slightly alter the behavior of revert (doing back up or not, delete | 2988 # slightly alter the behavior of revert (doing back up or not, delete |
3022 dsadded = added | 3022 dsadded = added |
3023 | 3023 |
3024 # in case of merge, files that are actually added can be reported as | 3024 # in case of merge, files that are actually added can be reported as |
3025 # modified, we need to post process the result | 3025 # modified, we need to post process the result |
3026 if p2 != nullid: | 3026 if p2 != nullid: |
3027 mergeadd = dsmodified - smf | 3027 mergeadd = set(dsmodified) |
3028 for path in dsmodified: | |
3029 if path in mf: | |
3030 mergeadd.remove(path) | |
3028 dsadded |= mergeadd | 3031 dsadded |= mergeadd |
3029 dsmodified -= mergeadd | 3032 dsmodified -= mergeadd |
3030 | 3033 |
3031 # if f is a rename, update `names` to also revert the source | 3034 # if f is a rename, update `names` to also revert the source |
3032 cwd = repo.getcwd() | 3035 cwd = repo.getcwd() |