Skip to content

Commit 5ff4fc6

Browse files
KangOlgitster
authored andcommitted
remote-bzr: fix utf-8 support for fetching
The previous patches didn't deal with all the scenarios. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0290bf1 commit 5ff4fc6

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,24 @@ def get_filechanges(cur, prev):
183183

184184
changes = cur.changes_from(prev)
185185

186+
def u(s):
187+
return s.encode('utf-8')
188+
186189
for path, fid, kind in changes.added:
187-
modified[path] = fid
190+
modified[u(path)] = fid
188191
for path, fid, kind in changes.removed:
189-
removed[path] = None
192+
removed[u(path)] = None
190193
for path, fid, kind, mod, _ in changes.modified:
191-
modified[path] = fid
194+
modified[u(path)] = fid
192195
for oldpath, newpath, fid, kind, mod, _ in changes.renamed:
193-
removed[oldpath] = None
196+
removed[u(oldpath)] = None
194197
if kind == 'directory':
195198
lst = cur.list_files(from_dir=newpath, recursive=True)
196199
for path, file_class, kind, fid, entry in lst:
197200
if kind != 'directory':
198-
modified[newpath + '/' + path] = fid
201+
modified[u(newpath + '/' + path)] = fid
199202
else:
200-
modified[newpath] = fid
203+
modified[u(newpath)] = fid
201204

202205
return modified, removed
203206

@@ -223,7 +226,7 @@ def export_files(tree, files):
223226
# is the blog already exported?
224227
if h in filenodes:
225228
mark = filenodes[h]
226-
final.append((mode, mark, path.encode('utf-8')))
229+
final.append((mode, mark, path))
227230
continue
228231

229232
d = tree.get_file_text(fid)
@@ -240,7 +243,7 @@ def export_files(tree, files):
240243
print "data %d" % len(d)
241244
print d
242245

243-
final.append((mode, mark, path.encode('utf-8')))
246+
final.append((mode, mark, path))
244247

245248
return final
246249

contrib/remote-helpers/test-bzr.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ test_expect_success 'fetch utf-8 filenames' '
177177
178178
echo test >> "áéíóú" &&
179179
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 "áéíóú" "åß∂" &&
180187
bzr commit -m utf-8
181188
) &&
182189
@@ -186,7 +193,7 @@ test_expect_success 'fetch utf-8 filenames' '
186193
git ls-files > ../actual
187194
) &&
188195
189-
echo "\"\\303\\241\\303\\251\\303\\255\\303\\263\\303\\272\"" > expected &&
196+
echo "\"\\303\\245\\303\\237\\342\\210\\202\"" > expected &&
190197
test_cmp expected actual
191198
'
192199

0 commit comments

Comments
 (0)