diff --git a/mercurial/commit.py b/mercurial/commit.py index 64a9423450efb39d7f1bc5b6b2cca1efafb1870e_bWVyY3VyaWFsL2NvbW1pdC5weQ==..30aad2d9efca190b42fffd85e5ce4e500348c519_bWVyY3VyaWFsL2NvbW1pdC5weQ== 100644 --- a/mercurial/commit.py +++ b/mercurial/commit.py @@ -114,8 +114,13 @@ p1 = ctx.p1() writechangesetcopy, writefilecopymeta = _write_copy_meta(repo) + files = metadata.ChangingFiles() + ms = mergestate.mergestate.read(repo) + salvaged = _get_salvaged(repo, ms, ctx) + for s in salvaged: + files.mark_salvaged(s) if ctx.manifestnode(): # reuse an existing manifest revision repo.ui.debug(b'reusing known manifest\n') mn = ctx.manifestnode() @@ -117,9 +122,8 @@ if ctx.manifestnode(): # reuse an existing manifest revision repo.ui.debug(b'reusing known manifest\n') mn = ctx.manifestnode() - files = metadata.ChangingFiles() files.update_touched(ctx.files()) if writechangesetcopy: files.update_added(ctx.filesadded()) @@ -127,5 +131,4 @@ elif not ctx.files(): repo.ui.debug(b'reusing manifest from p1 (no file change)\n') mn = p1.manifestnode() - files = metadata.ChangingFiles() else: @@ -131,5 +134,5 @@ else: - mn, files = _process_files(tr, ctx, error=error) + mn = _process_files(tr, ctx, ms, files, error=error) if origctx and origctx.manifestnode() == mn: origfiles = origctx.files() @@ -140,5 +143,14 @@ files.update_copies_from_p1(ctx.p1copies()) files.update_copies_from_p2(ctx.p2copies()) - copy_sd = ctx.repo().filecopiesmode == b'changeset-sidedata' + 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: @@ -144,6 +156,2 @@ 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(): @@ -149,5 +157,5 @@ if ms.active(): - for fname in sorted(ms._stateextras.keys()): + 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: @@ -151,8 +159,7 @@ 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 @@ -157,6 +164,6 @@ -def _process_files(tr, ctx, error=False): +def _process_files(tr, ctx, ms, files, error=False): repo = ctx.repo() p1 = ctx.p1() p2 = ctx.p2() @@ -170,9 +177,6 @@ m = mctx.read() m1 = m1ctx.read() m2 = m2ctx.read() - ms = mergestate.mergestate.read(repo) - - files = metadata.ChangingFiles() # check in files added = [] @@ -223,7 +227,7 @@ mn = _commit_manifest(tr, linkrev, ctx, mctx, m, files.touched, added, drop) - return mn, files + return mn def _filecommit( diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py index 64a9423450efb39d7f1bc5b6b2cca1efafb1870e_bWVyY3VyaWFsL2RlYnVnY29tbWFuZHMucHk=..30aad2d9efca190b42fffd85e5ce4e500348c519_bWVyY3VyaWFsL2RlYnVnY29tbWFuZHMucHk= 100644 --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -2107,7 +2107,7 @@ fm_files.end() fm_extras = fm.nested(b'extras') - for f, d in sorted(pycompat.iteritems(ms._stateextras)): + for f, d in sorted(pycompat.iteritems(ms.extras())): if f in ms: # If file is in mergestate, we have already processed it's extras continue diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py index 64a9423450efb39d7f1bc5b6b2cca1efafb1870e_bWVyY3VyaWFsL21lcmdlc3RhdGUucHk=..30aad2d9efca190b42fffd85e5ce4e500348c519_bWVyY3VyaWFsL21lcmdlc3RhdGUucHk= 100644 --- a/mercurial/mergestate.py +++ b/mercurial/mergestate.py @@ -305,7 +305,12 @@ ): yield f - def extras(self, filename): + def extras(self, filename=None): + """ return extras stored with the mergestate + + if filename is passed, extras for that file is only returned """ + if filename is None: + return self._stateextras return self._stateextras[filename] def _resolve(self, preresolve, dfile, wctx):