Tracking files and file-level operations

Martin Geisler mg at aragost.com
Tue Jul 20 08:35:55 BST 2010


Chris Hecker <checker at d6.com> writes:

> You may want to read this:
>
> http://wiki.bazaar.canonical.com/BzrFileCopies
>
> I think it's pretty silly that bzr doesn't support copies, but I do
> agree with their rationale that renames are more important (at least
> in my experience), so I think it's slightly sillier that Hg doesn't
> support renames [...]

Please stop right there! What you say is wrong. Why do you think
Mercurial does not support renames?

It most certainly does support renaming files, including the "propagate
change to the new file when merging" scenario. Try a session like this:

  % hg init
  % touch a.txt
  % hg add
  adding a.txt
  % hg commit -m 'empty a'
  % hg rename a.txt b.txt
  % hg commit -m 'rename a to b'
  % hg update 0
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  % echo hello world > a.txt
  % hg commit -m 'change a'
  created new head
  % hg merge
  merging a.txt and b.txt to b.txt
  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)

The 'merging a.txt and b.txt to b.txt' line above tells you that the
change was propagated into the new name. After a commit the history
looks like:

  % hg glog
  @    changeset:   3:4ace64e8504f
  |\   tag:         tip
  | |  parent:      2:230b39ecab98
  | |  parent:      1:4a70576457c4
  | |  user:        Martin Geisler <mg at aragost.com>
  | |  date:        Tue Jul 20 09:28:24 2010 +0200
  | |  summary:     merge changed a into b
  | |
  | o  changeset:   2:230b39ecab98
  | |  parent:      0:c1b55b2a01b0
  | |  user:        Martin Geisler <mg at aragost.com>
  | |  date:        Tue Jul 20 09:28:11 2010 +0200
  | |  summary:     change a
  | |
  o |  changeset:   1:4a70576457c4
  |/   user:        Martin Geisler <mg at aragost.com>
  |    date:        Tue Jul 20 09:27:59 2010 +0200
  |    summary:     rename a to b
  |
  o  changeset:   0:c1b55b2a01b0
     user:        Martin Geisler <mg at aragost.com>
     date:        Tue Jul 20 09:27:45 2010 +0200
     summary:     empty a

and the directory and file content is as you would expect:

  % ls
  b.txt
  % cat b.txt
  hello world

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://aragost.com/mercurial/



More information about the bazaar mailing list