remote-bzr: fix utf-8 support for fetching
The previous patches didn't deal with all the scenarios. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christophe Simonis committed
Apr 8, 2013 at 13:36 UTC
5ff4fc649e18c02bc475ec5785a985ac5f6e0688
2 files changed
+19
-9
contrib/remote-helpers/git-remote-bzr
+11
-8
@@ -183,21 +183,24 @@ def get_filechanges(cur, prev):
183
184
changes = cur.changes_from(prev)
185
186
+ def u(s):
187
+ return s.encode('utf-8')
188
+
189
for path, fid, kind in changes.added:
187
- modified[path] = fid
190
+ modified[u(path)] = fid
191
for path, fid, kind in changes.removed:
189
- removed[path] = None
192
+ removed[u(path)] = None
193
for path, fid, kind, mod, _ in changes.modified:
191
- modified[path] = fid
194
+ modified[u(path)] = fid
195
for oldpath, newpath, fid, kind, mod, _ in changes.renamed:
193
- removed[oldpath] = None
196
+ removed[u(oldpath)] = None
197
if kind == 'directory':
198
lst = cur.list_files(from_dir=newpath, recursive=True)
199
for path, file_class, kind, fid, entry in lst:
200
if kind != 'directory':
198
- modified[newpath + '/' + path] = fid
201
+ modified[u(newpath + '/' + path)] = fid
202
else:
200
- modified[newpath] = fid
203
+ modified[u(newpath)] = fid
204
205
return modified, removed
206
@@ -223,7 +226,7 @@ def export_files(tree, files):
226
# is the blog already exported?
227
if h in filenodes:
228
mark = filenodes[h]
226
- final.append((mode, mark, path.encode('utf-8')))
229
+ final.append((mode, mark, path))
230
continue
231
232
d = tree.get_file_text(fid)
@@ -240,7 +243,7 @@ def export_files(tree, files):
243
print "data %d" % len(d)
244
print d
245
243
- final.append((mode, mark, path.encode('utf-8')))
246
+ final.append((mode, mark, path))
247
248
return final
249
contrib/remote-helpers/test-bzr.sh
+8
-1
@@ -177,6 +177,13 @@ test_expect_success 'fetch utf-8 filenames' '
177
178
echo test >> "áéíóú" &&
179
bzr add "áéíóú" &&
180
+ echo test >> "îø∫∆" &&
181
+ bzr add "îø∫∆" &&
182
+ bzr commit -m utf-8 &&
183
+ echo test >> "áéíóú" &&
184
+ bzr commit -m utf-8 &&
185
+ bzr rm "îø∫∆" &&
186
+ bzr mv "áéíóú" "åß∂" &&
187
bzr commit -m utf-8
188
) &&
189
@@ -186,7 +193,7 @@ test_expect_success 'fetch utf-8 filenames' '
193
git ls-files > ../actual
194
) &&
195
189
- echo "\"\\303\\241\\303\\251\\303\\255\\303\\263\\303\\272\"" > expected &&
196
+ echo "\"\\303\\245\\303\\237\\342\\210\\202\"" > expected &&
197
test_cmp expected actual
198
'
199