convert/mtn: handle files moved in a moved directory (
issue1619/2)
--- a/hgext/convert/monotone.py Tue Apr 21 15:57:15 2009 +0200
+++ b/hgext/convert/monotone.py Tue Apr 21 22:31:16 2009 +0200
@@ -122,14 +122,14 @@
#revision = self.mtncmd("get_revision %s" % rev).split("\n\n")
revision = self.mtnrun("get_revision", rev).split("\n\n")
files = {}
- addedfiles = {}
+ ignoremove = {}
renameddirs = []
copies = {}
for e in revision:
m = self.add_file_re.match(e)
if m:
files[m.group(1)] = rev
- addedfiles[m.group(1)] = rev
+ ignoremove[m.group(1)] = rev
m = self.patch_re.match(e)
if m:
files[m.group(1)] = rev
@@ -144,6 +144,7 @@
toname = m.group(2)
fromname = m.group(1)
if self.mtnisfile(toname, rev):
+ ignoremove[toname] = 1
copies[toname] = fromname
files[toname] = rev
files[fromname] = rev
@@ -155,7 +156,7 @@
for fromdir, todir in renameddirs:
renamed = {}
for tofile in self.files:
- if tofile in addedfiles:
+ if tofile in ignoremove:
continue
if tofile.startswith(todir + '/'):
renamed[tofile] = fromdir + tofile[len(todir):]
--- a/tests/test-convert-mtn Tue Apr 21 15:57:15 2009 +0200
+++ b/tests/test-convert-mtn Tue Apr 21 22:31:16 2009 +0200
@@ -80,6 +80,14 @@
mtn ci -m emptydir
mtn drop -R dir2/dir
mtn ci -m dropdirectory
+echo '% test directory and file move'
+mkdir -p dir3/d1
+echo a > dir3/a
+mtn add dir3/a dir3/d1
+mtn ci -m dirfilemove
+mtn mv dir3/a dir3/d1/a
+mtn mv dir3/d1 dir3/d2
+mtn ci -m dirfilemove2
cd ..
echo % convert incrementally
@@ -108,5 +116,7 @@
hg log -v -C -r 4 | grep copies
echo % check file remove with directory move
hg manifest -r 5
+echo % check file move with directory move
+hg manifest -r 9
exit 0
--- a/tests/test-convert-mtn.out Tue Apr 21 15:57:15 2009 +0200
+++ b/tests/test-convert-mtn.out Tue Apr 21 22:31:16 2009 +0200
@@ -53,19 +53,37 @@
mtn: dropping dir2/dir from workspace manifest
mtn: beginning commit on branch 'com.selenic.test'
mtn: committed revision 2323d4bc324e6c82628dc04d47a9fd32ad24e322
+% test directory and file move
+mtn: adding dir3 to workspace manifest
+mtn: adding dir3/a to workspace manifest
+mtn: adding dir3/d1 to workspace manifest
+mtn: beginning commit on branch 'com.selenic.test'
+mtn: committed revision 47b192f720faa622f48c68d1eb075b26d405aa8b
+mtn: skipping dir3/d1, already accounted for in workspace
+mtn: renaming dir3/a to dir3/d1/a in workspace manifest
+mtn: skipping dir3, already accounted for in workspace
+mtn: renaming dir3/d1 to dir3/d2 in workspace manifest
+mtn: beginning commit on branch 'com.selenic.test'
+mtn: committed revision 8b543a400d3ee7f6d4bb1835b9b9e3747c8cb632
% convert incrementally
assuming destination repo.mtn-hg
scanning source...
sorting...
converting...
-5 update2 "with" quotes
-4 createdir1
-3 movedir1
-2 movedir
-1 emptydir
-0 dropdirectory
-6 files updated, 0 files merged, 0 files removed, 0 files unresolved
-@ 7 "dropdirectory" files: dir2/dir/subdir/f
+7 update2 "with" quotes
+6 createdir1
+5 movedir1
+4 movedir
+3 emptydir
+2 dropdirectory
+1 dirfilemove
+0 dirfilemove2
+7 files updated, 0 files merged, 0 files removed, 0 files unresolved
+@ 9 "dirfilemove2" files: dir3/a dir3/d2/a
+|
+o 8 "dirfilemove" files: dir3/a
+|
+o 7 "dropdirectory" files: dir2/dir/subdir/f
|
o 6 "emptydir" files: dir2/dir/subdir/f
|
@@ -87,6 +105,7 @@
dir1/subdir2_other/file1
dir2/a
dir2/newfile
+dir3/d2/a
e
% contents
a
@@ -108,3 +127,11 @@
dir2/a
dir2/newfile
e
+% check file move with directory move
+bin2
+dir1/subdir2/file1
+dir1/subdir2_other/file1
+dir2/a
+dir2/newfile
+dir3/d2/a
+e