[Pull Request] Remove uses of hasattr

Augie Fackler durin42 at gmail.com
Mon Jul 25 22:44:55 CDT 2011


A while ago I asked about removing hasattr because of surprising behavior, and the general consensus seemed to be that I should go ahead and make a run at it. While on a flight today I finally finished the job. It's a really long patch queue, so instead of mailing it I'm submitting it as a pull request. You can see the changesets here:

http://code.google.com/p/durin42-hg-hasattr-ectomy/source/list?num=50

and if you want to pull/incoming, the URL you want is

http://code.google.com/p/durin42-hg-hasattr-ectomy/

It's 38 patches in total. I tried to batch them for easy reviewing. Ones of note are:

Duplicate less code when checking to see if we're in a frozen binary:
http://code.google.com/p/durin42-hg-hasattr-ectomy/source/detail?r=b6581ed193f374f2d38a4cad5ad25640f304ce1f

These two attack a particular hasattr() use case in the entire codebase since it's mechanically fixable:
http://code.google.com/p/durin42-hg-hasattr-ectomy/source/detail?r=f4814ebb99f75812a55776ed3a306883432935dd
http://code.google.com/p/durin42-hg-hasattr-ectomy/source/detail?r=235f15a351866c2c084d4e88b89f7b69fafa66da

and this last one of note adds modules to the blacklist because of those side effects of hasattr() I warned about:
http://code.google.com/p/durin42-hg-hasattr-ectomy/source/detail?r=57c2982d243bd6651e1d9e3f138f46b27b32828f

Other than that, it's mostly mechanical replacement, with a few migrations to getattr() so we can avoid looking up the attribute twice. I tried to make the patches all tiny so they'd be easy to review.


More information about the Mercurial-devel mailing list