[PATCH 2 of 8] hg: warn if repo.ui is passed when creating a peer or a localrepo
mpm at selenic.com
Mon Oct 22 16:01:43 CDT 2012
On Mon, 2012-10-22 at 11:55 +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe at besonet.ch>
> # Date 1349372803 -7200
> # Node ID a20a8a4dd3c5dc4d25cb38d04bff96e75b50e95f
> # Parent 75053afab605dfef2f51075550fcebf6e10f80db
> hg: warn if repo.ui is passed when creating a peer or a localrepo
+ src.write_err(' PROGRAMMER WARNING: %s\n' % warnmsg)
+ NameError: global name 'src' is not defined
> For not getting the configuration of another repo, baseui has to be used when
> crating a new repository (or a new peer). Therefore we warn the programmer if
> the ui of a repo is passed.
> Because a user also sees this warning (when there is a programming error), the
> message is short.
Ugh, no. Let's not pester end users with things they're powerless to
fix. That anti-pattern is best left to Python core developers.
> diff -r 75053afab605 -r a20a8a4dd3c5 mercurial/hg.py
> --- a/mercurial/hg.py Don Okt 04 19:46:42 2012 +0200
> +++ b/mercurial/hg.py Don Okt 04 19:46:43 2012 +0200
> @@ -587,6 +587,7 @@
> src = src.ui # copy target options from repo
> else: # assume it's a global ui object
> dst = src.copy() # keep all global options
> + src.notinrepo('pass repo (not repo.ui) to hg.peer')
We make a point of having the ui object have no idea that repo objects
exist ("layering"). This runs against that, which makes it a "layering
Instead, it might be friendlier all around to have the peer constuctor
look for ui.baseui itself.
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel