On Sat, Sep 19, 2009 at 11:36, Steve Borho <st...@borho.org> wrote:
> On Fri, Sep 18, 2009 at 12:21 AM, Yuki KODAMA <endflow....@gmail.com> wrote:
>
> Actually, my commit was wrong.  Specifying --check prevents you from
> doing any update if the working directory is dirty, even if you're not
> switching branches.
>
> So both --clean and --check need to be checkboxes, or we need radio
> buttons with 'force clean', 'check clean', 'allow merge'.. or
> something similar.

Attached patch provides update options more explicitly.
I know this is not needed any more, but I send for something...
No need to apply this patch to main repo, Steve.

Now I'm trying to implement Steve's idea: smart update features.

-- 
Yuki KODAMA
# HG changeset patch
# User Yuki KODAMA <endflow....@gmail.com>
# Date 1253335321 -32400
# Node ID b4d14a118cae3b3efbb4974c8e62379e032a60bd
# Parent  942d421a90bc87b47a90f95b19ac8c7df921f6e2
update: provide options more explicitly

diff --git a/tortoisehg/hgtk/update.py b/tortoisehg/hgtk/update.py
--- a/tortoisehg/hgtk/update.py
+++ b/tortoisehg/hgtk/update.py
@@ -22,6 +22,10 @@
 MODE_NORMAL   = 'normal'
 MODE_UPDATING = 'updating'
 
+OPT_CHECK = 0
+OPT_CLEAN = 1
+OPT_MERGE = 2
+
 class UpdateDialog(gtk.Dialog):
     """ Dialog to update Mercurial repo """
     def __init__(self, rev=None):
@@ -49,23 +53,36 @@
         self.action_area.pack_end(self.updatebtn)
         self.closebtn = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
 
+        # layout table
+        self.table = table = gtk.Table(1, 2)
+        self.vbox.pack_start(table, True, True, 2)
+        # copy from 'thgconfig.py'
+        def addrow(text, widget, expand=True):
+            label = gtk.Label(text)
+            label.set_alignment(1, 0.5)
+            row = table.get_property('n-rows')
+            table.set_property('n-rows', row + 1)
+            table.attach(label, 0, 1, row, row + 1, gtk.FILL, 0, 4, 2)
+            if not expand:
+                hbox = gtk.HBox()
+                hbox.pack_start(widget, False, False)
+                hbox.pack_start(gtk.Label(''))
+                widget = hbox
+            table.attach(widget, 1, 2, row, row + 1, gtk.FILL|gtk.EXPAND, 0, 4, 2)
+
         # revision label & combobox
-        self.revhbox = hbox = gtk.HBox()
-        lbl = gtk.Label(_('Update to:'))
-        hbox.pack_start(lbl, False, False, 2)
         self.revcombo = combo = gtk.combo_box_entry_new_text()
         entry = combo.child
         entry.connect('activate', lambda b: self.update(repo))
         entry.set_width_chars(38)
-        hbox.pack_start(combo, True, True, 2)
-        self.vbox.pack_start(hbox, False, False, 4)
+        addrow(_('Update to:'), self.revcombo)
 
         # fill list of combo
         if rev != None:
             combo.append_text(str(rev))
         else:
             combo.append_text(BRANCH_TIP)
-        combo.set_active(0)
+        combo.set_active(OPT_CHECK)
         for b in repo.branchtags():
             combo.append_text(b)
         tags = list(repo.tags())
@@ -74,9 +91,13 @@
         for t in tags:
             combo.append_text(t)
 
-        # option
-        self.optclean = gtk.CheckButton(_('Overwrite local changes (--clean)'))
-        self.vbox.pack_start(self.optclean, False, False, 4)
+        # options
+        self.optlist = gtk.combo_box_new_text()
+        self.optlist.append_text(_('Check local changes (--check)'))
+        self.optlist.append_text(_('Discard local changes (--clean)'))
+        self.optlist.append_text(_('Allow merge (default)'))
+        self.optlist.set_active(0)
+        addrow(_('Option:'), self.optlist, expand=False)
 
         # prepare to show
         self.updatebtn.grab_focus()
@@ -123,8 +144,8 @@
             raise _('unknown mode name: %s') % mode
         updating = not normal
 
-        self.revhbox.set_sensitive(normal)
-        self.optclean.set_sensitive(normal)
+        self.table.set_sensitive(normal)
+        self.optlist.set_sensitive(normal)
         self.updatebtn.set_property('visible', normal)
         self.closebtn.set_property('visible', normal)
         if cmd:
@@ -134,16 +155,16 @@
     def update(self, repo):
         self.switch_to(MODE_UPDATING)
 
-        clean = self.optclean.get_active()
+        cmdline = ['hg', 'update', '--verbose']
         rev = self.revcombo.get_active_text()
-        cmdline = ['hg', 'update', '--verbose']
         if rev != BRANCH_TIP:
             cmdline.append('--rev')
             cmdline.append(rev)
-        if clean:
+        opt = self.optlist.get_active()
+        if opt == OPT_CHECK:
+            cmdline.append('--check')
+        elif opt == OPT_CLEAN:
             cmdline.append('--clean')
-        else:
-            cmdline.append('--check')
 
         def cmd_done(returncode):
             self.switch_to(MODE_NORMAL, cmd=False)
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to