From: Felipe Contreras Date: Mon, 08 Apr 2013 17:27:10 GMT Subject: [PATCH v2 1/7] remote-bzr: fix directory renaming Message-ID: <1365442036-25732-2-git-send-email-felipe.contreras@gmail.com> In-Reply-To: <1365442036-25732-1-git-send-email-felipe.contreras@gmail.com> From: Christophe Simonis Git does not handle directories, renaming a directory is renaming every files in this directory. [fc: added tests] Signed-off-by: Felipe Contreras --- contrib/remote-helpers/git-remote-bzr | 8 +++++++- contrib/remote-helpers/test-bzr.sh | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr index c5822e4..a7d041b 100755 --- a/contrib/remote-helpers/git-remote-bzr +++ b/contrib/remote-helpers/git-remote-bzr @@ -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 diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh index 8450432..d26e5c7 100755 --- a/contrib/remote-helpers/test-bzr.sh +++ b/contrib/remote-helpers/test-bzr.sh @@ -126,4 +126,28 @@ test_expect_success 'special modes' ' test_cmp expected actual ' +cat > expected < 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 -- 1.8.2