Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGff9694ea3852: resolve: use context manager for config override
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/commands.py (14 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | Jun 14 2018, 6:46 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| try: | try: | ||||
| util.copyfile(a, a + ".resolve") | util.copyfile(a, a + ".resolve") | ||||
| except (IOError, OSError) as inst: | except (IOError, OSError) as inst: | ||||
| if inst.errno != errno.ENOENT: | if inst.errno != errno.ENOENT: | ||||
| raise | raise | ||||
| try: | try: | ||||
| # preresolve file | # preresolve file | ||||
| ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | ||||
| 'resolve') | with ui.configoverride(overrides, 'resolve'): | ||||
| complete, r = ms.preresolve(f, wctx) | complete, r = ms.preresolve(f, wctx) | ||||
| if not complete: | if not complete: | ||||
| tocomplete.append(f) | tocomplete.append(f) | ||||
| elif r: | elif r: | ||||
| ret = 1 | ret = 1 | ||||
| finally: | finally: | ||||
| ui.setconfig('ui', 'forcemerge', '', 'resolve') | |||||
| ms.commit() | ms.commit() | ||||
| # replace filemerge's .orig file with our resolve file, but only | # replace filemerge's .orig file with our resolve file, but only | ||||
| # for merges that are complete | # for merges that are complete | ||||
| if complete: | if complete: | ||||
| try: | try: | ||||
| util.rename(a + ".resolve", | util.rename(a + ".resolve", | ||||
| scmutil.origpath(ui, repo, a)) | scmutil.origpath(ui, repo, a)) | ||||
| except OSError as inst: | except OSError as inst: | ||||
| if inst.errno != errno.ENOENT: | if inst.errno != errno.ENOENT: | ||||
| raise | raise | ||||
| for f in tocomplete: | for f in tocomplete: | ||||
| try: | try: | ||||
| # resolve file | # resolve file | ||||
| ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | ||||
| 'resolve') | with ui.configoverride(overrides, 'resolve'): | ||||
| r = ms.resolve(f, wctx) | r = ms.resolve(f, wctx) | ||||
| if r: | if r: | ||||
| ret = 1 | ret = 1 | ||||
| finally: | finally: | ||||
| ui.setconfig('ui', 'forcemerge', '', 'resolve') | |||||
| ms.commit() | ms.commit() | ||||
| # replace filemerge's .orig file with our resolve file | # replace filemerge's .orig file with our resolve file | ||||
| a = repo.wjoin(f) | a = repo.wjoin(f) | ||||
| try: | try: | ||||
| util.rename(a + ".resolve", scmutil.origpath(ui, repo, a)) | util.rename(a + ".resolve", scmutil.origpath(ui, repo, a)) | ||||
| except OSError as inst: | except OSError as inst: | ||||
| if inst.errno != errno.ENOENT: | if inst.errno != errno.ENOENT: | ||||