Mercurial > hg
comparison hgext/mq.py @ 14241:45f7aa35f2fd
mq: don't hide the patch module
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Fri, 06 May 2011 19:03:45 +0300 |
parents | 967be4bb42a7 |
children | d04ba50e104d |
comparison
equal
deleted
inserted
replaced
14240:28762bb767dc | 14241:45f7aa35f2fd |
---|---|
43 ''' | 43 ''' |
44 | 44 |
45 from mercurial.i18n import _ | 45 from mercurial.i18n import _ |
46 from mercurial.node import bin, hex, short, nullid, nullrev | 46 from mercurial.node import bin, hex, short, nullid, nullrev |
47 from mercurial.lock import release | 47 from mercurial.lock import release |
48 from mercurial import commands, cmdutil, hg, patch, scmutil, util, revset | 48 from mercurial import commands, cmdutil, hg, scmutil, util, revset |
49 from mercurial import repair, extensions, url, error | 49 from mercurial import repair, extensions, url, error |
50 from mercurial import patch as patchmod | |
50 import os, sys, re, errno, shutil | 51 import os, sys, re, errno, shutil |
51 | 52 |
52 commands.norepo += " qclone" | 53 commands.norepo += " qclone" |
53 | 54 |
54 # Patch names looks like unix-file names. | 55 # Patch names looks like unix-file names. |
319 self.series_dirty = 0 | 320 self.series_dirty = 0 |
320 self.guards_dirty = False | 321 self.guards_dirty = False |
321 self.active_guards = None | 322 self.active_guards = None |
322 | 323 |
323 def diffopts(self, opts={}, patchfn=None): | 324 def diffopts(self, opts={}, patchfn=None): |
324 diffopts = patch.diffopts(self.ui, opts) | 325 diffopts = patchmod.diffopts(self.ui, opts) |
325 if self.gitmode == 'auto': | 326 if self.gitmode == 'auto': |
326 diffopts.upgrade = True | 327 diffopts.upgrade = True |
327 elif self.gitmode == 'keep': | 328 elif self.gitmode == 'keep': |
328 pass | 329 pass |
329 elif self.gitmode in ('yes', 'no'): | 330 elif self.gitmode in ('yes', 'no'): |
611 def patch(self, repo, patchfile): | 612 def patch(self, repo, patchfile): |
612 '''Apply patchfile to the working directory. | 613 '''Apply patchfile to the working directory. |
613 patchfile: name of patch file''' | 614 patchfile: name of patch file''' |
614 files = {} | 615 files = {} |
615 try: | 616 try: |
616 fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root, | 617 fuzz = patchmod.patch(patchfile, self.ui, strip=1, cwd=repo.root, |
617 files=files, eolmode=None) | 618 files=files, eolmode=None) |
618 except Exception, inst: | 619 except Exception, inst: |
619 self.ui.note(str(inst) + '\n') | 620 self.ui.note(str(inst) + '\n') |
620 if not self.ui.verbose: | 621 if not self.ui.verbose: |
621 self.ui.warn(_("patch failed, unable to continue (try -v)\n")) | 622 self.ui.warn(_("patch failed, unable to continue (try -v)\n")) |
945 if msg: | 946 if msg: |
946 msg = msg + "\n\n" | 947 msg = msg + "\n\n" |
947 p.write(msg) | 948 p.write(msg) |
948 if commitfiles: | 949 if commitfiles: |
949 parent = self.qparents(repo, n) | 950 parent = self.qparents(repo, n) |
950 chunks = patch.diff(repo, node1=parent, node2=n, | 951 chunks = patchmod.diff(repo, node1=parent, node2=n, |
951 match=match, opts=diffopts) | 952 match=match, opts=diffopts) |
952 for chunk in chunks: | 953 for chunk in chunks: |
953 p.write(chunk) | 954 p.write(chunk) |
954 p.close() | 955 p.close() |
955 wlock.release() | 956 wlock.release() |
1405 m = list(mm) | 1406 m = list(mm) |
1406 r = list(dd) | 1407 r = list(dd) |
1407 a = list(aa) | 1408 a = list(aa) |
1408 c = [filter(matchfn, l) for l in (m, a, r)] | 1409 c = [filter(matchfn, l) for l in (m, a, r)] |
1409 match = cmdutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs)) | 1410 match = cmdutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs)) |
1410 chunks = patch.diff(repo, patchparent, match=match, | 1411 chunks = patchmod.diff(repo, patchparent, match=match, |
1411 changes=c, opts=diffopts) | 1412 changes=c, opts=diffopts) |
1412 for chunk in chunks: | 1413 for chunk in chunks: |
1413 patchf.write(chunk) | 1414 patchf.write(chunk) |
1414 | 1415 |
1415 try: | 1416 try: |