Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek shellext: added support for opening repository in Kiln

Changeset fd0afa23a605

Parent 5fa9e28d34c9

by David Golub

Changes to 8 files · Browse files at fd0afa23a605 Showing diff from parent 5fa9e28d34c9 Diff from another changeset...

Added image
Change 1 of 1 Show Entire File win32/​shellext/​Kiln.cpp Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@@ -0,0 +1,35 @@
+// Copyright (C) 2011 Fog Creek Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. + +#include "stdafx.h" + +#include "Kiln.h" +#include "QueryDirstate.h" + +void KilnOpenRepo(const CString& strPath) +{ + CString strHgRoot; + if (GetHgRoot(strPath, strHgRoot)) + { + // Try to get the default path from hgrc + CString strHgrcPath = strHgRoot + "\\.hg\\hgrc"; + CString strDefaultPath; + LPTSTR lpszBuf = strDefaultPath.GetBuffer(MAX_PATH + 1); + DWORD nSize = ::GetPrivateProfileString("paths", "default", "", lpszBuf, + MAX_PATH, strHgrcPath); + strDefaultPath.ReleaseBuffer(nSize); + ::ShellExecute(NULL, NULL, strDefaultPath, NULL, NULL, SW_SHOW); + } +}
Change 1 of 1 Show Entire File win32/​shellext/​Kiln.h Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@@ -0,0 +1,18 @@
+// Copyright (C) 2011 Fog Creek Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. + +#pragma once + +void KilnOpenRepo(const CString& strPath);
 
200
201
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
204
205
 
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
@@ -200,6 +200,41 @@
  return 1;  }   +int GetHgRoot(const CString &strPath, CString& strHgRoot) +{ + static CQueryState qsLast; + + if (strPath.IsEmpty()) + return 0; + + CQueryState qsCur; + + qsCur.strPath = strPath; + qsCur.uTickCount = ::GetTickCount(); + + bool bOutdated = qsCur.uTickCount - qsLast.uTickCount > 2000; + + if (!bOutdated && qsLast.strPath == strPath) + { + strHgRoot = qsLast.strHgRoot; + return 1; + } + + if (::PathIsRoot(strPath)) + { + qsLast = qsCur; + return 0; + } + + if (FindHgRoot('0', qsCur, qsLast, bOutdated) == 0) + return 0; + + if (qsCur.strHgRoot.IsEmpty()) + return 0; + + strHgRoot = qsCur.strHgRoot; + return 1; +}    int HgQueryDirstate(char chClass, const CString& strPath, char chFilterStatus,   char& chOutStatus)
 
15
16
17
 
18
19
 
15
16
17
18
19
20
@@ -15,5 +15,6 @@
   #pragma once   +int GetHgRoot(const CString& strPath, CString& strHgRoot);  int HgQueryDirstate(char chClass, const CString& strPath, char chFilterStatus,   char& chOutStatus);
 
206
207
208
 
209
210
211
 
233
234
235
 
236
237
238
 
206
207
208
209
210
211
212
 
234
235
236
237
238
239
240
@@ -206,6 +206,7 @@
  <ClCompile Include="Dirstate.cpp" />   <ClCompile Include="DirstateCache.cpp" />   <ClCompile Include="IconBitmapUtils.cpp" /> + <ClCompile Include="Kiln.cpp" />   <ClCompile Include="QueryDirstate.cpp" />   <ClCompile Include="RegistryConfig.cpp" />   <ClCompile Include="stdafx.cpp"> @@ -233,6 +234,7 @@
  <ClInclude Include="Dirstate.h" />   <ClInclude Include="DirstateCache.h" />   <ClInclude Include="IconBitmapUtils.h" /> + <ClInclude Include="Kiln.h" />   <ClInclude Include="QueryDirstate.h" />   <ClInclude Include="RegistryConfig.h" />   <ClInclude Include="resource.h" />
 
75
76
77
 
 
 
78
79
80
 
137
138
139
 
 
 
140
141
142
 
75
76
77
78
79
80
81
82
83
 
140
141
142
143
144
145
146
147
148
@@ -75,6 +75,9 @@
  <ClCompile Include="stdafx.cpp">   <Filter>Source Files</Filter>   </ClCompile> + <ClCompile Include="Kiln.cpp"> + <Filter>Source Files</Filter> + </ClCompile>   </ItemGroup>   <ItemGroup>   <ClInclude Include="Directory.h"> @@ -137,6 +140,9 @@
  <ClInclude Include="resource.h">   <Filter>Header Files</Filter>   </ClInclude> + <ClInclude Include="Kiln.h"> + <Filter>Header Files</Filter> + </ClInclude>   </ItemGroup>   <ItemGroup>   <None Include="THgShell.def">
 
25
26
27
 
28
29
30
 
108
109
110
 
 
 
111
112
113
 
119
120
121
122
 
123
124
125
 
136
137
138
 
 
139
140
141
 
428
429
430
431
 
432
433
434
 
805
806
807
 
 
 
 
 
808
809
810
 
25
26
27
28
29
30
31
 
109
110
111
112
113
114
115
116
117
 
123
124
125
 
126
127
128
129
 
140
141
142
143
144
145
146
147
 
434
435
436
 
437
438
439
440
 
811
812
813
814
815
816
817
818
819
820
821
@@ -25,6 +25,7 @@
 #include "TortoiseIconBitmap.h"  #include "THgVersion.h"  #include "TortoiseHgCmenu.h" +#include "Kiln.h"    #include <msi.h>   @@ -108,6 +109,9 @@
  { "shellconf", L"Explorer Extension Settings",   L"Configures the Explorer extension.",   "settings_repo.ico", 0}, + { "kiln", L"Kiln", + L"Opens the current repository in Kiln.", + "kiln.ico", 0 },     // Add new items here.   // Template: @@ -119,7 +123,7 @@
 static const char* const RepoNoFilesMenu =   "commit status shelve vdiff sep"   " add revert rename forget remove sep" - " workbench update grep sep" + " workbench update grep sep kiln sep"   " synch serve clone init thgstatus sep"   " hgignore guess sep"   " shellconf repoconf userconf sep" @@ -136,6 +140,8 @@
  " workbench sep"   " about";   +static const LPCTSTR DefaultPromotedString = "commit,workbench,kiln"; +  void CTortoiseHgCmenuBase::AddMenuList(UINT idCmd, const CString& strName)  {   ATLTRACE("AddMenuList: idCmd = %d, name = '%s'\n", idCmd, strName); @@ -428,7 +434,7 @@
    InitMenuMaps(MenuDescList, sizeof(MenuDescList) / sizeof(CMenuDescription));   - CString promoted_string = "commit,workbench"; // default value if key not found + CString promoted_string = DefaultPromotedString; // default value if key not found   GetRegistryConfig("PromotedItems", promoted_string);     CAtlList<CString> listPromoted; @@ -805,6 +811,11 @@
  }   return;   } + else if (strCmd == "kiln") + { + KilnOpenRepo(strCwd); + return; + }     if (!m_arrFiles.IsEmpty())   {