Mercurial > hg
comparison hgext/fix.py @ 47767:66ad7e32011f stable
fix: use scmutil.movedirstate() instead of reimplementing
I wrote this patch 2 years ago as a little cleanup. I wanted to
generally used `scmutil.movedirstate()` instead of manually updating
the dirstate because that is easy to get wrong. I didn't know until
today that the current code had a bug. So I added the test case two
patches before this one and dusted off this one patch. This is a
little slower than the previous code, as it diffs two
manifests. However, it fixes the bug and I don't think it's going to
be noticeably slower anyway.
Differential Revision: https://phab.mercurial-scm.org/D11210
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 11 Mar 2019 10:59:35 -0700 |
parents | 3feda1e779d4 |
children | e69c82bf3a01 |
comparison
equal
deleted
inserted
replaced
47766:3feda1e779d4 | 47767:66ad7e32011f |
---|---|
757 assert repo.dirstate.p2() == nullid | 757 assert repo.dirstate.p2() == nullid |
758 | 758 |
759 for path, data in pycompat.iteritems(filedata): | 759 for path, data in pycompat.iteritems(filedata): |
760 fctx = ctx[path] | 760 fctx = ctx[path] |
761 fctx.write(data, fctx.flags()) | 761 fctx.write(data, fctx.flags()) |
762 if repo.dirstate[path] == b'n': | |
763 repo.dirstate.set_possibly_dirty(path) | |
764 | 762 |
765 oldp1 = repo.dirstate.p1() | 763 oldp1 = repo.dirstate.p1() |
766 newp1 = replacements.get(oldp1, oldp1) | 764 newp1 = replacements.get(oldp1, oldp1) |
767 if newp1 != oldp1: | 765 if newp1 != oldp1: |
768 repo.setparents(newp1, nullid) | 766 with repo.dirstate.parentchange(): |
767 scmutil.movedirstate(repo, repo[newp1]) | |
769 | 768 |
770 | 769 |
771 def replacerev(ui, repo, ctx, filedata, replacements): | 770 def replacerev(ui, repo, ctx, filedata, replacements): |
772 """Commit a new revision like the given one, but with file content changes | 771 """Commit a new revision like the given one, but with file content changes |
773 | 772 |