hgext/mq.py
changeset 16366 913d1fa61398
parent 16365 5d61e007d957
child 16428 9b26d541e972
--- a/hgext/mq.py	Thu Apr 05 23:52:06 2012 +0900
+++ b/hgext/mq.py	Thu Apr 05 23:52:55 2012 +0900
@@ -950,6 +950,7 @@
         inclsubs = self.checksubstate(repo)
         if inclsubs:
             inclsubs.append('.hgsubstate')
+            substatestate = repo.dirstate['.hgsubstate']
         if opts.get('include') or opts.get('exclude') or pats:
             if inclsubs:
                 pats = list(pats or []) + inclsubs
@@ -959,9 +960,11 @@
                 if f != '.hgsubstate': # .hgsubstate is auto-created
                     raise util.Abort('%s: %s' % (f, msg))
             match.bad = badfn
-            m, a, r, d = repo.status(match=match)[:4]
+            changes = repo.status(match=match)
+            m, a, r, d = changes[:4]
         else:
-            m, a, r, d = self.checklocalchanges(repo, force=True)
+            changes = self.checklocalchanges(repo, force=True)
+            m, a, r, d = changes
         match = scmutil.matchfiles(repo, m + a + r + inclsubs)
         if len(repo[None].parents()) > 1:
             raise util.Abort(_('cannot manage merge changesets'))
@@ -1010,8 +1013,15 @@
                         p.write(msg)
                     if commitfiles:
                         parent = self.qparents(repo, n)
+                        if inclsubs:
+                            if substatestate in 'a?':
+                                changes[1].append('.hgsubstate')
+                            elif substatestate in 'r':
+                                changes[2].append('.hgsubstate')
+                            else: # modified
+                                changes[0].append('.hgsubstate')
                         chunks = patchmod.diff(repo, node1=parent, node2=n,
-                                            match=match, opts=diffopts)
+                                               changes=changes, opts=diffopts)
                         for chunk in chunks:
                             p.write(chunk)
                     p.close()