Steve Borho avatar Steve Borho committed 9dfebd5

chunks: use a lower patching API, properly subclass repo.ui instance

Comments (0)

Files changed (1)

tortoisehg/hgqt/chunks.py

                 self.refresh()
 
     def runPatcher(self, fp, wfile, updatestate):
-        class warncapt(uimod.ui):
+        ui = self.repo.ui.copy()
+        class warncapt(ui.__class__):
             def warn(self, msg, *args, **opts):
                 self.write(msg)
+        ui.__class__ = warncapt
+
+        ok = True
         repo = self.repo
-        ui = warncapt()
         ui.pushbuffer()
-        strip, pfiles = 1, {}
-        ok = True
+        pfiles = {}
+        curdir = os.getcwd()
         try:
-            patch.internalpatch(fp, ui, strip, repo.root, files=pfiles,
-                                eolmode=None)
+            os.chdir(repo.root)
+            if patch.applydiff(ui, fp, pfiles) < 0:
+                ok = False
+                self.showMessage.emit(_('Patch failed to apply'))
         except patch.PatchError, err:
             ok = False
             self.showMessage.emit(hglib.tounicode(str(err)))
+        os.chdir(curdir)
         for line in ui.popbuffer().splitlines():
             if line.endswith(wfile + '.rej'):
                 if qtlib.QuestionMsgBox(_('Manually resolve rejected chunks?'),
                                         hglib.tounicode(line) + u'<br><br>' +
                                         _('Edit patched file and rejects?'),
                                        parent=self):
-                    #wctxactions.edit(self, repo.ui, repo, [wfile, wfile+'.rej'])
                     from tortoisehg.hgqt import rejects
                     dlg = rejects.RejectsDialog(repo.wjoin(wfile), self)
                     if dlg.exec_() == QDialog.Accepted:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.