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 on hgroot param

Changeset f7a80abf8b8d

Parent 0bb05c596bae

by Adrian Buehlmann

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
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
 #include "stdafx.h"  #include "ShellExt.h"  #include "TortoiseUtils.h"  #include "StringUtils.h"  #include "PipeUtils.h"  #include "dirstate.h"    #include <shlwapi.h>      STDMETHODIMP CShellExt::GetOverlayInfo(LPWSTR pwszIconFile, int cchMax,   int *pIndex, DWORD *pdwFlags)  {   *pIndex = 0;   *pdwFlags = ISIOI_ICONFILE;     // get installation path   std::string dir = GetTHgProgRoot();   if (dir.empty())   {   TDEBUG_TRACE("GetOverlayInfo: THG root is empty");   wcsncpy(pwszIconFile, L"", cchMax);   return S_OK;   }     // find icon per overlay type   std::wstring dirWide = MultibyteToWide(dir);   wcsncpy(pwszIconFile, dirWide.c_str(), cchMax);   cchMax -= static_cast<int>(dirWide.size()) + 1;  /*   switch (myTortoiseClass)   {   case TORTOISE_OLE_ADDED:   wcsncat(pwszIconFile, L"\\icons\\status\\added.ico", cchMax);   break;   case TORTOISE_OLE_MODIFIED:   wcsncat(pwszIconFile, L"\\icons\\status\\changed.ico", cchMax);   break;   case TORTOISE_OLE_UNCHANGED:   wcsncat(pwszIconFile, L"\\icons\\status\\unchanged.ico", cchMax);   break;   default:   break;   }  */   std::string path = WideToMultibyte(pwszIconFile);   TDEBUG_TRACE("GetOverlayInfo: icon path = " << path);     return S_OK;  }    STDMETHODIMP CShellExt::GetPriority(int *pPriority)  {   *pPriority = 1;   return S_OK;  }      STDMETHODIMP CShellExt::IsMemberOf(LPCWSTR pwszPath, DWORD /* dwAttrib */)  {   std::string mbstr = WideToMultibyte(pwszPath);     TDEBUG_TRACE("IsMemberOf: search for " << mbstr.c_str());     char path[MAX_PATH] = "";   strncat(path, mbstr.c_str(), MAX_PATH);     std::string hgroot = GetHgRepoRoot(path);     if (hgroot.empty())   {   TDEBUG_TRACE("IsMemberOf: Not a Hg repo (hgroot is empty)");   return S_FALSE;   }     TDEBUG_TRACE("IsMemberOf: hgroot = " << hgroot);     size_t offset = hgroot.length();   if (path[offset] == '\\')   offset++;   const char* relpathptr = path + offset;     std::string relpath = relpathptr;     char status = 0;     if (PathIsDirectory(path))   {   if (relpath.size() == 0)   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   - if (!HgQueryDirstateDirectory(hgroot.c_str(), path, relpath, status)) + if (!HgQueryDirstateDirectory(hgroot, path, relpath, status))   {   TDEBUG_TRACE("IsMemberOf: HgQueryDirstateDirectory returns false");   return S_FALSE;   }   }   else   { - if (!HgQueryDirstateFile(hgroot.c_str(), path, relpath, status)) + if (!HgQueryDirstateFile(hgroot, path, relpath, status))   {   TDEBUG_TRACE("IsMemberOf: HgQueryDirstateFile returns false");   return S_FALSE;   }   }     TDEBUG_TRACE("IsMemberOf: status = " << status);     if (myTortoiseClass == TORTOISE_OLE_ADDED && status == 'A')   return S_OK;   else if (myTortoiseClass == TORTOISE_OLE_MODIFIED && status == 'M')   return S_OK;   else if (myTortoiseClass == TORTOISE_OLE_UNCHANGED && status == 'C')   return S_OK;     return S_FALSE;  }
 
231
232
233
234
 
235
236
237
 
258
259
260
261
 
262
263
264
 
271
272
273
274
 
275
276
277
 
319
320
321
322
 
323
324
325
 
231
232
233
 
234
235
236
237
 
258
259
260
 
261
262
263
264
 
271
272
273
 
274
275
276
277
 
319
320
321
 
322
323
324
325
@@ -231,7 +231,7 @@
     int HgQueryDirstate( - const char* hgroot, const char* abspath, std::string& relpath, + const std::string& hgroot, const char* abspath, std::string& relpath,   const dirstate*& ppd, struct _stat& rstat)  {   if (0 != lstat(abspath, rstat)) @@ -258,7 +258,7 @@
     int HgQueryDirstateDirectory( - const char* hgroot, const char* abspath, + const std::string& hgroot, const char* abspath,   std::string& relpath, char& outStatus)  {   const dirstate* pd = 0; @@ -271,7 +271,7 @@
  bool modified = false;   bool empty = true;   - size_t rootlen = strlen(hgroot); + size_t rootlen = hgroot.size();   size_t len = relpath.size();     for (dirstate::Iter iter = pd->entries.begin(); @@ -319,7 +319,7 @@
     int HgQueryDirstateFile( - const char* hgroot, const char* abspath, + const std::string& hgroot, const char* abspath,   std::string& relpath, char& outStatus)  {   const dirstate* pd = 0;
 
4
5
6
7
 
 
8
9
10
 
 
11
12
 
4
5
6
 
7
8
9
10
 
11
12
13
14
@@ -4,9 +4,11 @@
 #include <string>    int HgQueryDirstateFile( - const char* hgroot, const char* abspath, std::string& relpath, char& outStatus); + const std::string& hgroot, const char* abspath, + std::string& relpath, char& outStatus);    int HgQueryDirstateDirectory( - const char* hgroot, const char* abspath, std::string& relpath, char& outStatus); + const std::string& hgroot, const char* abspath, + std::string& relpath, char& outStatus);    #endif