overriding defaults (was Re: [PATCH] clone: update to branch ...)

Matt Mackall mpm at selenic.com
Wed Oct 21 16:14:34 CDT 2009


On Wed, 2009-10-21 at 12:42 -0700, John Coomes wrote:
> Matt Mackall (mpm at selenic.com) wrote:
> > On Wed, 2009-10-21 at 11:03 +0200, Adrian Buehlmann wrote:
> > > On 21.10.2009 10:17, Peter Arrenbrecht wrote:
> > > > On Wed, Oct 21, 2009 at 10:09 AM, Adrian Buehlmann <adrian at cadifra.com> wrote:
> > > >> --source-branch sounds good
> > > >>
> > > >> (--source-branch could even be specified in [defaults], provided
> > > >> mercurial would gracefully disregard it without moaning if it had
> > > >> been specified for a non local source repo.)
> > > >>
> > > >> My plan for --source-branch was to do the same as
> > > >>
> > > >>  hg clone -u <branch of src's parent> src dest
> > > >>
> > > >> would do.
> > > >>
> > > >> That aside, we need 'clone -u' for completeness/versatility's sake.
> > > >> We should implement that first and see if it has a chance to make
> > > >> it into 1.4. Matt's messages seem to hint at that.
> > > > 
> > > > I guess `hg clone -u . src dest` should cover most scenarios where
> > > > people would have wanted --source-branch.
> > > >
> > > 
> > > Excellent.
> > > 
> > > So . is in scope. Neat.
> > > 
> > > Compare existing:
> > > 
> > > $ hg -R thg-stable par
> > > changeset:   3536:cd50b769e235
> > > branch:      stable
> > > tag:         0.8.3
> > > user:        Steve Borho <steve at borho.org>
> > > date:        Tue Oct 06 22:07:28 2009 -0500
> > > summary:     hgtk: correct arguments to dispatch() when launching qct
> > > 
> > > $ hg clone -r . thg-stable thg-stable-bug1234
> > > requesting all changes
> > > adding changesets
> > > adding manifests
> > > adding file changes
> > > added 3537 changesets with 5456 changes to 522 files
> > > updating to branch stable
> > > 297 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > > 
> > > Planned (faking output):
> > > 
> > > $ hg clone -u . thg-stable thg-stable-bug1235
> > > updating to branch stable
> > > 297 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > > 
> > > > For folks who want to put "-u ." into [defaults], we should make sure
> > > > that -U still disables it.
> > > 
> > > Good point.
> > > 
> > > -U should gracefully and silently override -u without mercurial moaning
> > > at it (or at least not moan by default, i.e. without --verbose).
> > 
> > Disagree. Again, this is one of the fundamental problems with defaults:
> > once you've set a default, there's no way to bypass it. Don't use 'em.
> 
> Or create a way to override them.  I think mercurial could really
> benefit from an automatic way to allow bool options to be negated.
> E.g., if every bool option foo implicitly defined an additional option
> --no-foo.  ksh getopts supports this concept with -n/+n (ksh only
> accepts short options, though).
> 
> Assuming it was/could be implemented, would something along those
> lines be considered?

Nope. There's no need for it. Just don't set defaults that are contrary
to the real defaults and you never encounter this problem or the
additional complexity of having to support option negation.

You also don't need to worry about scripts and other tools getting
fooled/broken by those defaults. And you also don't need to worry about
your coworkers fat-fingering things on your machine because your
defaults and their defaults don't agree. Which -will happen- if one of
you sets -u . as a default on clone.

Defaults are a bad idea. They are deprecated. Don't use them. Don't
recommend them. Forget they existed. Use aliases.

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial-devel mailing list