patch: use scmutil.marktouched instead of scmutil.addremove
authorSiddharth Agarwal <sid0@fb.com>
Thu, 04 Apr 2013 13:45:21 -0700
changeset 19155 0b3689a08df5
parent 19154 0c7cf411b390
child 19157 113681bbef9e
patch: use scmutil.marktouched instead of scmutil.addremove addremove required paths relative to the cwd, which meant a lot of extra code that transformed paths into relative ones. That code is now gone as well.
mercurial/patch.py
--- a/mercurial/patch.py	Thu Apr 04 13:38:28 2013 -0700
+++ b/mercurial/patch.py	Thu Apr 04 13:45:21 2013 -0700
@@ -481,7 +481,7 @@
 
     def close(self):
         wctx = self.repo[None]
-        addremoved = set(self.changed)
+        changed = set(self.changed)
         for src, dst in self.copied:
             scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst)
         if self.removed:
@@ -491,14 +491,10 @@
                     # File was deleted and no longer belongs to the
                     # dirstate, it was probably marked added then
                     # deleted, and should not be considered by
-                    # addremove().
-                    addremoved.discard(f)
-        if addremoved:
-            cwd = self.repo.getcwd()
-            if cwd:
-                addremoved = [util.pathto(self.repo.root, cwd, f)
-                              for f in addremoved]
-            scmutil.addremove(self.repo, addremoved, similarity=self.similarity)
+                    # marktouched().
+                    changed.discard(f)
+        if changed:
+            scmutil.marktouched(self.repo, changed, self.similarity)
         return sorted(self.changed)
 
 class filestore(object):
@@ -1397,12 +1393,7 @@
                 ui.warn(line + '\n')
     finally:
         if files:
-            cfiles = list(files)
-            cwd = repo.getcwd()
-            if cwd:
-                cfiles = [util.pathto(repo.root, cwd, f)
-                          for f in cfiles]
-            scmutil.addremove(repo, cfiles, similarity=similarity)
+            scmutil.marktouched(repo, files, similarity)
     code = fp.close()
     if code:
         raise PatchError(_("patch command failed: %s") %