[PATCH RFC] commands: add 'setup' command to allow automatic hgrc configuration

Mathias De Maré mathias.demare at gmail.com
Thu Mar 12 13:53:36 CDT 2015


On Thu, Mar 12, 2015 at 7:30 PM, Matt Mackall <mpm at selenic.com> wrote:

> On Thu, 2015-03-12 at 18:24 +0100, mathias.demare at gmail.com wrote:
> > # HG changeset patch
> > # User Mathias De Maré <mathias.demare at gmail.com>
> > # Date 1426162870 -3600
> > #      Thu Mar 12 13:21:10 2015 +0100
> > # Node ID 0de0fc66a20a5f0658a6c6f1f5de20d4705f3de1
> > # Parent  7cf9a9e0cf893e7ae82dc576a03c843fd6640438
> > commands: add 'setup' command to allow automatic hgrc configuration
>
> I'm not terribly excited about this. It just delays people learning how
> to edit their config file which is not that hard and much more useful in
> the long run.
>
I agree that users do need to learn that in the long run. I was mostly
thinking about this towards first impressions for users, and to allow them
to enable some useful items which they otherwise don't know exist.
I'd like to find a way to make the user experience for new users as good as
possible.

Each of your comments below raises a good point, I'll need to fix those
things. However, is it useful in general to continue with this (seeing as
you're indeed not too enthousiastic about this), or should I just drop it?

>
> > I wasn't too sure about using the first path
> > listed in the userhgrc, not sure if that's the best approach.
>
> It should agree with whatever "hg conf -e" does when no config exists.
> But maybe you don't know about that?
>
Oh, good point, I should've looked there. Perhaps showing the result at the
end (like with 'hg conf -e') would be useful as well.

>
> > - Popping up a merge window in case a user already has a .hgrc.
> >   This could allow the user to do the merge,
> >   and avoids us having to mess with editing configs
> >   (this was a very good idea by smf).
>
> Terrifying. I'm the type of user who's intimidated by editing a config
> file.. so you're going to launch into a program that shows me four
> different copies of that file all at once? I don't see how that's
> helping.
>
Again a good point, perhaps not a good thing to implement after all.

>
> > + at command('setup', [])
> > +def setup(ui, repo):
> > +    """run a setup to generate a Mercurial configuration
> > +
> > +    Answer a few questions to generate a basic Mercurial configuration.
> > +
> > +    Returns 0 on success.
> > +    """
> > +
> > +    paths = scmutil.userrcpath()
> > +    if os.path.isfile(paths[0]):
> > +        if not query.binaryquery(repo,
> > +                _('WARNING: you already have a ' \
> > +                'Mercurial configuration file!\n' \
> > +                'Are you sure you want to overwrite it ' \
> > +                'with a new configuration?'),
> > +            False):
> > +            return
>
> You seem to be inventing a wholly-new set of ways of warning and
> prompting the user when we already have ui.prompt* and ui.warn?
>
> And for some reason, they take a repo argument rather than a ui
> argument?
>
Yes, I made a bad call here :-/ I'll need to change this.

>
> > +    if query.binaryquery(repo,
> > +            _('Would you like to configure your username? '), True):
> > +        name = query.textquery(repo, _('Please enter your name: '))
>
> FWIW, Mercurial message style is to use lowercase.
>
> > +        userconfig.set('pager', 'pager', 'less -FRX')
>
> There's a reason this isn't the default in the pager extension, which is
> that there's already a standard way to set your preferred pager and
> options across applications that we should respect.
>
> > +        userconfig.set('extensions', 'progress', '')
> > +    if query.binaryquery(repo,
> > +            'Would you like to use an extended diff format? ' \
> > +            'If you are viewing changes, ' \
> > +            'this allows you to easily see added/removed files.',
>
> "..but will break compatibility with standard diff/patch tools."
>
> Again, there's a reason it's not on by default. And generally speaking,
> diverging from orthodoxy in minor details won't do your main cause any
> favors.
>
> --
> Mathematics is the supreme nostalgia of our time.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150312/4519f446/attachment.html>


More information about the Mercurial-devel mailing list