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

IconOverlay: move more code into HgQueryDirstate

HgQueryDirstate now has only two params

Changeset 422e9c472bbb

Parent 55964a9ffccd

by Adrian Buehlmann

Changes to 3 files · Browse files at 422e9c472bbb Showing diff from parent 55964a9ffccd Diff from another changeset...

 
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
83
84
85
 
60
61
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
65
66
67
@@ -60,26 +60,8 @@
 {   std::string path = WideToMultibyte(pwszPath);   - std::string hgroot = GetHgRepoRoot(path); - - if (hgroot.empty()) - return S_FALSE; - - size_t offset = hgroot.length(); - if (path[offset] == '\\') - offset++; - const char* relpathptr = path.c_str() + offset; - - const std::string relpath = relpathptr; - - if (relpath.empty()) - return S_FALSE; // don't show icon on repo root dir - - if (relpath.compare(0, 3, ".hg") == 0) - return S_FALSE; // don't descend into .hg dir -   char status = 0; - if (!HgQueryDirstate(hgroot, path, relpath, status)) + if (!HgQueryDirstate(path, status))   return S_FALSE;     if (myTortoiseClass == TORTOISE_OLE_ADDED && status == 'A')
 
17
18
19
 
20
21
22
 
320
321
322
323
324
325
 
326
327
328
 
329
330
 
331
332
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
335
336
 
338
339
340
341
342
343
344
 
347
348
349
350
 
351
352
353
 
17
18
19
20
21
22
23
 
321
322
323
 
 
 
324
325
326
 
327
328
 
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
 
355
356
357
 
358
359
360
 
363
364
365
 
366
367
368
369
@@ -17,6 +17,7 @@
 #include "stdafx.h"    #include "dirstate.h" +#include "TortoiseUtils.h"    #include <shlwapi.h>   @@ -320,17 +321,33 @@
 }     -int HgQueryDirstate( - const std::string& hgroot, const std::string& abspath, - const std::string& relpath_in, char& outStatus) +int HgQueryDirstate(const std::string& path, char& outStatus)  {   struct _stat stat; - if (0 != lstat(abspath.c_str(), stat)) + if (0 != lstat(path.c_str(), stat))   { - TDEBUG_TRACE("HgQueryDirstate: lstat(" << abspath << ") fails"); + TDEBUG_TRACE("HgQueryDirstate: lstat(" << path << ") fails");   return 0;   }   + std::string hgroot = GetHgRepoRoot(path); + + if (hgroot.empty()) + return 0; + + size_t offset = hgroot.length(); + if (path[offset] == '\\') + offset++; + const char* relpathptr = path.c_str() + offset; + + std::string relpath = relpathptr; + + if (relpath.empty()) + return 0; // don't show icon on repo root dir + + if (relpath.compare(0, 3, ".hg") == 0) + return 0; // don't descend into .hg dir +   const dirstate* pd = dirstatecache::get(hgroot);   if (!pd)   { @@ -338,7 +355,6 @@
  return 0;   }   - std::string relpath = relpath_in;   for (size_t i = 0; i < relpath.size(); ++i)   {   if (relpath[i] == '\\') @@ -347,7 +363,7 @@
    int res = 0;   - if (PathIsDirectory(abspath.c_str())) + if (PathIsDirectory(path.c_str()))   res = HgQueryDirstateDirectory(hgroot, pd, relpath, outStatus);   else   res = HgQueryDirstateFile(pd, relpath, stat, outStatus);
 
3
4
5
6
7
8
 
9
10
 
3
4
5
 
 
 
6
7
8
@@ -3,8 +3,6 @@
   #include <string>   -int HgQueryDirstate( - const std::string& hgroot, const std::string& abspath, - const std::string& relpath, char& outStatus); +int HgQueryDirstate(const std::string& path, char& outStatus);    #endif