Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 37620:fd1dd79cff20
cmdutil: pass in parsed patch to tryimportone() (API)
Previously, we parsed the patch in tryimportone(). This assumes the
input is in a patch format that needs to be parsed. We want to support
feeding in data from other formats. So let's let the caller handle the
parsing.
One wonky thing about patch parsing is that patch.extract() creates
a temp file to hold the diffs and it is up to tryimportone() to
unlink that temp file. I'll improve this in a subsequent commit.
Differential Revision: https://phab.mercurial-scm.org/D3305
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 12 Apr 2018 23:06:27 -0700 |
parents | daafaff4e5be |
children | 5537d8f5e989 |
comparison
equal
deleted
inserted
replaced
37619:68132a95df31 | 37620:fd1dd79cff20 |
---|---|
3087 ui.status(_('applying %s\n') % patchurl) | 3087 ui.status(_('applying %s\n') % patchurl) |
3088 patchfile = hg.openpath(ui, patchurl) | 3088 patchfile = hg.openpath(ui, patchurl) |
3089 | 3089 |
3090 haspatch = False | 3090 haspatch = False |
3091 for hunk in patch.split(patchfile): | 3091 for hunk in patch.split(patchfile): |
3092 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk, | 3092 patchdata = patch.extract(ui, hunk) |
3093 parents, opts, | 3093 |
3094 msgs, hg.clean) | 3094 msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata, |
3095 parents, opts, | |
3096 msgs, hg.clean) | |
3095 if msg: | 3097 if msg: |
3096 haspatch = True | 3098 haspatch = True |
3097 ui.note(msg + '\n') | 3099 ui.note(msg + '\n') |
3098 if update or exact: | 3100 if update or exact: |
3099 parents = repo[None].parents() | 3101 parents = repo[None].parents() |