changeset 4332:4e5e1638b165

mq: don't abort when merging a patch that removes files
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 09 Apr 2007 04:24:17 -0300
parents ce52deed83bc
children 4f721e96f1de
files hgext/mq.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Apr 09 04:24:17 2007 -0300
+++ b/hgext/mq.py	Mon Apr 09 04:24:17 2007 -0300
@@ -457,8 +457,16 @@
             patcherr = not patcherr
 
             if merge and files:
-                # Mark as merged and update dirstate parent info
-                repo.dirstate.update(repo.dirstate.filterfiles(files.keys()), 'm')
+                # Mark as removed/merged and update dirstate parent info
+                removed = []
+                merged = []
+                for f in files:
+                    if os.path.exists(repo.dirstate.wjoin(f)):
+                        merged.append(f)
+                    else:
+                        removed.append(f)
+                repo.dirstate.update(repo.dirstate.filterfiles(removed), 'r')
+                repo.dirstate.update(repo.dirstate.filterfiles(merged), 'm')
                 p1, p2 = repo.dirstate.parents()
                 repo.dirstate.setparents(p1, merge)
             files = patch.updatedir(self.ui, repo, files, wlock=wlock)