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

shellext: formatting/white space cleanup in TortoiseUtils.cpp

Changeset fdc794881ed6

Parent 8feb5e4dd752

by Adrian Buehlmann

Changes to one file · Browse files at fdc794881ed6 Showing diff from parent 8feb5e4dd752 Diff from another changeset...

 
8
9
10
11
12
13
14
15
16
 
 
 
 
 
 
17
18
 
19
20
21
22
23
24
25
26
 
 
 
 
 
 
27
28
 
29
30
31
 
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
121
 
149
150
151
 
152
153
154
 
168
169
170
 
171
172
173
 
189
190
191
 
192
193
194
 
205
206
207
 
208
209
210
 
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
 
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
121
122
123
124
125
126
 
154
155
156
157
158
159
160
 
174
175
176
177
178
179
180
 
196
197
198
199
200
201
202
 
213
214
215
216
217
218
219
@@ -8,24 +8,26 @@
   LPWSTR hf_mbtowc(LPWSTR lpw, LPCSTR lpa, int nChars)  { - assert(lpa != NULL); - assert(lpw != NULL); - - lpw[0] = '\0'; - MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars); - return lpw; + assert(lpa != NULL); + assert(lpw != NULL); + + lpw[0] = '\0'; + MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars); + return lpw;  }   +  LPSTR hf_wctomb(LPSTR lpa, LPCWSTR lpw, int nChars)  { - assert(lpw != NULL); - assert(lpa != NULL); - - lpa[0] = '\0'; - WideCharToMultiByte(CP_ACP, 0, lpw, -1, lpa, nChars, NULL, NULL); - return lpa; + assert(lpw != NULL); + assert(lpa != NULL); + + lpa[0] = '\0'; + WideCharToMultiByte(CP_ACP, 0, lpw, -1, lpa, nChars, NULL, NULL); + return lpa;  }   +  std::string GetTHgShellRoot()  {   LPCSTR regname = "Software\\TortoiseHgShell"; @@ -89,33 +91,36 @@
 // (see http://www.encocoservices.com/createprocess.html)  bool LaunchCommand(const std::string& command, const std::string& cwd)  { - TDEBUG_TRACE("LaunchCommand: " << command); - TDEBUG_TRACE("LaunchCommand: in " << cwd); - PROCESS_INFORMATION processInfo; - memset(&processInfo, 0, sizeof(processInfo)); + TDEBUG_TRACE("LaunchCommand: " << command); + TDEBUG_TRACE("LaunchCommand: in " << cwd); + PROCESS_INFORMATION processInfo; + memset(&processInfo, 0, sizeof(processInfo));   - STARTUPINFOA startupInfo; - memset(&startupInfo, 0, sizeof(startupInfo)); + STARTUPINFOA startupInfo; + memset(&startupInfo, 0, sizeof(startupInfo));   - int res = CreateProcessA(NULL, // No module name, use command line - const_cast<char*>(command.c_str()), - NULL, // Process handle not inherited - NULL, // Thread handle not inherited - FALSE, - CREATE_NO_WINDOW, - NULL, // use parent's environment - const_cast<char*>(cwd.c_str()), - &startupInfo, - &processInfo); - if (res == 0) - { - TDEBUG_TRACE("LaunchCommand: failed to launch"); - return false; - } + int res = CreateProcessA( + NULL, // No module name, use command line + const_cast<char*>(command.c_str()), + NULL, // Process handle not inherited + NULL, // Thread handle not inherited + FALSE, + CREATE_NO_WINDOW, + NULL, // use parent's environment + const_cast<char*>(cwd.c_str()), + &startupInfo, + &processInfo + );   - CloseHandle(processInfo.hProcess); - CloseHandle(processInfo.hThread); - return true; + if (res == 0) + { + TDEBUG_TRACE("LaunchCommand: failed to launch"); + return false; + } + + CloseHandle(processInfo.hProcess); + CloseHandle(processInfo.hThread); + return true;  }    std::string GetTemporaryFile(LPCTSTR prefix) @@ -149,6 +154,7 @@
  return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;  }   +  std::string DirName(const std::string& filename)  {   if (filename.empty()) @@ -168,6 +174,7 @@
  return filename.substr(pos+1);  }   +  HICON GetTortoiseIcon(const std::string& iconname)  {   std::string thgdir = GetTHgProgRoot(); @@ -189,6 +196,7 @@
  return h;  }   +  std::string GetHgRepoRoot(const std::string& path)  {   std::string p = IsDirectory(path)? path : DirName(path); @@ -205,6 +213,7 @@
  return p;  }   +  bool IsHgRepo(const std::string& path)  {   return !GetHgRepoRoot(path).empty();