This is an archive of the discontinued Mercurial Phabricator instance.

debugcommands: replace opts.get('foo') by opts['foo']
AbandonedPublic

Authored by martinvonz on Dec 14 2017, 6:35 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

martinvonz created this revision.Dec 14 2017, 6:35 PM
yuja added a subscriber: yuja.Dec 15 2017, 8:29 AM

Queued the first three patches, but I'm not certain about this. Sometimes we
do the reverse change for ease of calling command function as a plain function.

In D1694#29072, @yuja wrote:

Queued the first three patches, but I'm not certain about this. Sometimes we
do the reverse change for ease of calling command function as a plain function.

I think it's probably okay for debug commands, those are pretty rare to use as a function aren't they?

yuja added a comment.Jan 12 2018, 7:17 AM

I think it's probably okay for debug commands, those are pretty rare to use as a function aren't they?

Yeah, it's okay, but why do we apply a different rule to debug commands?

If we take this, I'd rather replace .get() by [] everywhere to blame third-party
tools which don't pass all options.

I don't feel strongly either. Martin, if you want to pursue this (which seems fine to me) why not make ocmmands.py consistent as well?

pulkit added a subscriber: pulkit.Jun 14 2018, 3:51 PM

@martinvonz do you want to pursue this or can this be mark as abandoned? (Trying to close differentials which are no longer required)

martinvonz abandoned this revision.Jun 14 2018, 6:02 PM
pulkit added a comment.EditedNov 30 2018, 11:37 AM
In D1694#29072, @yuja wrote:

Sometimes we do the reverse change for ease of calling command function as a plain function.

Just for record, today I hit the problem where some command is using opts[''] instead of opts.get() and I was calling command function as plain function leading me to KeyError.

In D1694#79416, @pulkit wrote:
In D1694#29072, @yuja wrote:

Sometimes we do the reverse change for ease of calling command function as a plain function.

Just for record, today I hit the problem where some command is using opts[''] instead of opts.get() and I was calling command function as plain function leading me to KeyError.

It would be nice to have some official API to call a command as a function. Such function would do the same processing as the dispatch logic to validate input and install default value.