# HG changeset patch # User Patrick Mezard # Date 2011-06-11 12:14:11 # Node ID 65f4512e40e4c888de4f69aa449c5f145a9e4fbb # Parent 81fc9678b018c928e2c5333b9055a66616db0531 patch: turn patch() touched files dict into a set diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -617,7 +617,7 @@ class queue(object): def patch(self, repo, patchfile): '''Apply patchfile to the working directory. patchfile: name of patch file''' - files = {} + files = set() try: fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1, files=files, eolmode=None) diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -227,7 +227,7 @@ class transplanter(object): raise util.Abort(_('can only omit patchfile if merging')) if patchfile: try: - files = {} + files = set() patch.patch(self.ui, repo, patchfile, files=files, eolmode=None) files = list(files) if not files: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3106,7 +3106,7 @@ def import_(ui, repo, patch1, *patches, if opts.get('exact') or opts.get('import_branch'): repo.dirstate.setbranch(branch or 'default') - files = {} + files = set() patch.patch(ui, repo, tmpname, strip=strip, files=files, eolmode=None, similarity=sim / 100.0) files = list(files) diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1223,7 +1223,7 @@ def _applydiff(ui, fp, patcher, backend, continue ret = current_file.apply(values) if ret >= 0: - changed.setdefault(current_file.fname, None) + changed.add(current_file.fname) if ret > 0: err = 1 elif state == 'file': @@ -1236,7 +1236,7 @@ def _applydiff(ui, fp, patcher, backend, path = pstrip(gp.path) if gp.oldpath: copysource = pstrip(gp.oldpath) - changed[path] = gp + changed.add(path) if gp.op == 'RENAME': backend.unlink(copysource) if not first_hunk: @@ -1306,7 +1306,7 @@ def _externalpatch(ui, repo, patcher, pa if line.startswith('patching file '): pf = util.parsepatchoutput(line) printed_file = False - files.setdefault(pf, None) + files.add(pf) elif line.find('with fuzz') >= 0: fuzz = True if not printed_file: @@ -1340,7 +1340,7 @@ def internalpatch(ui, repo, patchobj, st returns whether patch was applied with fuzz factor.""" if files is None: - files = {} + files = set() if eolmode is None: eolmode = ui.config('patch', 'eol', 'strict') if eolmode.lower() not in eolmodes: @@ -1359,7 +1359,7 @@ def internalpatch(ui, repo, patchobj, st finally: if fp != patchobj: fp.close() - files.update(dict.fromkeys(backend.close())) + files.update(backend.close()) store.close() if ret < 0: raise PatchError(_('patch failed to apply')) @@ -1380,7 +1380,7 @@ def patch(ui, repo, patchname, strip=1, """ patcher = ui.config('ui', 'patch') if files is None: - files = {} + files = set() try: if patcher: return _externalpatch(ui, repo, patcher, patchname, strip,