This is an archive of the discontinued Mercurial Phabricator instance.

narrow: don't do the dirstate dance if ellipses is not enabled
ClosedPublic

Authored by pulkit on Sep 28 2018, 4:58 PM.

Details

Summary

I believe we set dirstate parents to nullid before widening pull because in
ellipses cases, the parent might be stripped off with a new changeset. However
the second ds.setparents() call invalidate my assumption. I am not sure why we
do this. So here is a patch.

This patch also adds tests showing we break nothing in non-ellipses cases.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pulkit created this revision.Sep 28 2018, 4:58 PM

I am not sure about this one. I was unable to think of a reason why we need to do this dirstate dance in non-ellipses cases. @martinvonz @durin42 do you know why we do this?

pulkit edited the summary of this revision. (Show Details)Sep 30 2018, 12:11 PM
pulkit updated this revision to Diff 11502.
In D4788#72444, @pulkit wrote:

I am not sure about this one. I was unable to think of a reason why we need to do this dirstate dance in non-ellipses cases. @martinvonz @durin42 do you know why we do this?

What I usually do when I can't understand why something is needed: remove the code and run tests :) That will often tell you there there was in fact a reason for the code and give you some hints what that reason is. Of course, in some cases it won't tell you that and then you'll have to figure out if it's just untested or actually useless. Do you mean lines 279-280 of hgext/narrow/narrowcommands.py before this patch? If you remove those lines, you will see that test-narrow{,patterns,widen,widen-no-ellipsis}.t fail. You were right about the reason for the first setparent() call, btw. The reason for the code is so we move back to the old commit once we've restored the temporarily stripped commits.

hgext/narrow/narrowcommands.py
254–260

You have add the requirement earlier in the series, so you can just use that here? (I suspect this is a leftover from an earlier version of this patch.)

279–280

I think I'd prefer to not silence developer warnings more than necessary even if that means duplicating the repo.ui.configoverride(overrides, 'widen') (i.e. I'd prefer to keep that together with the wrappedextraprepare block).

In D4788#72444, @pulkit wrote:

I am not sure about this one. I was unable to think of a reason why we need to do this dirstate dance in non-ellipses cases. @martinvonz @durin42 do you know why we do this?

What I usually do when I can't understand why something is needed: remove the code and run tests :) That will often tell you there there was in fact a reason for the code and give you some hints what that reason is. Of course, in some cases it won't tell you that and then you'll have to figure out if it's just untested or actually useless. Do you mean lines 279-280 of hgext/narrow/narrowcommands.py before this patch? If you remove those lines, you will see that test-narrow{,patterns,widen,widen-no-ellipsis}.t fail. You were right about the reason for the first setparent() call, btw. The reason for the code is so we move back to the old commit once we've restored the temporarily stripped commits.

And in non-ellipses cases, we are not stripping commits, so we can easily make this only execute when ellipses is enabled.

hgext/narrow/narrowcommands.py
254–260

I think it's getting confusing for me and suspect bit hard for you too as the series tries to do two quite different yet related things. I will drop the ellipses requirement patch from this series and will first concentrate on the introducing wireprotocol command and the ellipses requirement thing as a seperate series when the wireprotocol one is reviewed and pushed.

pulkit updated this revision to Diff 11517.Oct 1 2018, 12:01 PM
pulkit edited the summary of this revision. (Show Details)Oct 2 2018, 10:19 AM
martinvonz accepted this revision.Oct 2 2018, 12:17 PM
martinvonz added inline comments.
hgext/narrow/narrowcommands.py
286–287

No need to change this, but FYI, I think the config override is one of the context managers that do their setup in __enter__ (not __init__), so it should be fine to assign repo.ui.configoverride(overrides, 'widen') to a variable if wanted to fit this on one line

This revision is now accepted and ready to land.Oct 2 2018, 12:17 PM
This revision was automatically updated to reflect the committed changes.