Why not hard link for hg copy?
Peter Arrenbrecht
peter.arrenbrecht at gmail.com
Wed Jun 10 00:53:22 CDT 2009
On Tue, Jun 9, 2009 at 4:46 PM, Neal Becker<ndbecker2 at gmail.com> wrote:
> Matt Mackall wrote:
>
>> On Tue, 2009-06-09 at 10:21 -0400, Neal Becker wrote:
>>> Subject says it all.
>>
>> Other programs cannot be trusted to do the right thing with hardlinks.
>> Otherwise, normal cp would use hardlinks by default as well.
>>
>
> I suppose this actually brings up the question of just what are the
> semantics of hg copy supposed to be? I was assuming that this marks the
> file as _forever_ being a duplicate. In this model, you would not be
> allowed to check in a change to file A that is different than file B. You
> would have to tell hg they are no longer copies.
>
> If this is not the semantics, then it's not obvious to me what the purpose
> of hg copy is.
The purpose is to help merge be clever:
hg init foo; cd foo
echo A >a
hg ci -Am orig-a
hg cp a b
hg ci -Am copied-to-b
hg up 0 # revert to before we copied a->b
echo B >a # overwrite contents of a
hg ci -Am modified-a
hg up -C 1 # back to where we copied a->b
When we merge, we get:
$ hg merge tip # merge change to a
merging b and a to b
1 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ ls a
B
$ ls b
B
So merge recognized a fix to a that should also go into b (it reckons).
-parren
More information about the Mercurial-devel
mailing list