Patchwork [4,of,4,mergedriver] merge: move almost all change/delete conflicts to resolve phase (BC) (API)

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 5, 2015, 9:49 a.m.
Message ID <20151205184941.54ef09baf045fb1b46179d67@tcha.org>
Download mbox | patch
Permalink /patch/11844/
State Not Applicable
Headers show

Comments

Yuya Nishihara - Dec. 5, 2015, 9:49 a.m.
On Thu, 03 Dec 2015 22:19:44 -0500, Matt Harbison wrote:
> Not sure why, but I'm seeing this on Windows:
> 
> --- c:/Users/Matt/Projects/hg/tests/test-subrepo-missing.t
> +++ c:/Users/Matt/Projects/hg/tests/test-subrepo-missing.t.err
> @@ -64,8 +64,12 @@
>     $ hg up 0
>     remote changed .hgsubstate which local deleted
>     use (c)hanged version or leave (d)eleted? c
> +   subrepository subrepo diverged (local revision: , remote revision:  
> 07f494440405)
> +  (M)erge, keep (l)ocal or keep (r)emote? m
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>     1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>     $ hg st
> +  M .hgsubstate
>     $ ls subrepo
>     a
> 
> I'd write it off because you mention not dealing with .hgsubstate  
> conflicts below, but the test runs fine on Linux.  I didn't try OS X.  I  
> can file a bug if it isn't an issue you are aware of/have a ready fix for.

The problem is that wctx.substate can be stale after batchget or batchremove,
and it is loaded before applyupdates() on Windows.
Matt Harbison - Dec. 6, 2015, 2:51 a.m.
On Sat, 05 Dec 2015 04:49:41 -0500, Yuya Nishihara <yuya@tcha.org> wrote:

> On Thu, 03 Dec 2015 22:19:44 -0500, Matt Harbison wrote:
>> Not sure why, but I'm seeing this on Windows:
>>
>> --- c:/Users/Matt/Projects/hg/tests/test-subrepo-missing.t
>> +++ c:/Users/Matt/Projects/hg/tests/test-subrepo-missing.t.err
>> @@ -64,8 +64,12 @@
>>     $ hg up 0
>>     remote changed .hgsubstate which local deleted
>>     use (c)hanged version or leave (d)eleted? c
>> +   subrepository subrepo diverged (local revision: , remote revision:
>> 07f494440405)
>> +  (M)erge, keep (l)ocal or keep (r)emote? m
>> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>>     1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>>     $ hg st
>> +  M .hgsubstate
>>     $ ls subrepo
>>     a
>>
>> I'd write it off because you mention not dealing with .hgsubstate
>> conflicts below, but the test runs fine on Linux.  I didn't try OS X.  I
>> can file a bug if it isn't an issue you are aware of/have a ready fix  
>> for.
>
> The problem is that wctx.substate can be stale after batchget or  
> batchremove,
> and it is loaded before applyupdates() on Windows.
>
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -1056,6 +1056,11 @@ def applyupdates(repo, actions, wctx, mc
>          progress(_updating, z, item=item, total=numupdates, unit=_files)
>      updated = len(actions['g'])
> +    # not sure this is right, but wctx can have stale cache after
> +    # batchremove/updates, so we have to do something like this:
> +    if removed or updated:
> +        wctx = repo[None]
> +
>      if [a for a in actions['g'] if a[0] == '.hgsubstate']:
>          subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
> @@ -1413,6 +1418,7 @@ def update(repo, node, branchmerge, forc
>                  actions[m] = []
>              actions[m].append((f, args, msg))
> +        wc.substate  # on case-insensitive system, substate is loaded  
> here
>          if not util.checkcase(repo.path):
>              # check collision between files only in p2 for clean update
>              if (not branchmerge and

Fixes it for me, but I have no idea if it is right either.  I'll write up  
the bug like Pierre-Yves asked so we can keep track of it.
Pierre-Yves David - Dec. 6, 2015, 5:49 a.m.
On 12/05/2015 06:51 PM, Matt Harbison wrote:
> On Sat, 05 Dec 2015 04:49:41 -0500, Yuya Nishihara <yuya@tcha.org> wrote:
>
>> On Thu, 03 Dec 2015 22:19:44 -0500, Matt Harbison wrote:
>>> Not sure why, but I'm seeing this on Windows:
>>>
>>> --- c:/Users/Matt/Projects/hg/tests/test-subrepo-missing.t
>>> +++ c:/Users/Matt/Projects/hg/tests/test-subrepo-missing.t.err
>>> @@ -64,8 +64,12 @@
>>>     $ hg up 0
>>>     remote changed .hgsubstate which local deleted
>>>     use (c)hanged version or leave (d)eleted? c
>>> +   subrepository subrepo diverged (local revision: , remote revision:
>>> 07f494440405)
>>> +  (M)erge, keep (l)ocal or keep (r)emote? m
>>> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>>>     1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>>>     $ hg st
>>> +  M .hgsubstate
>>>     $ ls subrepo
>>>     a
>>>
>>> I'd write it off because you mention not dealing with .hgsubstate
>>> conflicts below, but the test runs fine on Linux.  I didn't try OS X.  I
>>> can file a bug if it isn't an issue you are aware of/have a ready fix
>>> for.
>>
>> The problem is that wctx.substate can be stale after batchget or
>> batchremove,
>> and it is loaded before applyupdates() on Windows.
>>
>> --- a/mercurial/merge.py
>> +++ b/mercurial/merge.py
>> @@ -1056,6 +1056,11 @@ def applyupdates(repo, actions, wctx, mc
>>          progress(_updating, z, item=item, total=numupdates, unit=_files)
>>      updated = len(actions['g'])
>> +    # not sure this is right, but wctx can have stale cache after
>> +    # batchremove/updates, so we have to do something like this:
>> +    if removed or updated:
>> +        wctx = repo[None]
>> +
>>      if [a for a in actions['g'] if a[0] == '.hgsubstate']:
>>          subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
>> @@ -1413,6 +1418,7 @@ def update(repo, node, branchmerge, forc
>>                  actions[m] = []
>>              actions[m].append((f, args, msg))
>> +        wc.substate  # on case-insensitive system, substate is loaded
>> here
>>          if not util.checkcase(repo.path):
>>              # check collision between files only in p2 for clean update
>>              if (not branchmerge and
>
> Fixes it for me, but I have no idea if it is right either.  I'll write
> up the bug like Pierre-Yves asked so we can keep track of it.

Nice, please, send a proper patch and I'll take it.

Patch

--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1056,6 +1056,11 @@  def applyupdates(repo, actions, wctx, mc
         progress(_updating, z, item=item, total=numupdates, unit=_files)
     updated = len(actions['g'])
 
+    # not sure this is right, but wctx can have stale cache after
+    # batchremove/updates, so we have to do something like this:
+    if removed or updated:
+        wctx = repo[None]
+
     if [a for a in actions['g'] if a[0] == '.hgsubstate']:
         subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
 
@@ -1413,6 +1418,7 @@  def update(repo, node, branchmerge, forc
                 actions[m] = []
             actions[m].append((f, args, msg))
 
+        wc.substate  # on case-insensitive system, substate is loaded here
         if not util.checkcase(repo.path):
             # check collision between files only in p2 for clean update
             if (not branchmerge and