changeset 10014:54cd28258ea7

status: add the --change option to display files changed in a revision This option is similar to the one already used for the diff command. Unfortunately, the c and C short option are already used for status, so there is no corresponding short option. However, there is no short option for --rev either, so that's consistent.
author Gilles Moris <gilles.moris@free.fr>
date Mon, 30 Nov 2009 23:51:06 +0100
parents b2e87fde6806
children b5f352f33520
files mercurial/commands.py tests/test-debugcomplete.out tests/test-help.out tests/test-status tests/test-status.out
diffstat 5 files changed, 62 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Dec 01 09:53:02 2009 +0900
+++ b/mercurial/commands.py	Mon Nov 30 23:51:06 2009 +0100
@@ -2842,7 +2842,8 @@
 
     If one revision is given, it is used as the base revision.
     If two revisions are given, the differences between them are
-    shown.
+    shown. The --change option can also be used as a shortcut to list
+    the changed files of a revision from its first parent.
 
     The codes used to show the status of files are::
 
@@ -2856,7 +2857,18 @@
         = origin of the previous file listed as A (added)
     """
 
-    node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
+    revs = opts.get('rev')
+    change = opts.get('change')
+
+    if revs and change:
+        msg = _('cannot specify --rev and --change at the same time')
+        raise util.Abort(msg)
+    elif change:
+        node2 = repo.lookup(change)
+        node1 = repo[node2].parents()[0].node()
+    else:
+        node1, node2 = cmdutil.revpair(repo, revs)
+
     cwd = (pats and repo.getcwd()) or ''
     end = opts.get('print0') and '\0' or '\n'
     copy = {}
@@ -3660,6 +3672,7 @@
           ('0', 'print0', None,
            _('end filenames with NUL, for use with xargs')),
           ('', 'rev', [], _('show difference from revision')),
+          ('', 'change', '', _('list the changed files of a revision')),
          ] + walkopts,
          _('[OPTION]... [FILE]...')),
     "tag":
--- a/tests/test-debugcomplete.out	Tue Dec 01 09:53:02 2009 +0900
+++ b/tests/test-debugcomplete.out	Mon Nov 30 23:51:06 2009 +0100
@@ -177,7 +177,7 @@
 push: force, rev, ssh, remotecmd
 remove: after, force, include, exclude
 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate
-status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, include, exclude
+status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude
 summary: remote
 update: clean, check, date, rev
 addremove: similarity, include, exclude, dry-run
--- a/tests/test-help.out	Tue Dec 01 09:53:02 2009 +0900
+++ b/tests/test-help.out	Mon Nov 30 23:51:06 2009 +0100
@@ -270,7 +270,9 @@
     parent.
 
     If one revision is given, it is used as the base revision. If two
-    revisions are given, the differences between them are shown.
+    revisions are given, the differences between them are shown. The --change
+    option can also be used as a shortcut to list the changed files of a
+    revision from its first parent.
 
     The codes used to show the status of files are:
 
@@ -297,6 +299,7 @@
  -C --copies     show source of copied files
  -0 --print0     end filenames with NUL, for use with xargs
     --rev        show difference from revision
+    --change     list the changed files of a revision
  -I --include    include names matching the given patterns
  -X --exclude    exclude names matching the given patterns
 
--- a/tests/test-status	Tue Dec 01 09:53:02 2009 +0900
+++ b/tests/test-status	Mon Nov 30 23:51:06 2009 +0100
@@ -91,4 +91,27 @@
 assert "-q" "-u"         1
 assert "-m" "-a"         1
 assert "-r" "-d"         1
+cd ..
 
+hg init repo4
+cd repo4
+touch modified removed deleted
+hg ci -q -A -m 'initial checkin' -d "1000000 0"
+touch added unknown
+hg add added
+hg remove removed
+rm deleted
+echo x > modified
+hg copy modified copied
+hg ci -m 'test checkin' -d "1000001 0"
+rm *
+touch unrelated
+hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
+echo "hg status --change 1:"
+hg status --change 1
+echo "hg status --change 1 unrelated:"
+hg status --change 1 unrelated
+echo "hg status -C --change 1 added modified copied removed deleted:"
+hg status -C --change 1 added modified copied removed deleted
+echo "hg status -A --change 1"
+hg status -A --change 1
--- a/tests/test-status.out	Tue Dec 01 09:53:02 2009 +0900
+++ b/tests/test-status.out	Mon Nov 30 23:51:06 2009 +0100
@@ -124,3 +124,22 @@
 adding deleted
 adding modified
 adding removed
+hg status --change 1:
+M modified
+A added
+A copied
+R removed
+hg status --change 1 unrelated:
+hg status -C --change 1 added modified copied removed deleted:
+M modified
+A added
+A copied
+  modified
+R removed
+hg status -A --change 1
+M modified
+A added
+A copied
+  modified
+R removed
+C deleted