Show More
@@ -1096,11 +1096,17 b' def _dir_renames(repo, ctx, copy, fullco' | |||
|
1096 | 1096 | b" discovered dir src: '%s' -> dst: '%s'\n" % (d, dirmove[d]) |
|
1097 | 1097 | ) |
|
1098 | 1098 | |
|
1099 | # Sort the directories in reverse order, so we find children first | |
|
1100 | # For example, if dir1/ was renamed to dir2/, and dir1/subdir1/ | |
|
1101 | # was renamed to dir2/subdir2/, we want to move dir1/subdir1/file | |
|
1102 | # to dir2/subdir2/file (not dir2/subdir1/file) | |
|
1103 | dirmove_children_first = sorted(dirmove, reverse=True) | |
|
1104 | ||
|
1099 | 1105 | movewithdir = {} |
|
1100 | 1106 | # check unaccounted nonoverlapping files against directory moves |
|
1101 | 1107 | for f in addedfilesfn(): |
|
1102 | 1108 | if f not in fullcopy: |
|
1103 | for d in dirmove: | |
|
1109 | for d in dirmove_children_first: | |
|
1104 | 1110 | if f.startswith(d): |
|
1105 | 1111 | # new file added in a directory that was moved, move it |
|
1106 | 1112 | df = dirmove[d] + f[len(d) :] |
@@ -294,3 +294,45 b' status to list copies here.' | |||
|
294 | 294 | M t/t |
|
295 | 295 | R a/s |
|
296 | 296 | R a/t |
|
297 | ||
|
298 | $ cd .. | |
|
299 | ||
|
300 | ||
|
301 | Test that files are moved to a new directory based on the path prefix that | |
|
302 | matches the most. dir1/ below gets renamed to dir2/, and dir1/subdir1/ gets | |
|
303 | renamed to dir2/subdir2/. We want dir1/subdir1/newfile to move to | |
|
304 | dir2/subdir2/ (not to dir2/subdir1/ as we would infer based on just the rename | |
|
305 | of dir1/ to dir2/). | |
|
306 | ||
|
307 | $ hg init nested-renames | |
|
308 | $ cd nested-renames | |
|
309 | $ mkdir dir1 | |
|
310 | $ echo a > dir1/file1 | |
|
311 | $ echo b > dir1/file2 | |
|
312 | $ mkdir dir1/subdir1 | |
|
313 | $ echo c > dir1/subdir1/file3 | |
|
314 | $ echo d > dir1/subdir1/file4 | |
|
315 | $ hg ci -Aqm initial | |
|
316 | $ hg mv dir1 dir2 | |
|
317 | moving dir1/file1 to dir2/file1 | |
|
318 | moving dir1/file2 to dir2/file2 | |
|
319 | moving dir1/subdir1/file3 to dir2/subdir1/file3 | |
|
320 | moving dir1/subdir1/file4 to dir2/subdir1/file4 | |
|
321 | $ hg mv dir2/subdir1 dir2/subdir2 | |
|
322 | moving dir2/subdir1/file3 to dir2/subdir2/file3 | |
|
323 | moving dir2/subdir1/file4 to dir2/subdir2/file4 | |
|
324 | $ hg ci -m 'move dir1/ to dir2/ and dir1/subdir1/ to dir2/subdir2/' | |
|
325 | $ hg co 0 | |
|
326 | 4 files updated, 0 files merged, 4 files removed, 0 files unresolved | |
|
327 | $ echo e > dir1/subdir1/file5 | |
|
328 | $ hg ci -Aqm 'add file in dir1/subdir1/' | |
|
329 | $ hg merge 1 | |
|
330 | 5 files updated, 0 files merged, 4 files removed, 0 files unresolved | |
|
331 | (branch merge, don't forget to commit) | |
|
332 | $ hg files | |
|
333 | dir2/file1 | |
|
334 | dir2/file2 | |
|
335 | dir2/subdir2/file3 | |
|
336 | dir2/subdir2/file4 | |
|
337 | dir2/subdir2/file5 | |
|
338 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now