Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

manifestmodel: handle non-ascii filenames

Changeset db7648fa51d4

Parent 8e525e1b6b45

by Yuya Nishihara

Changes to 4 files · Browse files at db7648fa51d4 Showing diff from parent 8e525e1b6b45 Diff from another changeset...

Change 1 of 1 Show Entire File tests/​fixtures/​euc-jp-path.diff Stacked
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
@@ -0,0 +1,9 @@
+# HG changeset patch +# User test +# Date 0 0 +# Node ID b124d3c17d0d93e83d26c00d7a176c02c42d73d1 +# Parent 0000000000000000000000000000000000000000 +add aloha + +diff --git a/����ϡ� b/����ϡ� +new file mode 100644
 
1
2
3
4
 
 
 
5
6
7
8
 
 
 
 
9
10
11
 
 
12
13
14
 
26
27
28
 
 
 
 
 
29
30
31
 
51
52
53
 
 
 
 
 
54
55
56
 
58
59
60
 
 
 
 
 
61
62
63
 
1
2
3
 
4
5
6
7
8
 
 
9
10
11
12
13
 
 
14
15
16
17
18
 
30
31
32
33
34
35
36
37
38
39
40
 
60
61
62
63
64
65
66
67
68
69
70
 
72
73
74
75
76
77
78
79
80
81
82
@@ -1,14 +1,18 @@
 from nose.tools import *  from PyQt4.QtCore import QModelIndex  from tortoisehg.hgqt.manifestmodel import ManifestModel -from tests import get_fixture_repo +from tests import get_fixture_repo, with_encoding + +_aloha_ja = u'\u3042\u308d\u306f\u30fc'    def setup(): - global _repo - _repo = get_fixture_repo('subdirs') + global _repos + _repos = {} + for name in ('subdirs', 'euc-jp-path'): + _repos[name] = get_fixture_repo(name)   -def newmodel(rev=0): - return ManifestModel(_repo, rev=rev) +def newmodel(name='subdirs', rev=0): + return ManifestModel(_repos[name], rev=rev)    def test_data():   m = newmodel() @@ -26,6 +30,11 @@
  assert_equals(None, m.data(QModelIndex()))   assert_equals(None, m.data(m.index(0, 0, m.index(1, 0))))   +@with_encoding('euc-jp') +def test_data_eucjp(): + m = newmodel(name='euc-jp-path') + assert_equals(_aloha_ja, m.data(m.index(0, 0))) +  def test_isdir():   m = newmodel()   assert m.isDir(m.indexFromPath('')) @@ -51,6 +60,11 @@
  assert_equals('baz', m.filePath(m.index(0, 0)))   assert_equals('baz/bax', m.filePath(m.index(0, 0, m.index(0, 0))))   +@with_encoding('euc-jp') +def test_pathfromindex_eucjp(): + m = newmodel(name='euc-jp-path') + assert_equals(_aloha_ja, m.filePath(m.index(0, 0))) +  def test_indexfrompath():   m = newmodel()   assert_equals(QModelIndex(), m.indexFromPath('')) @@ -58,6 +72,11 @@
  assert_equals(m.index(0, 0), m.indexFromPath('baz'))   assert_equals(m.index(0, 0, m.index(0, 0)), m.indexFromPath('baz/bax'))   +@with_encoding('euc-jp') +def test_indexfrompath_eucjp(): + m = newmodel(name='euc-jp-path') + assert_equals(m.index(0, 0), m.indexFromPath(_aloha_ja)) +  def test_removed_should_be_listed():   m = newmodel(rev=1)   m.setStatusFilter('MARC')
 
212
213
214
215
 
216
217
218
 
212
213
214
 
215
216
217
218
@@ -212,7 +212,7 @@
    @pyqtSlot()   def _updatecontent(self): - if self.path not in self._repo[self._rev]: + if hglib.fromunicode(self.path) not in self._repo[self._rev]:   self._contentview.setCurrentWidget(self._nullcontent)   return  
 
14
15
16
 
17
18
19
 
48
49
50
 
51
52
53
 
112
113
114
115
 
 
 
 
116
117
118
 
194
195
196
197
 
198
199
200
 
14
15
16
17
18
19
20
 
49
50
51
52
53
54
55
 
114
115
116
 
117
118
119
120
121
122
123
 
199
200
201
 
202
203
204
205
@@ -14,6 +14,7 @@
 from PyQt4.QtGui import *    from mercurial import util +from tortoisehg.util import hglib  from tortoisehg.hgqt import qtlib, status, visdiff    class ManifestModel(QAbstractItemModel): @@ -48,6 +49,7 @@
  return e.name     def filePath(self, index): + """Return path at the given index [unicode]"""   if not index.isValid():   return ''   @@ -112,7 +114,10 @@
  return QModelIndex()     def indexFromPath(self, path, column=0): - """Return index for the specified path if found; otherwise invalid index""" + """Return index for the specified path if found [unicode] + + If not found, returns invalid index. + """   if not path:   return QModelIndex()   @@ -194,7 +199,7 @@
  continue     e = roote - for p in path.split('/'): + for p in hglib.tounicode(path).split('/'):   if not p in e:   e.addchild(p)   e = e[p]