Proper tracking of file-level operations: rename, directories, merges

Martin Geisler mg at aragost.com
Fri Oct 21 07:22:08 UTC 2011


Colin D Bennett <colin at gibibit.com> writes:

> On Fri, 21 Oct 2011 08:57:00 +1100
> Ben Finney <ben+bazaar at benfinney.id.au> wrote:
>
>>...
>> $ hg status
>> A bar/beans
>> A bar/eggs
>> A bar/spam
>> R foo/beans
>> R foo/eggs
>> R foo/spam
>> =====
>
> It took me a moment to see the significance of this behavior of hg:
>
> You can't distinguish the single file with modified content from the
> other files which have no content change.

That is false. After renaming and modifying the file, you get:

  $ hg status -C
  A bar/beans
    foo/beans
  A bar/eggs
    foo/eggs
  A bar/spam
    foo/spam
  R foo/beans
  R foo/eggs
  R foo/spam

Not pretty, but it shows where each file was renamed from. To see the
modifications you use 'hg diff':

  $ hg diff
  diff --git a/foo/beans b/bar/beans
  rename from foo/beans
  rename to bar/beans
  diff --git a/foo/eggs b/bar/eggs
  rename from foo/eggs
  rename to bar/eggs
  --- a/foo/eggs
  +++ b/bar/eggs
  @@ -1,1 +1,1 @@
  -Lorem ipsum
  +Lorem morit ipsum
  diff --git a/foo/spam b/bar/spam
  rename from foo/spam
  rename to bar/spam

Here you see the extended Git diff format (the normal patch format
cannot represent renames). Regardless of how you've configured Mercurial
to show diffs, Mercurial will faithfully record that "bar/eggs" was
moved and modified. No information is lost here.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/



More information about the bazaar mailing list