Source

thg-qt-mq / sync-pushpull-check.mbox

Subject:
[thg-dev] [PATCH 1 of 1] sync: add checkbox to use same repository for push and pull
From:
André Sintzoff <andre.sintzoff@gmail.com>
Date:
2012年05月19日 03:49
To:
thg-dev@googlegroups.com

# HG changeset patch
# User André Sintzoff <andre.sintzoff@gmail.com>
# Date 1337365748 -7200
# Branch stable
# Node ID eb8bd962cc659949277908bff348492e4b72b256
# Parent  def3666e88c972efbd5681725c93a21cbefe7a1d
sync: add checkbox to use same repository for push and pull

diff --git a/tortoisehg/hgqt/sync.py b/tortoisehg/hgqt/sync.py
--- a/tortoisehg/hgqt/sync.py
+++ b/tortoisehg/hgqt/sync.py
@@ -222,6 +222,14 @@
         hbox = QHBoxLayout()
         hbox.setContentsMargins(0, 0, 0, 0)
         bottomlayout.addLayout(hbox)
+        self.onerepocheckbox = QCheckBox(_('Use same repository for push and pull'))
+        hbox.addWidget(self.onerepocheckbox)
+        self.onerepocheckbox.hide()
+        self.onerepocheckbox.toggled.connect(self.onerepocheckbox_toggled)
+
+        hbox = QHBoxLayout()
+        hbox.setContentsMargins(0, 0, 0, 0)
+        bottomlayout.addLayout(hbox)
 
         self.pathEditToolbar = tbar = QToolBar(_('Path Edit Toolbar'))
         tbar.setStyleSheet(qtlib.tbstylesheet)
@@ -480,15 +488,25 @@
         tm = PathsModel(pairs, self)
         self.reltv.setModel(tm)
 
+    def onerepocheckbox_toggled(self):
+        self.refreshUrl()
+        self.refreshStatusTips()
+
     def refreshUrl(self):
         'User has changed schema/host/port/path'
         if self.updateInProgress:
             return
         self.urllabel.setText(hglib.tounicode(self.currentUrl(True)))
         if self.curalias and self.curalias + '-push' in self.paths:
-            self.pushlabel.show()
-            self.pushurllabel.setText(hglib.tounicode(self.currentPushUrl()))
+            self.onerepocheckbox.show()
+            if self.onerepocheckbox.isChecked():
+                self.pushlabel.hide()
+                self.pushurllabel.setText('')
+            else:
+                self.pushlabel.show()
+                self.pushurllabel.setText(hglib.tounicode(self.currentPushUrl()))
         else:
+            self.onerepocheckbox.hide()
             self.pushlabel.hide()
             self.pushurllabel.setText('')
 
@@ -534,7 +552,8 @@
             return ''.join(parts)
 
     def currentPushUrl(self):
-        if self.curalias and self.curalias + '-push' in self.paths:
+        if self.curalias and self.curalias + '-push' in self.paths and \
+           not self.onerepocheckbox.isChecked():
             url = self.paths[self.curalias + '-push']
             user, host, port, folder, passwd, scheme = parseurl(url)
             parts = [scheme, '://']
@@ -763,10 +782,9 @@
             cmdline.append('--debug')
 
         cururl = self.currentUrl(False)
-        implicitpushrepo = False
         if ('push' in cmdline or 'outgoing' in cmdline) and \
-           self.curalias + '-push' in self.paths:
-            implicitpushrepo = True
+           not self.onerepocheckbox.isChecked() and \
+           self.curalias and self.curalias + '-push' in self.paths:
             cururl = self.paths[self.curalias + '-push']
 
         if not cururl:
@@ -803,7 +821,9 @@
                             self.saveclicked()
 
         safeurl = self.currentUrl(True)
-        if implicitpushrepo:
+        if ('push' in cmdline or 'outgoing' in cmdline) and \
+           not self.onerepocheckbox.isChecked() and \
+           self.curalias and self.curalias + '-push' in self.paths:
             safeurl = self.currentPushUrl()
 
         display = ' '.join(cmdline + [safeurl]).replace('\n', '^M')