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

IconOverlay.cpp: skip empty and .hg relpaths unconditionally

Changeset f73593b0512f

Parent dbf731e75c2f

by Adrian Buehlmann

Changes to one file · Browse files at f73593b0512f Showing diff from parent dbf731e75c2f 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
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
 #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 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;     std::string relpath = relpathptr;   + 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 +   char status = 0;     if (PathIsDirectory(path.c_str()))   { - 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, path, relpath, status))   return S_FALSE;   }   else   {   if (!HgQueryDirstateFile(hgroot, path, relpath, status))   return S_FALSE;   }     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;  }