MercurialQueues patch merging broken?

Giorgos Keramidas keramida at ceid.upatras.gr
Mon May 14 00:03:52 UTC 2007


On 2007-05-14 03:03, Giorgos Keramidas <keramida at ceid.upatras.gr> wrote:
> The first bad revision is:
> changeset:   4418:0532491f7476
> parent:      4416:bb1800a7d7e1
> user:        Bryan O'Sullivan <bos at serpentine.com>
> date:        Tue May 08 12:16:02 2007 -0700
> summary:     MQ: tidy up if a qpush is interrupted.
> 
> The attached patches backout this change, and I've verified that after
> the backout qpush+merge work as before.
> 
> I'm only using the backout locally, because I depend on MQ a lot, but
> Bryan may know how to fix this without the backout, so I've Cc:'ed him
> to the thread now...

Oops.  ENOATTACHMENT: I forgot to attach the patches.

Attached now.


-------------- next part --------------
# HG changeset patch
# User Giorgos Keramidas <keramida at ceid.upatras.gr>
# Date 1179100233 -10800
# Node ID 29e897551c0b11d49f28d0d19bee7be5668bbe31
# Parent  0532491f74767760299350a665bdb1557d494b2a
Backed out changeset 0532491f74767760299350a665bdb1557d494b2a

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -421,27 +421,7 @@ class queue:
         return (True, files, fuzz)
 
     def apply(self, repo, series, list=False, update_status=True,
-              strict=False, patchdir=None, merge=None, wlock=None,
-              all_files={}):
-        tr = repo.transaction()
-        try:
-            ret = self._apply(tr, repo, series, list, update_status,
-                              strict, patchdir, merge, wlock,
-                              all_files=all_files)
-            tr.close()
-            self.save_dirty()
-            return ret
-        except:
-            try:
-                tr.abort()
-            finally:
-                repo.reload()
-                repo.wreload()
-            raise
-
-    def _apply(self, tr, repo, series, list=False, update_status=True,
-               strict=False, patchdir=None, merge=None, wlock=None,
-               all_files={}):
+              strict=False, patchdir=None, merge=None, wlock=None):
         # TODO unify with commands.py
         if not patchdir:
             patchdir = self.path
@@ -449,6 +429,7 @@ class queue:
         if not wlock:
             wlock = repo.wlock()
         lock = repo.lock()
+        tr = repo.transaction()
         n = None
         for patchname in series:
             pushable, reason = self.pushable(patchname)
@@ -473,7 +454,6 @@ class queue:
                 message = '\n'.join(message)
 
             (patcherr, files, fuzz) = self.patch(repo, pf)
-            all_files.update(files)
             patcherr = not patcherr
 
             if merge and files:
@@ -512,6 +492,7 @@ class queue:
                 self.ui.warn("fuzz found when applying patch, stopping\n")
                 err = 1
                 break
+        tr.close()
         return (err, n)
 
     def delete(self, repo, patches, opts):
@@ -846,25 +827,10 @@ class queue:
         else:
             end = self.series.index(patch, start) + 1
         s = self.series[start:end]
-        all_files = {}
-        try:
-            if mergeq:
-                ret = self.mergepatch(repo, mergeq, s, wlock)
-            else:
-                ret = self.apply(repo, s, list, wlock=wlock,
-                                 all_files=all_files)
-        except:
-            self.ui.warn(_('cleaning up working directory...'))
-            node = repo.dirstate.parents()[0]
-            hg.revert(repo, node, None, wlock)
-            unknown = repo.status(wlock=wlock)[4]
-            # only remove unknown files that we know we touched or
-            # created while patching
-            for f in unknown:
-                if f in all_files:
-                    util.unlink(repo.wjoin(f))
-            self.ui.warn(_('done\n'))
-            raise
+        if mergeq:
+            ret = self.mergepatch(repo, mergeq, s, wlock)
+        else:
+            ret = self.apply(repo, s, list, wlock=wlock)
         top = self.applied[-1].name
         if ret[0]:
             self.ui.write("Errors during apply, please fix and refresh %s\n" %
@@ -1825,6 +1791,7 @@ def push(ui, repo, patch=None, **opts):
         ui.warn("merging with queue at: %s\n" % mergeq.path)
     ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
                  mergeq=mergeq)
+    q.save_dirty()
     return ret
 
 def pop(ui, repo, patch=None, **opts):
-------------- next part --------------
# HG changeset patch
# User Giorgos Keramidas <keramida at ceid.upatras.gr>
# Date 1179100357 -10800
# Node ID 3f76ef18b27d6693f6111c9b91e92d2568a9f99b
# Parent  a764edb6fc952e620438a6c7a8cc10bcffe80039
# Parent  29e897551c0b11d49f28d0d19bee7be5668bbe31
Merge backout of 0532491f74767760299350a665bdb1557d494b2a

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -435,27 +435,7 @@ class queue:
         return (True, files, fuzz)
 
     def apply(self, repo, series, list=False, update_status=True,
-              strict=False, patchdir=None, merge=None, wlock=None,
-              all_files={}):
-        tr = repo.transaction()
-        try:
-            ret = self._apply(tr, repo, series, list, update_status,
-                              strict, patchdir, merge, wlock,
-                              all_files=all_files)
-            tr.close()
-            self.save_dirty()
-            return ret
-        except:
-            try:
-                tr.abort()
-            finally:
-                repo.reload()
-                repo.wreload()
-            raise
-
-    def _apply(self, tr, repo, series, list=False, update_status=True,
-               strict=False, patchdir=None, merge=None, wlock=None,
-               all_files={}):
+              strict=False, patchdir=None, merge=None, wlock=None):
         # TODO unify with commands.py
         if not patchdir:
             patchdir = self.path
@@ -463,6 +443,7 @@ class queue:
         if not wlock:
             wlock = repo.wlock()
         lock = repo.lock()
+        tr = repo.transaction()
         n = None
         for patchname in series:
             pushable, reason = self.pushable(patchname)
@@ -487,7 +468,6 @@ class queue:
                 message = '\n'.join(message)
 
             (patcherr, files, fuzz) = self.patch(repo, pf)
-            all_files.update(files)
             patcherr = not patcherr
 
             if merge and files:
@@ -526,7 +506,7 @@ class queue:
                 self.ui.warn("fuzz found when applying patch, stopping\n")
                 err = 1
                 break
-        self.removeundo(repo)
+        tr.close()
         return (err, n)
 
     def delete(self, repo, patches, opts):
@@ -879,25 +859,10 @@ class queue:
         else:
             end = self.series.index(patch, start) + 1
         s = self.series[start:end]
-        all_files = {}
-        try:
-            if mergeq:
-                ret = self.mergepatch(repo, mergeq, s, wlock)
-            else:
-                ret = self.apply(repo, s, list, wlock=wlock,
-                                 all_files=all_files)
-        except:
-            self.ui.warn(_('cleaning up working directory...'))
-            node = repo.dirstate.parents()[0]
-            hg.revert(repo, node, None, wlock)
-            unknown = repo.status(wlock=wlock)[4]
-            # only remove unknown files that we know we touched or
-            # created while patching
-            for f in unknown:
-                if f in all_files:
-                    util.unlink(repo.wjoin(f))
-            self.ui.warn(_('done\n'))
-            raise
+        if mergeq:
+            ret = self.mergepatch(repo, mergeq, s, wlock)
+        else:
+            ret = self.apply(repo, s, list, wlock=wlock)
         top = self.applied[-1].name
         if ret[0]:
             self.ui.write("Errors during apply, please fix and refresh %s\n" %
@@ -1882,6 +1847,7 @@ def push(ui, repo, patch=None, **opts):
         ui.warn("merging with queue at: %s\n" % mergeq.path)
     ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
                  mergeq=mergeq)
+    q.save_dirty()
     return ret
 
 def pop(ui, repo, patch=None, **opts):


More information about the Mercurial-devel mailing list