Patchwork [6,of,6] patch: use scmutil.touch instead of scmutil.addremove

login
register
mail settings
Submitter Siddharth Agarwal
Date May 7, 2013, 12:12 a.m.
Message ID <7db039e4516ec4bcdb6f.1367885552@sid0x220>
Download mbox | patch
Permalink /patch/1576/
State Changes Requested, archived
Delegated to: Augie Fackler
Headers show

Comments

Siddharth Agarwal - May 7, 2013, 12:12 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1365108321 25200
#      Thu Apr 04 13:45:21 2013 -0700
# Node ID 7db039e4516ec4bcdb6fabb7f3fd48191249949b
# Parent  486f0b01206477869f6a6946961fea0b2e776b12
patch: use scmutil.touch 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 7, 2013, 5:44 p.m.
On Mon, May 06, 2013 at 05:12:32PM -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 7db039e4516ec4bcdb6fabb7f3fd48191249949b
> # Parent  486f0b01206477869f6a6946961fea0b2e776b12
> patch: use scmutil.touch instead of scmutil.addremove

Other than the name of touch (which I still find confusing), series LGTM.

>
> 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 -r 486f0b012064 -r 7db039e4516e 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 @@ class workingbackend(fsbackend):
>
>      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 @@ class workingbackend(fsbackend):
>                      # 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)
> +                    # touch().
> +                    changed.discard(f)
> +        if changed:
> +            scmutil.touch(self.repo, changed, self.similarity)
>          return sorted(self.changed)
>
>  class filestore(object):
> @@ -1397,12 +1393,7 @@ def _externalpatch(ui, repo, patcher, pa
>                  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.touch(repo, files, similarity)
>      code = fp.close()
>      if code:
>          raise PatchError(_("patch command failed: %s") %
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Siddharth Agarwal - May 8, 2013, 5:53 a.m.
On 05/07/2013 10:44 AM, Augie Fackler wrote:
> On Mon, May 06, 2013 at 05:12:32PM -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 7db039e4516ec4bcdb6fabb7f3fd48191249949b
>> # Parent  486f0b01206477869f6a6946961fea0b2e776b12
>> patch: use scmutil.touch instead of scmutil.addremove
> Other than the name of touch (which I still find confusing), series LGTM.

Perhaps you could crew 1-4 then, and we can discuss the name for it 
separately.

markhandled sounds reasonable. What about marktouched?
Augie Fackler - May 8, 2013, 3:03 p.m.
On May 8, 2013, at 1:53 AM, Siddharth Agarwal <sid0@fb.com> wrote:

> On 05/07/2013 10:44 AM, Augie Fackler wrote:
>> On Mon, May 06, 2013 at 05:12:32PM -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 7db039e4516ec4bcdb6fabb7f3fd48191249949b
>>> # Parent  486f0b01206477869f6a6946961fea0b2e776b12
>>> patch: use scmutil.touch instead of scmutil.addremove
>> Other than the name of touch (which I still find confusing), series LGTM.
> 
> Perhaps you could crew 1-4 then, and we can discuss the name for it separately.
> 
> markhandled sounds reasonable. What about marktouched?

I'm also fine with marktouched. How about resend the series with that fix, and I'll crew the whole thing? Feel free to put me on the CC line so it jumps to my inbox.

Patch

diff -r 486f0b012064 -r 7db039e4516e 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 @@  class workingbackend(fsbackend):
 
     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 @@  class workingbackend(fsbackend):
                     # 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)
+                    # touch().
+                    changed.discard(f)
+        if changed:
+            scmutil.touch(self.repo, changed, self.similarity)
         return sorted(self.changed)
 
 class filestore(object):
@@ -1397,12 +1393,7 @@  def _externalpatch(ui, repo, patcher, pa
                 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.touch(repo, files, similarity)
     code = fp.close()
     if code:
         raise PatchError(_("patch command failed: %s") %