hg convert misses directory renames

Pavel Volkovitskiy olfway at gmail.com
Thu Apr 2 10:36:43 CDT 2009


Hello!

I tried to convert monotone repo to hg and got different checkout (
http://www.selenic.com/mercurial/bts/issue1587 )

monotone renames 'dir1/subdir1' to 'dir1/subdir2' but hg misses that rename

in hgext/convert/monotone.py:
...
     def mtnrenamefiles(self, files, fromdir, todir):
         renamed = {}
         for tofile in files:
-            suffix = tofile.lstrip(todir)
-            if todir + suffix == tofile:
-                renamed[tofile] = (fromdir + suffix).lstrip("/")
+            if tofile.startswith(todir):
+                renamed[tofile] = fromdir + tofile[len(todir):]
         return renamed
...

i guess tofile.lstrip(todir) was supposed to strip 'dir1/subdir1' from
'dir1/subdir1/file1' but actually it strips not _string_ but _characters_:

'fdir1/subdir1/file1'.lstrip('fdir1/subdir1') -> 'le1'

suggested patch (fix + test) in attachment, pls review

PS: i also removed lstrip('/') b/c all paths in monotone manifest was
without leading '/'

-- 
Pavel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20090402/a66c5614/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hg-convert-monotone-directory-rename.patch
Type: text/x-patch
Size: 3193 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090402/a66c5614/attachment.bin 


More information about the Mercurial-devel mailing list