Patchwork log: prefer 'wctx' over 'pctx' for working context

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 19, 2015, 4:19 p.m.
Message ID <ef0698d6c3bb363ec4d7.1426781989@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8164/
State Superseded
Commit 1925769b4ff831a91325601a8a2cccdf7d3183ea
Headers show

Comments

Martin von Zweigbergk - March 19, 2015, 4:19 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1426740265 25200
#      Wed Mar 18 21:44:25 2015 -0700
# Node ID ef0698d6c3bb363ec4d7face69409f6555d0e7c2
# Parent  5cb459dc32d209653a3e5d77749cf989ab9a51e4
log: prefer 'wctx' over 'pctx' for working context
Martin von Zweigbergk - March 19, 2015, 4:24 p.m.
On Thu, Mar 19, 2015 at 9:19 AM Martin von Zweigbergk <martinvonz@google.com>
wrote:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1426740265 25200
> #      Wed Mar 18 21:44:25 2015 -0700
> # Node ID ef0698d6c3bb363ec4d7face69409f6555d0e7c2
> # Parent  5cb459dc32d209653a3e5d77749cf989ab9a51e4
> log: prefer 'wctx' over 'pctx' for working context
>
> diff -r 5cb459dc32d2 -r ef0698d6c3bb hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py     Tue Oct 28 22:32:18 2014 -0700
> +++ b/hgext/largefiles/overrides.py     Wed Mar 18 21:44:25 2015 -0700
> @@ -376,8 +376,8 @@
>      # The magic matchandpats override should be used for case (1) but not
> for
>      # case (2).
>      def overridemakelogfilematcher(repo, pats, opts):
> -        pctx = repo[None]
> -        match, pats = oldmatchandpats(pctx, pats, opts)
> +        wctx = repo[None]
> +        match, pats = oldmatchandpats(wctx, pats, opts)
>          return lambda rev: match
>
>      oldmatchandpats = installmatchandpatsfn(overridematchandpats)
> diff -r 5cb459dc32d2 -r ef0698d6c3bb mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py      Tue Oct 28 22:32:18 2014 -0700
> +++ b/mercurial/cmdutil.py      Wed Mar 18 21:44:25 2015 -0700
> @@ -1924,12 +1924,12 @@
>      # _matchfiles() revset but walkchangerevs() builds its matcher with
>      # scmutil.match(). The difference is input pats are globbed on
>      # platforms without shell expansion (windows).
> -    pctx = repo[None]
> -    match, pats = scmutil.matchandpats(pctx, pats, opts)
> +    wctx = repo[None]
> +    match, pats = scmutil.matchandpats(wctx, pats, opts)
>      slowpath = match.anypats() or (match.files() and opts.get('removed'))
>      if not slowpath:
>          for f in match.files():
> -            if follow and f not in pctx:
> +            if follow and f not in wctx:
>

Hmm... perhaps this was meant to be repo['.']? The error message soon after
says "cannot follow file not in parent revision". Durham, you touched this
code a while back (July 2014), do you have any idea?


>                  # If the file exists, it may be a directory, so let it
>                  # take the slow path.
>                  if os.path.exists(repo.wjoin(f)):
>
Durham Goode - March 19, 2015, 4:33 p.m.
On 3/19/15 9:24 AM, Martin von Zweigbergk wrote:
>
>
> On Thu, Mar 19, 2015 at 9:19 AM Martin von Zweigbergk 
> <martinvonz@google.com <mailto:martinvonz@google.com>> wrote:
>
>     # HG changeset patch
>     # User Martin von Zweigbergk <martinvonz@google.com
>     <mailto:martinvonz@google.com>>
>     # Date 1426740265 25200
>     #      Wed Mar 18 21:44:25 2015 -0700
>     # Node ID ef0698d6c3bb363ec4d7face69409f6555d0e7c2
>     # Parent  5cb459dc32d209653a3e5d77749cf989ab9a51e4
>     log: prefer 'wctx' over 'pctx' for working context
>
>     diff -r 5cb459dc32d2 -r ef0698d6c3bb mercurial/cmdutil.py
>     --- a/mercurial/cmdutil.py      Tue Oct 28 22:32:18 2014 -0700
>     +++ b/mercurial/cmdutil.py      Wed Mar 18 21:44:25 2015 -0700
>     @@ -1924,12 +1924,12 @@
>          # _matchfiles() revset but walkchangerevs() builds its
>     matcher with
>          # scmutil.match(). The difference is input pats are globbed on
>          # platforms without shell expansion (windows).
>     -    pctx = repo[None]
>     -    match, pats = scmutil.matchandpats(pctx, pats, opts)
>     +    wctx = repo[None]
>     +    match, pats = scmutil.matchandpats(wctx, pats, opts)
>          slowpath = match.anypats() or (match.files() and
>     opts.get('removed'))
>          if not slowpath:
>              for f in match.files():
>     -            if follow and f not in pctx:
>     +            if follow and f not in wctx:
>
>
> Hmm... perhaps this was meant to be repo['.']? The error message soon 
> after says "cannot follow file not in parent revision". Durham, you 
> touched this code a while back (July 2014), do you have any idea?
>
Yea, the message seems a bit wrong (but it's the message from prior to 
my change too).  Functionality wise I could see this going either way 
(repo['.'] or repo[None]).  Probably not a big deal though.
Martin von Zweigbergk - March 19, 2015, 4:41 p.m.
On Thu, Mar 19, 2015 at 9:38 AM Durham Goode <durham@fb.com> wrote:

>
>
> On 3/19/15 9:24 AM, Martin von Zweigbergk wrote:
>
>
>
> On Thu, Mar 19, 2015 at 9:19 AM Martin von Zweigbergk <
> martinvonz@google.com> wrote:
>
>> # HG changeset patch
>> # User Martin von Zweigbergk <martinvonz@google.com>
>> # Date 1426740265 25200
>> #      Wed Mar 18 21:44:25 2015 -0700
>> # Node ID ef0698d6c3bb363ec4d7face69409f6555d0e7c2
>> # Parent  5cb459dc32d209653a3e5d77749cf989ab9a51e4
>> log: prefer 'wctx' over 'pctx' for working context
>>
>>     diff -r 5cb459dc32d2 -r ef0698d6c3bb mercurial/cmdutil.py
>> --- a/mercurial/cmdutil.py      Tue Oct 28 22:32:18 2014 -0700
>> +++ b/mercurial/cmdutil.py      Wed Mar 18 21:44:25 2015 -0700
>> @@ -1924,12 +1924,12 @@
>>      # _matchfiles() revset but walkchangerevs() builds its matcher with
>>      # scmutil.match(). The difference is input pats are globbed on
>>      # platforms without shell expansion (windows).
>> -    pctx = repo[None]
>> -    match, pats = scmutil.matchandpats(pctx, pats, opts)
>> +    wctx = repo[None]
>> +    match, pats = scmutil.matchandpats(wctx, pats, opts)
>>      slowpath = match.anypats() or (match.files() and opts.get('removed'))
>>      if not slowpath:
>>          for f in match.files():
>> -            if follow and f not in pctx:
>> +            if follow and f not in wctx:
>>
>
>  Hmm... perhaps this was meant to be repo['.']? The error message soon
> after says "cannot follow file not in parent revision". Durham, you touched
> this code a while back (July 2014), do you have any idea?
>
>
> Yea, the message seems a bit wrong (but it's the message from prior to my
> change too).  Functionality wise I could see this going either way
> (repo['.'] or repo[None]).  Probably not a big deal though.
>

I think I'll do something else here, so please ignore this patch.

The way it currently works, you "hg log --follow contrib/mergetools.hgrc"
(a deleted file) fails, but if you touch the file first, it "works",
although I don't think it actually follow. We should probably change the
check.

Patch

diff -r 5cb459dc32d2 -r ef0698d6c3bb hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Tue Oct 28 22:32:18 2014 -0700
+++ b/hgext/largefiles/overrides.py	Wed Mar 18 21:44:25 2015 -0700
@@ -376,8 +376,8 @@ 
     # The magic matchandpats override should be used for case (1) but not for
     # case (2).
     def overridemakelogfilematcher(repo, pats, opts):
-        pctx = repo[None]
-        match, pats = oldmatchandpats(pctx, pats, opts)
+        wctx = repo[None]
+        match, pats = oldmatchandpats(wctx, pats, opts)
         return lambda rev: match
 
     oldmatchandpats = installmatchandpatsfn(overridematchandpats)
diff -r 5cb459dc32d2 -r ef0698d6c3bb mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Tue Oct 28 22:32:18 2014 -0700
+++ b/mercurial/cmdutil.py	Wed Mar 18 21:44:25 2015 -0700
@@ -1924,12 +1924,12 @@ 
     # _matchfiles() revset but walkchangerevs() builds its matcher with
     # scmutil.match(). The difference is input pats are globbed on
     # platforms without shell expansion (windows).
-    pctx = repo[None]
-    match, pats = scmutil.matchandpats(pctx, pats, opts)
+    wctx = repo[None]
+    match, pats = scmutil.matchandpats(wctx, pats, opts)
     slowpath = match.anypats() or (match.files() and opts.get('removed'))
     if not slowpath:
         for f in match.files():
-            if follow and f not in pctx:
+            if follow and f not in wctx:
                 # If the file exists, it may be a directory, so let it
                 # take the slow path.
                 if os.path.exists(repo.wjoin(f)):