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

fogcreek shellext: only show Kiln on context menu for an actual Kiln repository

Changeset f83ef1d2374f

Parent fd0afa23a605

by David Golub

Changes to 3 files · Browse files at f83ef1d2374f Showing diff from parent fd0afa23a605 Diff from another changeset...

 
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
22
23
24
 
 
25
26
27
28
29
30
31
32
33
 
 
34
35
 
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
@@ -18,18 +18,38 @@
 #include "Kiln.h"  #include "QueryDirstate.h"   +bool KilnGetUrl(const CString& strPath, CString* pstrKilnUrl) +{ + CString strHgRoot; + if (!GetHgRoot(strPath, strHgRoot)) + return false; + + // 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); + if (strDefaultPath.IsEmpty()) + return false; + + // Check whether the repository is a Kiln repository. + CString strLower = strDefaultPath; + strLower.MakeLower(); + if (strLower.Find("kilnhg.com/") == -1 && strLower.Find("/kiln/") == -1) + return false; + if (pstrKilnUrl != NULL) + *pstrKilnUrl = strDefaultPath; + return true; +} +  void KilnOpenRepo(const CString& strPath)  { - CString strHgRoot; - if (GetHgRoot(strPath, strHgRoot)) + CString strKilnUrl; + if (KilnGetUrl(strPath, &strKilnUrl))   { - // 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); + // Open the repository in the default web browser + ::ShellExecute(NULL, NULL, strKilnUrl, NULL, NULL, SW_SHOW);   }  }
 
15
16
17
 
18
 
15
16
17
18
19
@@ -15,4 +15,5 @@
   #pragma once   +bool KilnGetUrl(const CString& strPath, CString* pstrKilnUrl = NULL);  void KilnOpenRepo(const CString& strPath);
 
507
508
509
 
 
510
511
512
 
533
534
535
 
 
536
537
538
 
507
508
509
510
511
512
513
514
 
535
536
537
538
539
540
541
542
@@ -507,6 +507,8 @@
  CString strName = listEntries.GetNext(position);   if (listPromoted.Find(strName) != NULL)   { + if (strName == "kiln" && !KilnGetUrl(strCwd)) + continue;   InsertMenuItemByName(hMenu, strName, indexMenu++, idCmd++, idCmdFirst, L"Hg ");   }   } @@ -533,6 +535,8 @@
  {   if (listPromoted.Find(strName) == NULL)   { + if (strName == "kiln" && !KilnGetUrl(strCwd)) + continue;   InsertMenuItemByName(hSubMenu, strName, indexSubMenu++, idCmd++,   idCmdFirst, L"");   bIsSeparator = false;