This is an archive of the discontinued Mercurial Phabricator instance.

rebase: refactor logic to read rebasestate in a separate function
ClosedPublic

Authored by pulkit on Jul 1 2018, 4:32 PM.

Details

Summary

This will help us in plugging the use of state.cmdstate() to read rebasestate.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

pulkit created this revision.Jul 1 2018, 4:32 PM
This revision was automatically updated to reflect the committed changes.
yuja added a subscriber: yuja.Jul 2 2018, 8:45 AM

Queued, thanks.

f = repo.vfs("rebasestate")
for i, l in enumerate(f.read().splitlines()):
    if i == 0:
  • originalwd = repo[l].rev()

+ data['originalwd'] = repo[l].rev()

FWIW, I don't have any better idea to keep old hg not crash with new state
file, other than:

a. use separate file (e.g. "rebasestate2") and leave "rebasestate" in old

format (or make it an empty file to trigger error.)

b. abuse repo[l].rev() to abort with lookup error with somewhat descriptive

message.
pulkit added a comment.Jul 2 2018, 2:18 PM
In D3873#60501, @yuja wrote:

Queued, thanks.

f = repo.vfs("rebasestate")
for i, l in enumerate(f.read().splitlines()):
    if i == 0:
  • originalwd = repo[l].rev()

+ data['originalwd'] = repo[l].rev()

FWIW, I don't have any better idea to keep old hg not crash with new state
file, other than:
a. use separate file (e.g. "rebasestate2") and leave "rebasestate" in old

format (or make it an empty file to trigger error.)

Yeah, I was preventing this for a long time but feels like I can't anymore. How about having a .hg/state/ where we will have our new histedit and rebase state files?

b. abuse repo[l].rev() to abort with lookup error with somewhat descriptive

message.

This is more bad. Let's not do that.

yuja added a comment.Jul 3 2018, 8:02 AM
> FWIW, I don't have any better idea to keep old hg not crash with new state
>  file, other than:
>
>   a. use separate file (e.g. "rebasestate2") and leave "rebasestate" in old
>      format (or make it an empty file to trigger error.)
Yeah, I was preventing this for a long time but feels like I can't anymore.
How about having a `.hg/state/` where we will have our new histedit and
rebase state files?

A separate directory wouldn't make the situation better. We can't stop writing
a v1 state file anyway since missing v1 state file means "no rebase in progress"
in old hg versions.