Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8.1, 0.8.2, and 0.8.3

shellext: teach DirectoryStatus to detect '@@noicons' in .hg/thgstatus

this will allow to disable the overlay icons per repository if
.hg/thgstatus begins with the string '@@noicons'

Changeset 994997ccbc85

Parent 6f56035923d6

by Adrian Buehlmann

Changes to 2 files · Browse files at 994997ccbc85 Showing diff from parent 6f56035923d6 Diff from another changeset...

 
59
60
61
 
62
63
64
 
71
72
73
74
75
76
77
78
79
 
 
 
 
 
 
80
81
 
 
82
83
84
85
 
86
87
88
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
91
92
93
94
 
95
96
97
98
 
99
100
101
102
 
103
104
 
105
106
107
 
59
60
61
62
63
64
65
 
72
73
74
 
 
 
75
76
 
77
78
79
80
81
82
83
 
84
85
86
 
 
 
87
88
 
 
 
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 
121
 
122
123
124
125
126
127
128
129
130
 
131
132
 
133
134
135
136
@@ -59,6 +59,7 @@
 int DirectoryStatus::read(const std::string& hgroot, const std::string& cwd)  {   v_.clear(); + noicons_ = false;     std::string p = hgroot + "\\.hg\\thgstatus";   @@ -71,37 +72,65 @@
  return 0;   }   - char state; - std::vector<char> path(MAX_PATH); -   DirectoryStatus::E e;   - while (fread(&state, sizeof(state), 1, f) == 1) + int res = 1; + const std::string noicons = "@@noicons"; + + std::vector<char> vline(200); + + for (;;)   { - e.status_ = state; + vline.clear(); + char t;   - path.clear(); - char t; - while (fread(&t, sizeof(t), 1, f) == 1 && t != '\n') + for (;;)   { - path.push_back(t); - if (path.size() > 1000) - return 0; + if (fread(&t, sizeof(t), 1, f) != 1) + goto close; + if (t == '\n') + break; + vline.push_back(t); + if (vline.size() > 1000) + { + res = 0; + goto close; + } + } + vline.push_back(0); + + std::string line = &vline[0]; + + if (line.substr(0, noicons.size()) == noicons) + { + noicons_ = true; + goto close; + } + + if (line.empty()) + goto close; + + e.status_ = line[0]; + + std::string path; + if (line.size() > 1) + { + path = line.c_str() + 1;   }   path.push_back('/'); - path.push_back(0);   - e.path_ = &path[0]; + e.path_ = path;     v_.push_back(e);   }   +close:   fclose(f);     TDEBUG_TRACE("DirectoryStatus::read(" << hgroot << "): done. " - << v_.size() << " entries read"); + << v_.size() << " entries read. noicons_ = " << noicons_ );   - return 1; + return res;  }    
 
30
31
32
 
33
34
 
 
35
36
37
 
38
39
40
 
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@@ -30,11 +30,15 @@
    typedef std::vector<E> V;   V v_; + bool noicons_;    public: + DirectoryStatus(): noicons_(false) {} +   static DirectoryStatus* get(   const std::string& hgroot, const std::string& cwd);   char status(const std::string& relpath) const; + bool noicons() const { return noicons_; }    private:   int read(const std::string& hgroot, const std::string& cwd);