Skip to content

Commit

Permalink
remote-bzr: fix directory renaming
Browse files Browse the repository at this point in the history
Git does not handle directories, renaming a directory is renaming every
files in this directory.

[fc: added tests]

Signed-off-by: Felipe Contreras <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
KangOl authored and gitster committed Apr 7, 2013
1 parent 21ccebe commit 82447e3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contrib/remote-helpers/git-remote-bzr
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ def get_filechanges(cur, prev):
modified[path] = fid
for oldpath, newpath, fid, kind, mod, _ in changes.renamed:
removed[oldpath] = None
modified[newpath] = fid
if kind == 'directory':
lst = cur.list_files(from_dir=newpath, recursive=True)
for path, file_class, kind, fid, entry in lst:
if kind != 'directory':
modified[newpath + '/' + path] = fid
else:
modified[newpath] = fid

return modified, removed

Expand Down
24 changes: 24 additions & 0 deletions contrib/remote-helpers/test-bzr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,28 @@ test_expect_success 'special modes' '
test_cmp expected actual
'

cat > expected <<EOF
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
EOF

test_expect_success 'moving directory' '
(cd bzrrepo &&
mkdir movedir &&
echo one > movedir/one &&
echo two > movedir/two &&
bzr add movedir &&
bzr commit -m movedir &&
bzr mv movedir movedir-new &&
bzr commit -m movedir-new) &&
(cd gitrepo &&
git pull &&
git ls-tree HEAD > ../actual) &&
test_cmp expected actual
'

test_done

0 comments on commit 82447e3

Please sign in to comment.