[PATCH] status: add option to show status of files in subrepos

Matt Mackall mpm at selenic.com
Wed Jun 9 03:04:49 CDT 2010


On Mon, 2010-06-07 at 14:14 +1200, David Mitchell wrote:
> # HG changeset patch
> # User David Mitchell <david.mitchell at telogis.com>
> # Date 1275870701 -43200
> # Branch stable
> # Node ID a26fd6d9d9f60da713f64a92f5713d724c94adef
> # Parent  d3ebb1a0bc49559e1e41d37f69c2afa06722563e
> Add option to status to see changes in all subrepos.
> 
> 
> Only used by status command so it has no impact on the way commits are
> done, and therefore no effect on the default commit status comment.

When you submit a change like this, please show us what it looks like so
we can talk about it. One of the common complaints about subrepos is
that it's not obvious when a subrepo is modified so commit's recursive
behavior bites people. So it's not clear that:

M foo
M sub/bar

really gives people enough notice that it's a subrepo that's changed.
But then:

M foo
M subrepo/

is just weird, so maybe your way is right after all. Opinions?

Is there a reason not to have a -S flag?

I guess it only works with hg subrepos and not svn? Hopefully someone
with some svn savvy will chip in and fix that.

> Doesn't show which changes are files in subrepos and which are the top
> level repo.
> 
> 
> diff -r d3ebb1a0bc49 -r a26fd6d9d9f6 mercurial/commands.py
> --- a/mercurial/commands.py Tue Jun 01 18:29:52 2010 -0400
> +++ b/mercurial/commands.py Mon Jun 07 12:31:41 2010 +1200
> @@ -3010,7 +3010,7 @@
>          show = ui.quiet and states[:4] or states[:5]
>  
>      stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
> -                       'ignored' in show, 'clean' in show, 'unknown'
> in show)

Your mail client is doing line wrapping. Please check out the patchbomb
extension.

> +                       'ignored' in show, 'clean' in show, 'unknown'
> in show, opts.get('subrepos'))

And be sure to wrap long lines. contrib/check-code catches this sort of
thing.

>      changestates = zip(states, 'MAR!?IC', stat)
>  
>      if (opts.get('all') or opts.get('copies')) and not
> opts.get('no_status'):
> @@ -3832,6 +3832,7 @@
>            ('i', 'ignored', None, _('show only ignored files')),
>            ('n', 'no-status', None, _('hide status prefix')),
>            ('C', 'copies', None, _('show source of copied files')),
> +          ('', 'subrepos', None, _('show status of files in
> subrepositories')),
>            ('0', 'print0', None,
>             _('end filenames with NUL, for use with xargs')),
>            ('', 'rev', [], _('show difference from revision')),
> diff -r d3ebb1a0bc49 -r a26fd6d9d9f6 mercurial/localrepo.py
> --- a/mercurial/localrepo.py Tue Jun 01 18:29:52 2010 -0400
> +++ b/mercurial/localrepo.py Mon Jun 07 12:31:41 2010 +1200
> @@ -971,7 +971,7 @@
>          return self[node].walk(match)
>  
>      def status(self, node1='.', node2=None, match=None,
> -               ignored=False, clean=False, unknown=False):
> +               ignored=False, clean=False, unknown=False,
> showSubs=False):

It also will complain about camelcase.

>          """return status of files between two nodes or node and
> working directory
>  
>          If node1 is None, use the first dirstate parent instead.
> @@ -1015,6 +1015,14 @@
>                  subrepos = ctx1.substate.keys()
>              s = self.dirstate.status(match, subrepos, listignored,
>                                       listclean, listunknown)
> +
> +            # Stat the sub repositories if requested
> +            if showSubs:
> +                for sr in subrepos:
> +                    subs = ctx2.sub(sr).status()
> +                    for idx in range(len(subs)):
> +                        [s[idx].append('%s/%s' % (sr, f)) for f in
> subs[idx]]
> +

That's a little hard to read. Perhaps something like

for sub in subrepos:
    substat = ctx2.sub(sub).status()
    for i, l in enumerate(substat):
        s[i].append('%s/%s' % (sub, f) for f in l)

There are things that expect these lists to be sorted, so we're going to
need an extra step here. And merging the sorted file lists from the main
repo and N subrepos efficiently can probably be done more efficiently
than sort(sum(lists)).


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list