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

dirstate: use std::string for relpath param

Changeset 8e6c2ef3d883

Parent ceb80b618ae3

by Adrian Buehlmann

Changes to 3 files · Browse files at 8e6c2ef3d883 Showing diff from parent ceb80b618ae3 Diff from another changeset...

 
80
81
82
83
84
 
85
86
87
88
89
90
 
91
92
93
 
94
95
96
 
80
81
82
 
 
83
84
85
86
87
88
 
89
90
91
 
92
93
94
95
@@ -80,17 +80,16 @@
  offset++;   const char* relpathptr = path + offset;   - char relpath[MAX_PATH] = ""; - strncat(relpath, relpathptr, MAX_PATH); + std::string relpath = relpathptr;     char status = 0;     if (PathIsDirectory(path))   { - if (!strlen(relpath)) + if (relpath.size() == 0)   return S_FALSE; // don't show icon on repo root dir   - if (strncmp(relpath, ".hg", 3) == 0) + if (relpath.compare(0, 3, ".hg") == 0)   return S_FALSE; // don't descend into .hg dir     if (!HgQueryDirstateDirectory(hgroot.c_str(), path, relpath, status))
 
229
230
231
232
 
233
234
235
 
245
246
247
248
 
249
250
251
 
 
252
253
254
 
256
257
258
259
 
 
260
261
262
263
264
 
265
266
267
 
269
270
271
272
 
273
274
275
276
277
278
 
279
280
281
 
315
316
317
318
 
 
319
320
321
 
323
324
325
326
 
327
328
329
330
331
332
333
 
334
335
336
337
 
338
339
 
340
341
342
 
229
230
231
 
232
233
234
235
 
245
246
247
 
248
249
 
 
250
251
252
253
254
 
256
257
258
 
259
260
261
262
263
264
 
265
266
267
268
 
270
271
272
 
273
274
275
276
277
278
 
279
280
281
282
 
316
317
318
 
319
320
321
322
323
 
325
326
327
 
328
329
330
331
332
333
334
 
335
336
337
338
 
339
340
 
341
342
343
344
@@ -229,7 +229,7 @@
     int HgQueryDirstate( - const char* hgroot, const char* abspath, char* relpathloc, + const char* hgroot, const char* abspath, std::string& relpath,   const dirstate*& ppd, struct _stat& rstat)  {   if (0 != lstat(abspath, rstat)) @@ -245,10 +245,10 @@
  return 0;   }   - for (char* t = relpathloc; *t; ++t) + for (size_t i = 0; i < relpath.size(); ++i)   { - if (*t == '\\') - *t = '/'; + if (relpath[i] == '\\') + relpath[i] = '/';   }     return 1; @@ -256,12 +256,13 @@
     int HgQueryDirstateDirectory( - const char* hgroot, const char* abspath, char* relpathloc, char& outStatus) + const char* hgroot, const char* abspath, + std::string& relpath, char& outStatus)  {   const dirstate* pd = 0;   struct _stat stat;   - if (!HgQueryDirstate(hgroot, abspath, relpathloc, pd, stat)) + if (!HgQueryDirstate(hgroot, abspath, relpath, pd, stat))   return 0;     bool added = false; @@ -269,13 +270,13 @@
  bool empty = true;     size_t rootlen = strlen(hgroot); - size_t len = strlen(relpathloc); + size_t len = relpath.size();     for (unsigned ix = 0; ix < pd->entries.size() && !modified; ix++)   {   const direntry& e = pd->entries[ix];   - if (0 != strncmp(relpathloc, e.name.c_str(), len)) + if (e.name.compare(0, len, relpath) != 0)   continue;     empty = false; @@ -315,7 +316,8 @@
     int HgQueryDirstateFile( - const char* hgroot, const char* abspath, char* relpathloc, char& outStatus) + const char* hgroot, const char* abspath, + std::string& relpath, char& outStatus)  {   const dirstate* pd = 0;   struct _stat stat; @@ -323,20 +325,20 @@
  TDEBUG_TRACE("HgQueryDirstateFile: search for " << abspath);   TDEBUG_TRACE("HgQueryDirstateFile: hgroot = " << hgroot);   - if (!HgQueryDirstate(hgroot, abspath, relpathloc, pd, stat)) + if (!HgQueryDirstate(hgroot, abspath, relpath, pd, stat))   {   TDEBUG_TRACE("HgQueryDirstateFile: HgQueryDirstate returns false");   return 0;   }     TDEBUG_TRACE("HgQueryDirstateFile: pd->entries.size() = " << pd->entries.size()); - TDEBUG_TRACE("HgQueryDirstateFile: relpathloc = " << relpathloc); + TDEBUG_TRACE("HgQueryDirstateFile: relpath = " << relpath);     for (unsigned ix = 0; ix < pd->entries.size(); ix++)   { - if (0 == strncmp(relpathloc, pd->entries[ix].name.c_str(), MAX_PATH)) + if (relpath == pd->entries[ix].name)   { - TDEBUG_TRACE("HgQueryDirstateFile: found relpathloc"); + TDEBUG_TRACE("HgQueryDirstateFile: found relpath");   outStatus = mapdirstate(pd->entries[ix], stat);   TDEBUG_TRACE("HgQueryDirstateFile: outStatus = " << outStatus);   return outStatus != '?';
 
1
2
3
 
 
4
5
 
6
7
8
 
9
10
 
1
2
3
4
5
6
 
7
8
9
 
10
11
12
@@ -1,10 +1,12 @@
 #ifndef _DIRSTATE_H  #define _DIRSTATE_H   +#include <string> +  int HgQueryDirstateFile( - const char* hgroot, const char* abspath, char* relpathloc, char& outStatus); + const char* hgroot, const char* abspath, std::string& relpath, char& outStatus);    int HgQueryDirstateDirectory( - const char* hgroot, const char* abspath, char* relpathloc, char& outStatus); + const char* hgroot, const char* abspath, std::string& relpath, char& outStatus);    #endif