Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Matt Mackall <mpm <at> selenic.com>
Subject: Re: [PATCH 2 of 8] hg: warn if repo.ui is passed when creating a peer or a localrepo
Newsgroups: gmane.comp.version-control.mercurial.devel
Date: Monday 22nd October 2012 21:01:43 UTC (over 5 years ago)
On Mon, 2012-10-22 at 11:55 +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg 
> # Date 1349372803 -7200
> # Node ID a20a8a4dd3c5dc4d25cb38d04bff96e75b50e95f
> # Parent  75053afab605dfef2f51075550fcebf6e10f80db
> hg: warn if repo.ui is passed when creating a peer or a localrepo

Fails tests:

+      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
violation".

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.
 
CD: 3ms