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

stable shellext: show myTortoiseClass as prefix in debug output of HgQueryDirstate

Example debug view output:

[520] [THG] [C] HgQueryDirstate: stat.lstat("W:\thg-stable\hgtk") -> stat.isdir is 0
^
(myTortoiseClass is 'C' in this example)

Current state of the overlay codebase should show only lines with "[C]", as that's the
handler which is called first by the shell extension's host (normally explorer.exe).

Other handlers ('M', 'A', '?') are called afterwards and use the cached status result
of the preceding call, which normally produces no debug out.

(as tested on Windows XP)

Changeset d7a64ec19887

Parent 0b56def06755

by Adrian Buehlmann

Changes to 3 files · Browse files at d7a64ec19887 Showing diff from parent 0b56def06755 Diff from another changeset...

 
45
46
47
48
 
49
50
51
 
45
46
47
 
48
49
50
51
@@ -45,7 +45,7 @@
  filterStatus = 'A';     char status = 0; - if (!HgQueryDirstate(path, filterStatus, status)) + if (!HgQueryDirstate(myTortoiseClass, path, filterStatus, status))   return S_FALSE;     if (status == myTortoiseClass)
 
39
40
41
42
 
43
44
45
46
 
47
48
49
50
 
51
52
53
54
55
56
57
58
59
 
60
61
 
62
63
64
65
66
67
 
68
 
 
69
70
71
72
73
74
 
75
76
77
 
80
81
82
83
84
85
86
87
88
89
 
90
91
92
 
93
94
95
 
99
100
101
102
103
104
105
106
107
108
109
 
110
111
112
 
 
 
 
113
114
115
 
118
119
120
121
 
122
123
124
 
148
149
150
151
 
 
 
 
 
152
 
 
153
154
155
 
158
159
160
161
 
162
163
164
 
168
169
170
171
 
172
173
174
175
176
177
 
178
179
180
 
209
210
211
212
213
 
 
 
 
214
215
216
 
218
219
220
221
 
222
223
224
225
226
227
228
 
 
229
230
231
 
238
239
240
241
 
242
243
244
 
257
258
259
260
261
 
262
263
264
265
 
266
267
268
269
270
271
272
 
273
274
275
276
277
 
278
279
280
 
282
283
284
285
 
286
287
288
 
39
40
41
 
42
43
44
45
 
46
47
48
49
 
50
51
 
 
 
52
53
54
55
 
56
57
 
58
59
60
61
62
63
 
64
65
66
67
68
69
70
71
 
 
72
73
74
75
 
78
79
80
 
81
82
83
84
85
 
86
87
88
 
89
90
91
92
 
96
97
98
 
 
99
100
101
102
103
 
104
105
 
 
106
107
108
109
110
111
112
 
115
116
117
 
118
119
120
121
 
145
146
147
 
148
149
150
151
152
153
154
155
156
157
158
 
161
162
163
 
164
165
166
167
 
171
172
173
 
174
175
176
177
178
179
 
180
181
182
183
 
212
213
214
 
 
215
216
217
218
219
220
221
 
223
224
225
 
226
227
228
229
230
231
 
 
232
233
234
235
236
 
243
244
245
 
246
247
248
249
 
262
263
264
 
 
265
266
267
 
 
268
269
270
271
272
273
 
 
274
275
276
277
 
 
278
279
280
281
 
283
284
285
 
286
287
288
289
@@ -39,39 +39,37 @@
  char status;   unsigned tickcount;   - QueryState(): isdir(false), status(0), tickcount(0) {} + QueryState(): isdir(false), status('0'), tickcount(0) {}  };     -bool hasHgDir(const std::string& path) +bool hasHgDir(char cls, const std::string& path)  {   bool res = false;   - if (path.empty() || path == "\\" || PathIsRoot(path.c_str())) + if (path.empty() || path == "\\" || ::PathIsRoot(path.c_str()))   { - TDEBUG_TRACE( - "hasHgDir(\"" << path << "\") -> " << res - );   return res;   }     const std::string p = path + "\\.hg"; - res = PathIsDirectory(p.c_str()) != 0; + res = ::PathIsDirectory(p.c_str()) != 0;   TDEBUG_TRACE( - "hasHgDir: PathIsDirectory(\"" << p << "\") -> " << res + "[" << cls << "] hasHgDir: PathIsDirectory(\"" << p << "\") -> " << res   );   return res;  }     -int findHgRoot(QueryState& cur, QueryState& last, bool outdated) +int findHgRoot(char cls, QueryState& cur, QueryState& last, bool outdated)  { + std::string dp = "["; dp += cls; dp += "] findHgRoot"; +   if (!PathIsNetworkPath(cur.path.c_str()))   {   cur.isdir = PathIsDirectory(cur.path.c_str());   TDEBUG_TRACE( - "findHgRoot: PathIsDirectory(\"" << cur.path - << "\") -> " << cur.isdir + dp << ": PathIsDirectory(\"" << cur.path << "\") -> " << cur.isdir   );     if (cur.isdir) @@ -80,16 +78,15 @@
  p.push_back('\\');   if (p.find(".hg\\") != std::string::npos)   { - //TDEBUG_TRACE("findHgRoot: skipping '" << cur.path << "'");   last = cur;   return 0;   }   }   - if (cur.isdir && hasHgDir(cur.path)) + if (cur.isdir && hasHgDir(cls, cur.path))   {   cur.hgroot = cur.path; - TDEBUG_TRACE("findHgRoot(" << cur.path << "): hgroot = cur.path"); + TDEBUG_TRACE(dp << "(" << cur.path << "): hgroot = cur.path");   return 1;   }   } @@ -99,17 +96,17 @@
  if (!outdated && !last.basedir.empty() && cur.basedir == last.basedir)   {   cur.hgroot = last.hgroot; - // TDEBUG_TRACE("findHgRoot(" << cur.path << "): hgroot = '" << cur.hgroot - // << "' (same as last.basedir)");   return 1;   }     for (std::string p = cur.basedir;;)   { - if (hasHgDir(p)) { + if (hasHgDir(cls, p)) {   cur.hgroot = p; - TDEBUG_TRACE("findHgRoot(" << cur.path << "): hgroot = '" << cur.hgroot - << "' (found repo)"); + TDEBUG_TRACE( + dp << "(" << cur.path << "): hgroot = '" << cur.hgroot + << "' (found repo)" + );   return 1;   }   std::string p2 = DirName(p); @@ -118,7 +115,7 @@
  p.swap(p2);   }   - TDEBUG_TRACE("findHgRoot(" << cur.path << "): NO repo found"); + TDEBUG_TRACE(dp << "(" << cur.path << "): NO repo found");   last = cur;   return 0;  } @@ -148,8 +145,14 @@
     int HgQueryDirstate( - const std::string& path, const char& filterStatus, char& outStatus) + const char cls, + const std::string& path, + const char& filterStatus, + char& outStatus +)  { + std::string dp = "["; dp += cls; dp += "] HgQueryDirstate: "; +   static QueryState last;     if (path.empty()) @@ -158,7 +161,7 @@
  QueryState cur;     cur.path = path; - cur.tickcount = GetTickCount(); + cur.tickcount = ::GetTickCount();     const bool outdated = cur.tickcount - last.tickcount > 2000;   @@ -168,13 +171,13 @@
  return 1;   }   - if (PathIsRoot(path.c_str())) + if (::PathIsRoot(path.c_str()))   {   last = cur;   return 0;   }   - if (findHgRoot(cur, last, outdated) == 0) + if (findHgRoot(cls, cur, last, outdated) == 0)   return 0;     size_t offset = cur.hgroot.length(); @@ -209,8 +212,10 @@
  Dirstate* pds = Dirstatecache::get(cur.hgroot, cur.basedir, unset);   if (!pds)   { - TDEBUG_TRACE("HgQueryDirstate: Dirstatecache::get(" - << cur.hgroot << ") returns no Dirstate"); + TDEBUG_TRACE( + dp << "Dirstatecache::get(" << cur.hgroot + << ") returns no Dirstate" + );   last = cur;   return 0;   } @@ -218,14 +223,14 @@
  Winstat stat;   if (0 != stat.lstat(path.c_str()))   { - TDEBUG_TRACE("HgQueryDirstate: lstat(" << path << ") failed"); + TDEBUG_TRACE(dp << "lstat(" << path << ") failed");   last = cur;   return 0;   }   cur.isdir = stat.isdir;   TDEBUG_TRACE( - "HgQueryDirstate: stat.lstat(\"" << cur.path - << "\") -> stat.isdir is " << stat.isdir + dp << "stat.lstat(\"" << cur.path << "\") " + << "-> stat.isdir is " << stat.isdir   );     if (cur.isdir) @@ -238,7 +243,7 @@
    outStatus = (pdirsta ? pdirsta->status(relpath) : '?');   cur.status = outStatus; - cur.tickcount = GetTickCount(); + cur.tickcount = ::GetTickCount();   last = cur;   return 1;   } @@ -257,24 +262,20 @@
  std::string relbase;   if (get_relpath(cur.hgroot, cur.basedir, relbase))   { - TDEBUG_TRACE("HgQueryDirstate: relbase = '" - << relbase << "'"); + TDEBUG_TRACE(dp << "relbase = '" << relbase << "'");     char basedir_status = pdirsta->status(relbase); - TDEBUG_TRACE("HgQueryDirstate: basedir_status = " - << basedir_status); + TDEBUG_TRACE(dp << "basedir_status = " << basedir_status);     if (basedir_status != 'M')   {   if (unset)   { - TDEBUG_TRACE( - "HgQueryDirstate: omitting Thgstatus::update"); + TDEBUG_TRACE(dp << "omitting Thgstatus::update");   }   else   { - TDEBUG_TRACE( - "HgQueryDirstate: calling Thgstatus::update"); + TDEBUG_TRACE(dp << "calling Thgstatus::update");   Thgstatus::update(cur.hgroot);   }   } @@ -282,7 +283,7 @@
  }     cur.status = outStatus; - cur.tickcount = GetTickCount(); + cur.tickcount = ::GetTickCount();   last = cur;   return 1;  }
 
4
5
6
7
 
 
 
 
 
8
9
 
4
5
6
 
7
8
9
10
11
12
13
@@ -4,6 +4,10 @@
 #include <string>    int HgQueryDirstate( - const std::string& path, const char& filterStatus, char& outStatus); + const char myClass, + const std::string& path, + const char& filterStatus, + char& outStatus +);    #endif