views:

179

answers:

1

I know that Mercurial can track renames of files, but how do I get it to show me renames instead of adds/removes when I do hg status? For instance, instead of:

A bin/extract-csv-column.pl
A bin/find-mirna-binding.pl
A bin/xls2csv-separate-sheets.pl
A lib/Text/CSV/Euclid.pm
R src/extract-csv-column.pl
R src/find-mirna-binding.pl
R src/modules/Text/CSV/Euclid.pm
R src/xls2csv-separate-sheets.pl

I want some indication that four files have been moved.

I think I read somewhere that the output is like this to preserve backward-compatibility with something-or-other, but I'm not worried about that.

+4  A: 

There are several ways to do this.

Before you commit, you can use hg diff --git to show what was renamed:

$ hg diff --git
diff --git a/theTest.txt b/aTest.txt
rename from theTest.txt
rename to aTest.txt

Note that this only works if you used hg mv, hg rename, or mv and hg addremove --similarity 100.

After you commit, you can still use hg diff, but you'll have to specify the change using -r:

$ hg diff -r 0 -r 1 --git
diff --git a/test.txt b/theTest.txt
rename from test.txt
rename to theTest.txt

For both hg status and hg log, use the -C command-line flag to see the source that a file was copied from.

$ hg status -C
A aTest.txt
  theTest.txt
R theTest.txt

The line just below aTest.txt indicates the source it was copied from (theTest.txt).

$ hg log -v -C
changeset:   1:4d7b42489d9f
tag:         tip
user:        jhurne
date:        Tue Apr 20 20:57:07 2010 -0400
files:       test.txt theTest.txt
copies:      theTest.txt (test.txt)
description:
Renamed test.txt

You can see the files that were affected (test.txt and theTest.txt), and that "theTest.txt" was copied from test.txt.

Jim Hurne