Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing renames in hg status?

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.

like image 822
Ryan C. Thompson Avatar asked Apr 20 '10 23:04

Ryan C. Thompson


People also ask

What is hg status?

hg status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.

How to remove files from hg?

Once you decide that a file no longer belongs in your repository, use the hg remove command. This deletes the file, and tells Mercurial to stop tracking it (which will occur at the next commit). A removed file is represented in the output of hg status with a “ R ”.


2 Answers

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.

like image 115
Jim Hurne Avatar answered Oct 01 '22 12:10

Jim Hurne


You can find out how many files have been renamed with hg summary. If you want to see the actual files that were renamed, the fastest way I've found is to do:

hg st -a -C 

This will output something like this:

A <path\to\renamed\file>   <path\copied\from> A <path\to\added\file> A <path\to\renamed\file>   <path\copied\from> 

Since hg status considers a rename to be a copy and a remove, your renamed files will list a copied from file. Files that were added but not renamed will not list a copied from file.

like image 27
Kevin Berridge Avatar answered Oct 01 '22 12:10

Kevin Berridge