This is an archive of the discontinued Mercurial Phabricator instance.

state: raise ProgrammingError if an invalid key is being accessed
AbandonedPublic

Authored by pulkit on Mar 3 2018, 2:19 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

pulkit created this revision.Mar 3 2018, 2:19 PM

Hmm, really? Do any states have optional entries that would make this awkward?

Hmm, really? Do any states have optional entries that would make this awkward?

Nope, but I wanted to be safe here raising a ProgrammingError instead of KeyError.

yuja added a subscriber: yuja.Mar 4 2018, 12:47 PM
In D2596#42678, @pulkit wrote:

Hmm, really? Do any states have optional entries that would make this awkward?

Nope, but I wanted to be safe here raising a ProgrammingError instead of KeyError.

I don't follow, but what if the state file was written by old hg client where some new keys
were missing, and read by new client? Perhaps we'll have to support that scenario.

mercurial/state.py
61

Nit: no need to make a ProgrammingError translatable.

pulkit added a comment.Mar 4 2018, 3:50 PM
In D2596#42818, @yuja wrote:
In D2596#42678, @pulkit wrote:

Hmm, really? Do any states have optional entries that would make this awkward?

Nope, but I wanted to be safe here raising a ProgrammingError instead of KeyError.

I don't follow, but what if the state file was written by old hg client where some new keys
were missing, and read by new client? Perhaps we'll have to support that scenario.

I am going to drop this patch for now so in cases which Yuya mentioned, we can catch the KeyError to realize that key is not available.

pulkit abandoned this revision.Mar 19 2018, 4:45 AM