On Sun, 11 Mar 2018 15:19:26 +0530, Sushil khanchi wrote:
> # HG changeset patch
> # User Sushil khanchi <sushilkhanch...@gmail.com>
> # Date 1520665399 -19800
> #      Sat Mar 10 12:33:19 2018 +0530
> # Node ID a1be8989c0158abc69ebd97ca8a0cc7dc3801be9
> # Parent  4c71a26a4009d88590c9ae3d64a5912fd556d82e
> forget: add --dry-run mode

Can you add some tests?

> -def forget(ui, repo, match, prefix, explicitonly):
> +def forget(ui, repo, match, prefix, explicitonly, **opts):

I slightly prefer an explicit parameter, 'opts' or 'dryrun' instead of **opts.
That will show you we'll have to propagate the option to sub.forget().

> -    rejected = wctx.forget(forget, prefix)
> -    bad.extend(f for f in rejected if f in match.files())
> -    forgot.extend(f for f in forget if f not in rejected)
> +    if not opts.get(r'dry_run'):
> +        rejected = wctx.forget(forget, prefix)
> +        bad.extend(f for f in rejected if f in match.files())
> +        forgot.extend(f for f in forget if f not in rejected)
>      return bad, forgot
>  
>  def files(ui, ctx, m, fm, fmt, subrepos):
> diff -r 4c71a26a4009 -r a1be8989c015 mercurial/commands.py
> --- a/mercurial/commands.py   Sun Mar 04 21:16:36 2018 -0500
> +++ b/mercurial/commands.py   Sat Mar 10 12:33:19 2018 +0530
> @@ -2036,7 +2036,11 @@
>      with ui.formatter('files', opts) as fm:
>          return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
>  
> -@command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
> +@command(
> +    '^forget',
> +    [('', 'dry-run', None, _('only print output'))]
> +    + walkopts,

The constant 'dryrunopts' can be used instead.
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to