# HG changeset patch # User Laurent Charignon # Date 2015-05-21 21:32:14 # Node ID 07326d76f19d3f163b7182e750a2b029f5c45ca3 # Parent 5a8398b085ed3d070fa098151bc7599fdbdccaa2 record: extract code to compute newly added and modified files We want to reuse this logic in revert. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -21,6 +21,14 @@ def ishunk(x): hunkclasses = (crecordmod.uihunk, patch.recordhunk) return isinstance(x, hunkclasses) +def newandmodified(chunks, originalchunks): + newlyaddedandmodifiedfiles = set() + for chunk in chunks: + if ishunk(chunk) and chunk.header.isnewfile() and chunk not in \ + originalchunks: + newlyaddedandmodifiedfiles.add(chunk.header.filename()) + return newlyaddedandmodifiedfiles + def parsealiases(cmd): return cmd.lstrip("^").split("|") @@ -109,11 +117,7 @@ def dorecord(ui, repo, commitfunc, cmdsu # We need to keep a backup of files that have been newly added and # modified during the recording process because there is a previous # version without the edit in the workdir - newlyaddedandmodifiedfiles = set() - for chunk in chunks: - if ishunk(chunk) and chunk.header.isnewfile() and chunk not in \ - originalchunks: - newlyaddedandmodifiedfiles.add(chunk.header.filename()) + newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) contenders = set() for h in chunks: try: