14 import email.Parser |
14 import email.Parser |
15 |
15 |
16 from i18n import _ |
16 from i18n import _ |
17 from node import hex, short |
17 from node import hex, short |
18 import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error |
18 import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error |
19 import context |
|
20 |
19 |
21 gitre = re.compile('diff --git a/(.*) b/(.*)') |
20 gitre = re.compile('diff --git a/(.*) b/(.*)') |
22 |
21 |
23 class PatchError(Exception): |
22 class PatchError(Exception): |
24 pass |
23 pass |
1438 |
1437 |
1439 def patchrepo(ui, repo, ctx, store, patchobj, strip, files=None, |
1438 def patchrepo(ui, repo, ctx, store, patchobj, strip, files=None, |
1440 eolmode='strict'): |
1439 eolmode='strict'): |
1441 backend = repobackend(ui, repo, ctx, store) |
1440 backend = repobackend(ui, repo, ctx, store) |
1442 return patchbackend(ui, backend, patchobj, strip, files, eolmode) |
1441 return patchbackend(ui, backend, patchobj, strip, files, eolmode) |
1443 |
|
1444 def makememctx(repo, parents, text, user, date, branch, files, store, |
|
1445 editor=None): |
|
1446 def getfilectx(repo, memctx, path): |
|
1447 data, (islink, isexec), copied = store.getfile(path) |
|
1448 return context.memfilectx(path, data, islink=islink, isexec=isexec, |
|
1449 copied=copied) |
|
1450 extra = {} |
|
1451 if branch: |
|
1452 extra['branch'] = encoding.fromlocal(branch) |
|
1453 ctx = context.memctx(repo, parents, text, files, getfilectx, user, |
|
1454 date, extra) |
|
1455 if editor: |
|
1456 ctx._text = editor(repo, ctx, []) |
|
1457 return ctx |
|
1458 |
1442 |
1459 def patch(ui, repo, patchname, strip=1, files=None, eolmode='strict', |
1443 def patch(ui, repo, patchname, strip=1, files=None, eolmode='strict', |
1460 similarity=0): |
1444 similarity=0): |
1461 """Apply <patchname> to the working directory. |
1445 """Apply <patchname> to the working directory. |
1462 |
1446 |