[PATCH 1 of 2] diff: add the --output option

Ahmed S. Darwish darwish.07 at gmail.com
Sun Jun 30 15:28:14 CDT 2013


Hi!

On Sat, Jun 29, 2013 at 02:17:35PM -0500, Kevin Bullock wrote:
> On 28 Jun 2013, at 4:06 PM, Ahmed S. Darwish wrote:
> >
> > --- a/mercurial/commands.py	Mon Jun 24 14:02:01 2013 -0400
> > +++ b/mercurial/commands.py	Fri Jun 28 22:54:47 2013 +0200
> > @@ -2676,7 +2676,9 @@
> >         ui.warn("%s\n" % res2)
> > 
> > @command('^diff',
> > -    [('r', 'rev', [], _('revision'), _('REV')),
> > +    [('o', 'output', '',
> > +     _('print output to file with formatted name'), _('FORMAT')),
> > +    ('r', 'rev', [], _('revision'), _('REV')),
> 
> -o/--output should probably come _after_ -c/--change in this case.
> We'll also need some documentation of the name format. This could
> either be a cross-reference to 'hg help export', or you could wrap
> the documentation in a ".. container:: verbose".
>

I guess several `hg export' FORMAT codes does not seem to make sense
here, espcially since I'm not proposing ``hg diff --output'' as a
replacement or alias for `hg export'.  I'll thus limit the FORMAT
characters to:

    "%%"  literal "%" character
    "%b"  basename of the exporting repository

while probably adding:

    "%d"  current time and date

and include the above three lines in `hg diff' own documentation.

> > 
> > +    if fname:
> > +        fp = cmdutil.makefileobj(repo, fname)
> > +    else:
> > +        fp = None
> 
> Our usual idiom here is to set the variable to None unconditionally,
> then check the condition. Eliminates an unnecessary 'else' clause.
> 

Will do.

Thanks for the review,

--
Darwish
http://darwish.chasingpointers.com


More information about the Mercurial-devel mailing list