[PATCH 1 of 2] status: add relative option flag (issue3835)

Yuya Nishihara yuya at tcha.org
Wed Mar 25 08:54:46 CDT 2015


On Tue, 24 Mar 2015 22:46:56 -0700, Sean Farley wrote:
> # HG changeset patch
> # User Yung-Jin (Joey) Hu <yungjinhu at gmail.com>
> # Date 1426736402 25200
> #      Wed Mar 18 20:40:02 2015 -0700
> # Node ID f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd
> # Parent  5b85a5bc5bbb9d8365953609d98e4dce7110e9b0
> status: add relative option flag (issue3835)
> 
> Previously, you had to send the root of the repo to get the relative files of
> the entire repo.
> 
> hg status $(hg root)
> 
> This had the downside of involking running mercurial twice. Instead let's just
> add a flag and be done with it.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5686,10 +5686,12 @@ class httpservice(object):
>      ('n', 'no-status', None, _('hide status prefix')),
>      ('C', 'copies', None, _('show source of copied files')),
>      ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
>      ('', 'rev', [], _('show difference from revision'), _('REV')),
>      ('', 'change', '', _('list the changed files of a revision'), _('REV')),
> +    ('', 'relative', None,
> +     ('list the changed files relative to working directory')),
>      ] + walkopts + subrepoopts + formatteropts,
>      _('[OPTION]... [FILE]...'),
>      inferrepo=True)
>  def status(ui, repo, *pats, **opts):
>      """show changed files in the working directory
> @@ -5757,11 +5759,17 @@ def status(ui, repo, *pats, **opts):
>          node2 = scmutil.revsingle(repo, change, None).node()
>          node1 = repo[node2].p1().node()
>      else:
>          node1, node2 = scmutil.revpair(repo, revs)
>  
> -    if pats:
> +    relative = opts.get('relative')
> +
> +    if pats and relative:
> +        msg = _('cannot specify path and --relative at the same time')
> +        raise util.Abort(msg)

It's a little confusing to me that there are two variants of --relative.

hg diff --relative PATH

 - takes PATH
 - filtered by PATH

hg status --relative

 - boolean
 - not filtered by $PWD

Regards,


More information about the Mercurial-devel mailing list