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

David Mitchell david.mitchell at telogis.com
Sun Jun 6 21:14:01 CDT 2010


# 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.

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)
+                       'ignored' in show, 'clean' in show, 'unknown' in
show, opts.get('subrepos'))
     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):
         """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]]
+
             cmp, modified, added, removed, deleted, unknown, ignored, clean
= s

             # check for any possibly clean files
diff -r d3ebb1a0bc49 -r a26fd6d9d9f6 mercurial/subrepo.py
--- a/mercurial/subrepo.py Tue Jun 01 18:29:52 2010 -0400
+++ b/mercurial/subrepo.py Mon Jun 07 12:31:41 2010 +1200
@@ -238,6 +238,9 @@
         source, revision, kind = state
         self._repo.ui.debug("getting subrepo %s\n" % self._path)
         hg.clean(self._repo, revision, False)
+
+    def status(self):
+        return self._repo.status(showSubs=True)

     def merge(self, state):
         self._get(state)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100607/6204a16c/attachment.htm>


More information about the Mercurial-devel mailing list