changeset 2639:001703ec311d

Add an option '-C|--copies' to hg status to show the source of copied files. Copied files are displayed in the form: A newname oldname
author Brendan Cully <brendan@kublai.com>
date Wed, 19 Jul 2006 07:52:16 -0700
parents 8dadff054acf
children 02b6fa7bbfbf
files mercurial/commands.py tests/test-status tests/test-status.out
diffstat 3 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2609,6 +2609,7 @@ def status(ui, repo, *pats, **opts):
     ! = deleted, but still tracked
     ? = not tracked
     I = ignored (not shown by default)
+      = the previous added file was copied from here
     """
 
     show_ignored = opts['ignored'] and True or False
@@ -2637,6 +2638,9 @@ def status(ui, repo, *pats, **opts):
 
         for f in changes:
             ui.write(format % f)
+            if (opts.get('copies') and not opts.get('no_status')
+                and opt == 'added' and repo.dirstate.copies.has_key(f)):
+                ui.write('  %s%s' % (repo.dirstate.copies[f], end))
 
 def tag(ui, repo, name, rev_=None, **opts):
     """add a tag for the current tip or a given revision
@@ -3126,6 +3130,7 @@ table = {
           ('u', 'unknown', None, _('show only unknown (not tracked) files')),
           ('i', 'ignored', None, _('show ignored files')),
           ('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')),
           ('I', 'include', [], _('include names matching the given patterns')),
--- a/tests/test-status
+++ b/tests/test-status
@@ -32,3 +32,6 @@ echo "hg status:"
 hg status
 echo "hg status modified added removed deleted unknown never-existed ignored:"
 hg status modified added removed deleted unknown never-existed ignored
+hg copy modified copied
+echo "hg status -C:"
+hg status -C
--- a/tests/test-status.out
+++ b/tests/test-status.out
@@ -101,3 +101,10 @@ R removed
 ! deleted
 ? ignored
 ? unknown
+hg status -C:
+A added
+A copied
+  modified
+R removed
+! deleted
+? unknown