# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1269006952 -32400
# Branch stable
# Node ID 437f9ffbd168d533928f2a4b4424514278d7d75e
# Parent  d38af8bd2e69502d45302d856e85237b1c38e8db
thgmq: fix case of reordering patch preceded by guarded one

MQ reorder fails in the following case:

   0 foo  # guarded, unapplied
   1 bar  # applied
     ---
   2 baz  # unapplied

Moving 'baz' up raises exception and breaks '.hg/patches/series'.

diff --git a/tortoisehg/hgtk/thgmq.py b/tortoisehg/hgtk/thgmq.py
--- a/tortoisehg/hgtk/thgmq.py
+++ b/tortoisehg/hgtk/thgmq.py
@@ -476,12 +476,14 @@ class MQWidget(gtk.VBox):
                 if maxidx < idx:
                     maxidx = idx
 
-        # find index of first unapplied patch in TreeView
+        # find index of first unapplied patch after last applied one in 
TreeView
+        uminidx = None
         for i, row in enumerate(model):
-            if self.is_unapplied(row[MQ_NAME]):
+            if uminidx is None and self.is_unapplied(row[MQ_NAME]):
                 uminidx = i
-                break
-        else:
+            elif self.is_applied(row[MQ_NAME]):
+                uminidx = None
+        if uminidx is None:
             return False
 
         # check whether operation is possible

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