How to handle copies.copies()

Choy Rim choy.rim at gmail.com
Tue Nov 22 03:32:25 CST 2011


Frank A. Kingswood <frank <at> kingswood-consulting.co.uk> writes:

> 
> Hi!
> 
> I'm currently using copies.copies (in the perfarce extension) to work out 
file copies, but have found a
> problem when moving a file.
> 
> The first value returned from copies.copies(), and the debug output is:
> 
>   searching for copies back to rev 57
>   unmatched files in local:
>    aa
>   unmatched files in other:
>    aaa
>   all copies found (* = to merge, ! = divergent):
>    aa -> a *
>    aaa -> aa *
> cpy={'aa': 'a', 'aaa': 'aa'}
> add=[('aaa', '')]
> rem=[('aa', '')]
> 
> Revision 57 did a hg mv aa aaa. The copy from a to aa or vice versa was some 
time in the past, and aa was deleted and
> re-added afterwards.
> The add,rem values are from repo.status() and correctly indicate what 
happened.
> 
> My question is, how should I parse the copies() return value to determine 
this?
> 
> Regards,
> 
> Frank

Frank,

I've run into the same issue while using Perfarce. It looks like copies.copies 
detects some bogus mappings. It will find another file from the first change 
context that matches a file removed from the second change context.

in my case, i moved a file from xxx -> yyy. but there's an identical copy of 
xxx at zzz. so i get a mapping from xxx -> yyy but also zzz -> xxx. so i got 
the error "abort: xxx at deadbeef: not found in manifest!"

so i added a hack into the copy forget loop which looks like

            forget = []
            for c in cpy:
                if not c in ctx2:
                    ui.debug('bogus copy mapping. ignoring.\n')
                    continue
                ... etc. ...

Seems to work.

-Choy







More information about the Mercurial-devel mailing list