Patchwork context: return dirstate parents in workingctx.ancestors()

login
register
mail settings
Submitter Durham Goode
Date Dec. 18, 2014, 5:45 p.m.
Message ID <f0a39e33fba30ad436c8.1418924718@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7169/
State Accepted
Headers show

Comments

Durham Goode - Dec. 18, 2014, 5:45 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1418924234 28800
#      Thu Dec 18 09:37:14 2014 -0800
# Node ID f0a39e33fba30ad436c82dc556b9fbcbc038d3d0
# Parent  3f86fe9bcef0b67d1e5149e66630e46cb515ea90
context: return dirstate parents in workingctx.ancestors()

workingctx.ancestors() was not returning the dirstate parents as part of the
result set. The only place this function is used is for copy detection when
committing a file, and that code already checks the parents manually, so this
change has no affect at the moment.

I found it while playing around with changing how copy detection works.
Sean Farley - Dec. 18, 2014, 6:44 p.m.
Durham Goode writes:

> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1418924234 28800
> #      Thu Dec 18 09:37:14 2014 -0800
> # Node ID f0a39e33fba30ad436c82dc556b9fbcbc038d3d0
> # Parent  3f86fe9bcef0b67d1e5149e66630e46cb515ea90
> context: return dirstate parents in workingctx.ancestors()
>
> workingctx.ancestors() was not returning the dirstate parents as part of the
> result set. The only place this function is used is for copy detection when
> committing a file, and that code already checks the parents manually, so this
> change has no affect at the moment.
>
> I found it while playing around with changing how copy detection works.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -1160,6 +1160,8 @@ class committablectx(basectx):
>          return sorted(self._repo.dirstate.matches(match))
>  
>      def ancestors(self):
> +        for p in self._parents:
> +            yield p

Sure, that makes sense. As I mentioned on IRC, it's easier to filter
something out than to do manual adding or checking.
Matt Mackall - Dec. 22, 2014, 1:52 a.m.
On Thu, 2014-12-18 at 09:45 -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1418924234 28800
> #      Thu Dec 18 09:37:14 2014 -0800
> # Node ID f0a39e33fba30ad436c82dc556b9fbcbc038d3d0
> # Parent  3f86fe9bcef0b67d1e5149e66630e46cb515ea90
> context: return dirstate parents in workingctx.ancestors()

This is queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1160,6 +1160,8 @@  class committablectx(basectx):
         return sorted(self._repo.dirstate.matches(match))
 
     def ancestors(self):
+        for p in self._parents:
+            yield p
         for a in self._repo.changelog.ancestors(
             [p.rev() for p in self._parents]):
             yield changectx(self._repo, a)