# HG changeset patch
# User Wagner Bruna <wbr...@yahoo.com>
# Date 1254758040 10800
# Node ID 9ea3e9ac237d231654628aa0c5bbd77e03585cb9
# Parent  f0acd74b033f8704aef27867783cad1577c36d42
mq: support the qup extension

Allows making an unapplied patch the next in the series.

diff --git a/tortoisehg/hgtk/thgmq.py b/tortoisehg/hgtk/thgmq.py
--- a/tortoisehg/hgtk/thgmq.py
+++ b/tortoisehg/hgtk/thgmq.py
@@ -10,6 +10,8 @@
 import gobject
 import pango
 
+from mercurial import extensions
+
 from tortoisehg.util.i18n import _
 from tortoisehg.util import hglib
 
@@ -77,6 +79,12 @@
         self.repo = repo
         self.mqloaded = hasattr(repo, 'mq')
 
+        try:
+            extensions.find('qup')
+            self.hasqup = True
+        except KeyError:
+            self.hasqup = False
+
         # top toolbar
         tbar = gtklib.SlimToolbar(tooltips)
 
@@ -371,6 +379,17 @@
         cmdline = ['hg', 'qfold', patch]
         self.cmd.execute(cmdline, self.cmd_done)
 
+    def mknext(self, patch):
+        """
+        [MQ] Execute 'qup patch'
+
+        patch: the patch name or an index to specify the patch.
+        """
+        if not (self.hasqup and patch and self.is_operable()):
+            return
+        cmdline = ['hg', 'qup', patch]
+        self.cmd.execute(cmdline, self.cmd_done)
+
     def has_patch(self):
         """ return True if MQ has applicable patch """
         if self.mqloaded:
@@ -383,6 +402,12 @@
             return len(self.repo.mq.applied) > 0
         return False
 
+    def number_applied(self):
+        """ return the number of applied patches """
+        if self.mqloaded:
+            return len(self.repo.mq.applied)
+        return 0
+
     def is_operable(self):
         """ return True if MQ is operable """
         if self.mqloaded:
@@ -498,6 +523,7 @@
         is_qtip = self.is_qtip(row[MQ_NAME])
         is_qparent = row[MQ_INDEX] == INDEX_QPARENT
         is_applied = row[MQ_STATUS] == 'A'
+        is_next = row[MQ_INDEX] == self.number_applied()
 
         if is_operable and not is_qtip and (not is_qparent or has_applied):
             append(_('_goto'), self.goto_activated)
@@ -510,6 +536,8 @@
             append(_('delete --keep'), self.delete_keep_activated)
             if has_applied and not is_qparent:
                 append(_('f_old'), self.fold_activated)
+            if self.hasqup and not is_next:
+                append(_('make it _next'), self.mknext_activated)
 
         if len(menu.get_children()) > 0:
             menu.show_all()
@@ -667,3 +695,6 @@
 
     def fold_activated(self, menuitem, row):
         self.qfold(row[MQ_NAME])
+
+    def mknext_activated(self, menuitem, row):
+        self.mknext(row[MQ_NAME])

------------------------------------------------------------------------------
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