The push logic from "Push outgoing changes" and
"Push to Here", were different, the force push option and
some dialogs were been used only in the first operation,
now the two are sharing the same logic

I found this trying to push just one change that creates a new
header, the force option was been ignored.

-- 
Att.
Diego de Oliveira
System Architect
di...@diegooliveira.com
www.diegooliveira.com
# HG changeset patch
# User Diego de Oliveira <di...@diegooliveira.com>
# Date 1269377618 10800
# Node ID b6c8ded1658cd71132f36393476e775ab62e03f5
# Parent  6de6196eaa83cc875985b9e62dee0db8bf975e88
history: Unifying the push logic

The push logic from "Push outgoing changes" and
"Push to Here", were different, the force push option and
some dialogs were been used only in the first operation,
now the two are sharing the same logic

diff -r 6de6196eaa83 -r b6c8ded1658c tortoisehg/hgtk/history.py
--- a/tortoisehg/hgtk/history.py	Mon Mar 22 10:58:26 2010 -0500
+++ b/tortoisehg/hgtk/history.py	Tue Mar 23 17:53:38 2010 -0300
@@ -2005,39 +2005,10 @@
         self.show_dialog(dlg)
 
     def push_clicked(self, toolbutton):
-        original_path = hglib.fromutf(self.pathentry.get_text()).strip()
-        remote_path = hglib.validate_synch_path(original_path, self.repo)
+        remote_path = self.validate_path()
         if not remote_path:
-            gdialog.Prompt(_('No remote path specified'),
-                           _('Please enter or select a remote path'),
-                           self).run()
-            self.pathentry.grab_focus()
             return
 
-        confirm_push = False
-        if not hg.islocal(remote_path):
-            if self.forcepush:
-                title = _('Confirm Forced Push to Remote Repository')
-                text = _('Forced push to remote repository\n%s\n'
-                    '(creating new heads in remote if needed)?') % original_path
-                buttontext = _('Forced &Push')
-            else:
-                title = _('Confirm Push to remote Repository')
-                text = _('Push to remote repository\n%s\n?') % original_path
-                buttontext = _('&Push')
-            confirm_push = True
-        elif self.forcepush:
-            title = _('Confirm Forced Push')
-            text = _('Forced push to repository\n%s\n'
-                '(creating new heads if needed)?') % original_path
-            buttontext = _('Forced &Push')
-            confirm_push = True
-        if confirm_push:
-            dlg = gdialog.CustomPrompt(title, text,
-                    None, (buttontext, _('&Cancel')), default=1, esc=1)
-            if dlg.run() != 0:
-                return
-
         cmdline = ['hg', 'push'] + self.get_proxy_args()
         if self.forcepush:
             cmdline += ['--force']
@@ -2582,22 +2553,55 @@
                          statopts)
         dialog.display()
 
-    def push_to(self, menuitem):
-        remote_path = hglib.fromutf(self.pathentry.get_text()).strip()
-        for alias, path in self.repo.ui.configitems('paths'):
-            if remote_path == alias:
-                remote_path = path
-            elif remote_path == url.hidepassword(path):
-                remote_path = path
+    def validate_path(self):
+        original_path = hglib.fromutf(self.pathentry.get_text()).strip()
+        remote_path = hglib.validate_synch_path(original_path, self.repo)
         if not remote_path:
             gdialog.Prompt(_('No remote path specified'),
                            _('Please enter or select a remote path'),
                            self).run()
             self.pathentry.grab_focus()
+            return None
+        else:
+            confirm_push = False
+            if not hg.islocal(remote_path):
+                if self.forcepush:
+                    title = _('Confirm Forced Push to Remote Repository')
+                    text = _('Forced push to remote repository\n%s\n'
+                             '(creating new heads in remote if needed)?') % original_path
+                    buttontext = _('Forced &Push')
+                else:
+                    title = _('Confirm Push to remote Repository')
+                    text = _('Push to remote repository\n%s\n?') % original_path
+                    buttontext = _('&Push')
+                    confirm_push = True
+            elif self.forcepush:
+                title = _('Confirm Forced Push')
+                text = _('Forced push to repository\n%s\n'
+                         '(creating new heads if needed)?') % original_path
+                buttontext = _('Forced &Push')
+                confirm_push = True
+            
+            if confirm_push:
+                dlg = gdialog.CustomPrompt(title, text,
+                    None, (buttontext, _('&Cancel')), default=1, esc=1)
+                if dlg.run() != 0:
+                    return None
+                else :
+                    return remote_path
+            else :
+                return remote_path    
+
+    def push_to(self, menuitem):
+        remote_path = self.validate_path()
+        if not remote_path :
             return
+        
         node = self.repo[self.currevid].node()
         rev = str(self.currevid)
         cmdline = ['hg', 'push', '--rev', rev, remote_path]
+        if self.forcepush:
+            cmdline += ['--force']
 
         def callback(return_code, *args):
             if return_code == 0:
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to