Possible problem with -f option to rename

Peter Williams pwil3058 at bigpond.net.au
Fri Mar 30 19:52:20 CDT 2007


Eric M. Hopper wrote:
> On Thu, 2007-03-29 at 11:05 +1000, Peter Williams wrote:
>> During testing of my revision control GUI wrapper using hg as a back end 
>> I've noticed an anomaly when the -f option is used with rename to force 
>> the overwriting of an existing file.
>>
>> For a normal invocation of rename, the moved file (in its new location) 
>> is marked as added ("A") by the status command and the -C option to the 
>> status command indicates the identity of the moved file but neither of 
>> these happen for a file that was overwritten with -f.  This anomaly 
>> occurs both when the actual contents of the overwritten file is the same 
>> after the overwrite and when it has changed after overwrite although in 
>> this latter case it is marked as modified ("M").
>>
>> In all cases, the original file is marked as removed ("R").
>>
>> I can see a case for the added ("A") mark not being used (i.e. the file 
>> already existed) but think some information is lost (from the user's 
>> point of view) by the failure of the -C option to indicate the origin 
>> (especially in the case where the contents of the target have changed as 
>> a result of the overwrite).
>>
>> Is this the intended behaviour?
> 
> On a fairly recent build of Mercurial based on
> http://www.selenic.com/hg/rev/0ce23256e454 this doesn't happen this way.
> For a file that was moved over the top of another using mv -f the
> original shows as R, the file being stomped on shows as M, and the -C
> option properly shows the original after the file that shows as M.
> 
> Example:
> 
> $ hg mv -f a b
> $ hg status -C
> M b
>   a
> R a
> 
> I think this is correct behavior.

That looks good to me.

What about the case where the move causes no change to the contents of 
b?  It will not be marked as modified (which is correct) but will a be 
shown as the original after b?  Is this asking too much of hg? 
Especially, since b won't be listed unless the -c (or -A) option is 
used.  I.e. is this special (and probably very rare) case worth worrying 
about?

Peter
-- 
Peter Williams                                   pwil3058 at bigpond.net.au

"Learning, n. The kind of ignorance distinguishing the studious."
  -- Ambrose Bierce


More information about the Mercurial-devel mailing list