From patchwork Sat Oct 10 08:40:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9191: commit: refactor salvage calculation to a different function From: phabricator X-Patchwork-Id: 47428 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Sat, 10 Oct 2020 08:40:56 +0000 pulkit created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9191 AFFECTED FILES mercurial/commit.py CHANGE DETAILS To: pulkit, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/mercurial/commit.py b/mercurial/commit.py --- a/mercurial/commit.py +++ b/mercurial/commit.py @@ -140,20 +140,29 @@ files.update_copies_from_p1(ctx.p1copies()) files.update_copies_from_p2(ctx.p2copies()) - copy_sd = ctx.repo().filecopiesmode == b'changeset-sidedata' + ms = mergestate.mergestate.read(repo) + salvaged = _get_salvaged(ctx.repo(), ms, ctx) + for s in salvaged: + files.mark_salvaged(s) + + return mn, files + + +def _get_salvaged(repo, ms, ctx): + """ returns a list of salvaged files + + returns empty list if config option which process salvaged files are + not enabled """ + salvaged = [] + copy_sd = repo.filecopiesmode == b'changeset-sidedata' if copy_sd and len(ctx.parents()) > 1: - # XXX this `mergestate.read` could be duplicated with a the merge state - # reading in _process_files So we could refactor further to reuse it in - # some cases. - ms = mergestate.mergestate.read(repo) if ms.active(): for fname in sorted(ms.extras().keys()): might_removed = ms.extras(fname).get(b'merge-removal-candidate') if might_removed == b'yes': if fname in ctx: - files.mark_salvaged(fname) - - return mn, files + salvaged.append(fname) + return salvaged def _process_files(tr, ctx, error=False):