Source

thg-patches / SyncMq

# HG changeset patch
# Parent 7c8ecf007c306b39bc2824473c6cf19d4ba13141
sync: add support for the --mq option in the sync tool

This patch adds a combobox to the sync options dialog if the mq extension is
enabled. If one checks that combobox, the sync commands know that they should
work on the patch queue by setting the --mq option. If the mq extension is
disabled while the combobox is still checked, the stored mq option choice gets
discarded.

Since every command (push, pull, incoming, outgoing) needs a lot of changes,
this patch just adds the basic infrastructure and is the inception of the patch.

diff -r 7c8ecf007c30 tortoisehg/hgqt/sync.py
--- a/tortoisehg/hgqt/sync.py	Thu Nov 17 14:44:44 2011 -0500
+++ b/tortoisehg/hgqt/sync.py	Fri Nov 18 16:01:05 2011 +0100
@@ -92,10 +92,11 @@
         self.targetargs = []
 
         s = QSettings()
-        for opt in ('subrepos', 'force', 'new-branch', 'noproxy', 'debug'):
+        for opt in ('subrepos', 'force', 'new-branch', 'noproxy', 'debug', 'mq'):
             val = s.value('sync/' + opt, None).toBool()
             if val:
-                self.opts[opt] = val
+                if opt != 'mq' or 'mq' in self.repo.extensions():
+                    self.opts[opt] = val
         for opt in ('remotecmd', 'branch'):
             val = str(s.value('sync/' + opt, None).toString())
             if val:
@@ -719,7 +720,8 @@
 
         safeurl = self.currentUrl(True)
         display = ' '.join(cmdline + [safeurl]).replace('\n', '^M')
-        cmdline.append(cururl)
+        if not self.opts['mq']:
+            cmdline.append(cururl)
         self.repo.incrementBusyCount()
         self.cmd.run(cmdline, display=display, useproc='p4://' in cururl)
 
@@ -1546,6 +1548,12 @@
         self.debugcb.setChecked(opts.get('debug', False))
         layout.addWidget(self.debugcb)
 
+        if 'mq' in self.repo.extensions():
+            self.mqcb = QCheckBox(
+                _('Work on patch queue (--mq)'))
+            self.mqcb.setChecked(opts.get('mq', False))
+            layout.addWidget(self.mqcb)
+
         form = QFormLayout()
         layout.addLayout(form)
 
@@ -1579,6 +1587,8 @@
         outopts['new-branch'] = self.newbranchcb.isChecked()
         outopts['noproxy'] = self.noproxycb.isChecked()
         outopts['debug'] = self.debugcb.isChecked()
+        if 'mq' in self.repo.extensions():
+            outopts['mq'] = self.mqcb.isChecked()
 
         self.outopts = outopts
         QDialog.accept(self)