Patchwork [2,of,2,V3] patch: use scmutil.marktouched instead of scmutil.addremove

login
register
mail settings
Submitter Siddharth Agarwal
Date May 8, 2013, 10:18 p.m.
Message ID <9cc6da7262133d9ff5f4.1368051516@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1595/
State Accepted, archived
Headers show

Comments

Siddharth Agarwal - May 8, 2013, 10:18 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1365108321 25200
#      Thu Apr 04 13:45:21 2013 -0700
# Node ID 9cc6da7262133d9ff5f49e6fcfb67d895f98ddd3
# Parent  80ac5083bbebdc64b81656510278dbc830cf0e13
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.
Augie Fackler - May 9, 2013, 1:42 p.m.
On Wed, May 08, 2013 at 03:18:36PM -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1365108321 25200
> #      Thu Apr 04 13:45:21 2013 -0700
> # Node ID 9cc6da7262133d9ff5f49e6fcfb67d895f98ddd3
> # Parent  80ac5083bbebdc64b81656510278dbc830cf0e13
> patch: use scmutil.marktouched instead of scmutil.addremove

Queued all 6, as I don't see patches 1-4 of v1 queued anywhere. Thanks!

>
> 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.
>
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -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") %

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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") %