Changeset f83ef1d2374f…
Parent fd0afa23a605…
by
Changes to 3 files · Browse files at f83ef1d2374f Showing diff from parent fd0afa23a605 Diff from another changeset...
@@ -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,4 +15,5 @@
#pragma once
+bool KilnGetUrl(const CString& strPath, CString* pstrKilnUrl = NULL);
void KilnOpenRepo(const CString& strPath);
|
@@ -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;
|
Loading...