remote-bzr: fix directory renaming
Git does not handle directories, renaming a directory is renaming every files in this directory. [fc: added tests] Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christophe Simonis committed
Apr 5, 2013 at 21:49 UTC
82447e33610396a03f481cb26f39a5d7dc6eb193
2 files changed
+31
-1
contrib/remote-helpers/git-remote-bzr
+7
-1
@@ -191,7 +191,13 @@ def get_filechanges(cur, prev):
191
modified[path] = fid
192
for oldpath, newpath, fid, kind, mod, _ in changes.renamed:
193
removed[oldpath] = None
194
- modified[newpath] = fid
194
+ if kind == 'directory':
195
+ lst = cur.list_files(from_dir=newpath, recursive=True)
196
+ for path, file_class, kind, fid, entry in lst:
197
+ if kind != 'directory':
198
+ modified[newpath + '/' + path] = fid
199
+ else:
200
+ modified[newpath] = fid
201
202
return modified, removed
203
contrib/remote-helpers/test-bzr.sh
+24
@@ -140,4 +140,28 @@ test_expect_success 'special modes' '
140
test_cmp expected actual
141
'
142
143
+cat > expected <<EOF
144
+100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
145
+100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
146
+120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
147
+040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
148
+EOF
149
+
150
+test_expect_success 'moving directory' '
151
+ (cd bzrrepo &&
152
+ mkdir movedir &&
153
+ echo one > movedir/one &&
154
+ echo two > movedir/two &&
155
+ bzr add movedir &&
156
+ bzr commit -m movedir &&
157
+ bzr mv movedir movedir-new &&
158
+ bzr commit -m movedir-new) &&
159
+
160
+ (cd gitrepo &&
161
+ git pull &&
162
+ git ls-tree HEAD > ../actual) &&
163
+
164
+ test_cmp expected actual
165
+'
166
+
167
test_done