Changeset 1f51c7f62171…
Parent 0b8f7055dad4…
by
Changes to 10 files · Browse files at 1f51c7f62171 Showing diff from parent 0b8f7055dad4 Diff from another changeset...
@@ -54,7 +54,7 @@ }
}
-void KilnOpenFiles(HWND hWnd, const CString& strPath, const CAtlArray<CString>& arrFiles)
+void KilnOpenFiles(HWND hWnd, const CString& strPath, const CAtlList<CString>& listFiles)
{
CString strKilnUrl;
if (KilnGetUrl(strPath, &strKilnUrl))
@@ -67,10 +67,12 @@ GetHgRoot(strPath, strHgRoot);
// Open each file in the default web browser
- for (int i = 0; i < arrFiles.GetCount(); i++)
+ POSITION position = listFiles.GetHeadPosition();
+ while (position != NULL)
{
+ CString strFile = listFiles.GetNext(position);
CString strRelPath;
- GetRelPath(strHgRoot, arrFiles[i], strRelPath);
+ GetRelPath(strHgRoot, strFile, strRelPath);
::ShellExecute(hWnd, NULL, strKilnUrl + strRelPath, NULL, NULL, SW_SHOW);
}
}
|
@@ -18,4 +18,4 @@ bool KilnGetUrl(const CString& strPath, CString* pstrKilnUrl = NULL);
void KilnOpenRepo(HWND hWnd, const CString& strPath);
void KilnOpenFiles(HWND hWnd, const CString& strPath,
- const CAtlArray<CString>& arrFiles);
+ const CAtlList<CString>& arrFiles);
|
|
|
@@ -0,0 +1,134 @@ + // 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 "RunDialog.h"
+#include "TortoiseUtils.h"
+#include "StringUtils.h"
+#include "THgStatus.h"
+#include "Kiln.h"
+
+void RunDialog(HWND hWnd, const CString& strCmd, const CAtlList<CString>& listFiles,
+ const CString& strFolder)
+{
+ CString strDir = GetTHgProgRoot();
+ if (strDir.IsEmpty())
+ {
+ ATLTRACE("RunDialog: THG root is empty\n");
+ return;
+ }
+ CString strHgCmd = strDir + "\\thgw.exe";
+
+ WIN32_FIND_DATA data;
+ HANDLE hFind = ::FindFirstFile(strHgCmd, &data);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ strHgCmd = strDir + "\\hgtk.exe";
+ hFind = ::FindFirstFile(strHgCmd, &data);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ strHgCmd = strDir + "\\thg.cmd";
+ }
+ else
+ {
+ ::FindClose(hFind);
+ }
+ }
+ else
+ {
+ ::FindClose(hFind);
+ }
+
+ strHgCmd = Quote(strHgCmd) + " --nofork " + strCmd;
+
+ CString strCwd;
+ if (!strFolder.IsEmpty())
+ {
+ strCwd = strFolder;
+ }
+ else if (!listFiles.IsEmpty())
+ {
+ strCwd = listFiles.GetHead();
+ if (!::PathIsDirectory(strCwd)) strCwd = DirName(strCwd);
+ }
+ else
+ {
+ ATLTRACE("***** RunDialog: can't get cwd\n");
+ return;
+ }
+
+ if (strCmd == "thgstatus")
+ {
+ if (CTHgStatus::Remove(strCwd) != 0)
+ {
+ CString strPath = strDir + "\\TortoiseHgOverlayServer.exe";
+ LaunchCommand(Quote(strPath), strDir);
+ }
+ return;
+ }
+ else if (strCmd == "kiln")
+ {
+ KilnOpenRepo(hWnd, strCwd);
+ return;
+ }
+ else if (strCmd == "kilnfiles")
+ {
+ KilnOpenFiles(hWnd, strCwd, listFiles);
+ return;
+ }
+
+ if (!listFiles.IsEmpty())
+ {
+ CString strTempFile = GetTemporaryFile();
+ if (strTempFile.IsEmpty())
+ {
+ ATLTRACE("***** RunDialog: error: GetTemporaryFile returned empty string\n");
+ return;
+ }
+
+ ATLTRACE("RunDialog: temp file = %s\n", (LPCTSTR)strTempFile);
+ HANDLE hTempFile = ::CreateFile(strTempFile, GENERIC_WRITE, FILE_SHARE_READ, 0,
+ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+
+ if (hTempFile == INVALID_HANDLE_VALUE)
+ {
+ ATLTRACE("***** RunDialog: error: failed to create file '%s'\n",
+ (LPCTSTR)strTempFile);
+ return;
+ }
+
+ DWORD dwWritten;
+ POSITION position = listFiles.GetHeadPosition();
+ while (position != NULL)
+ {
+ CString strFile = listFiles.GetNext(position);
+ ATLTRACE("RunDialog: temp file adding '%s'\n", (LPCTSTR)strFile);
+ ::WriteFile(hTempFile, (LPCTSTR)strFile, strFile.GetLength(), &dwWritten, 0);
+ ::WriteFile(hTempFile, "\n", 1, &dwWritten, 0);
+ }
+ if (strCmd == "drag_move" || strCmd == "drag_copy")
+ {
+ // Append the current directory as the dest.
+ ::WriteFile(hTempFile, (LPCTSTR)strCwd, strCwd.GetLength(), &dwWritten, 0);
+ ::WriteFile(hTempFile, "\n", 1, &dwWritten, 0);
+ }
+
+ ::CloseHandle(hTempFile);
+ strHgCmd += " --listfile " + Quote(strTempFile);
+ }
+
+ LaunchCommand(strHgCmd, strCwd);
+}
|
|
@@ -0,0 +1,19 @@ + // 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 RunDialog(HWND hWnd, const CString& strCmd, const CAtlList<CString>& listFiles,
+ const CString& strFolder = "");
|
@@ -209,6 +209,7 @@ <ClCompile Include="Kiln.cpp" />
<ClCompile Include="QueryDirstate.cpp" />
<ClCompile Include="RegistryConfig.cpp" />
+ <ClCompile Include="RunDialog.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
@@ -239,6 +240,7 @@ <ClInclude Include="QueryDirstate.h" />
<ClInclude Include="RegistryConfig.h" />
<ClInclude Include="resource.h" />
+ <ClInclude Include="RunDialog.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="StringUtils.h" />
<ClInclude Include="SysInfo.h" />
|
@@ -81,6 +81,9 @@ <ClCompile Include="TortoiseHgKeyboard.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="RunDialog.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Directory.h">
@@ -149,6 +152,9 @@ <ClInclude Include="TortoiseHgKeyboard.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="RunDialog.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="THgShell.def">
|
|
@@ -25,6 +25,7 @@ #include "TortoiseIconBitmap.h"
#include "THgVersion.h"
#include "TortoiseHgCmenu.h"
+#include "RunDialog.h"
#include "Kiln.h"
#include <msi.h>
@@ -490,7 +491,7 @@ Tokenize(promoted_string, listPromoted, ",");
// Select menu to show
- bool bFileMenu = !m_arrFiles.IsEmpty();
+ bool bFileMenu = !m_listFiles.IsEmpty();
bool bIsHgRepo = false;
CString strCwd;
if (!m_strFolder.IsEmpty())
@@ -499,7 +500,8 @@ }
else if (bFileMenu)
{
- strCwd = ::PathIsDirectory(m_arrFiles[0]) ? m_arrFiles[0] : DirName(m_arrFiles[0]);
+ strCwd = m_listFiles.GetHead();
+ if (!::PathIsDirectory(strCwd)) strCwd = DirName(strCwd);
}
if (!strCwd.IsEmpty())
@@ -507,11 +509,11 @@ // check if target directory is a Mercurial repository
CString strRoot = GetHgRepoRoot(strCwd);
bIsHgRepo = !strRoot.IsEmpty();
- if (m_arrFiles.GetCount() == 1 && strRoot == m_arrFiles[0])
+ if (m_listFiles.GetCount() == 1 && strRoot == m_listFiles.GetHead())
{
bFileMenu = false;
m_strFolder = strCwd;
- m_arrFiles.RemoveAll();
+ m_listFiles.RemoveAll();
}
}
@@ -633,7 +635,7 @@ const CMenuIdCmdMap::CPair* p = m_mapMenuId.Lookup(idCmd);
if (p != NULL)
{
- RunDialog(lpcmi->hwnd, p->m_value.strName);
+ RunDialog(lpcmi->hwnd, p->m_value.strName, m_listFiles, m_strFolder);
hr = S_OK;
}
else
@@ -821,108 +823,6 @@ return S_OK;
}
-
-void CTortoiseHgCmenuBase::RunDialog(HWND hWnd, const CString& strCmd)
-{
- CString strDir = GetTHgProgRoot();
- if (strDir.IsEmpty())
- {
- ATLTRACE("RunDialog: THG root is empty\n");
- return;
- }
- CString strHgCmd = strDir + "\\thgw.exe";
-
- WIN32_FIND_DATA data;
- HANDLE hFind = ::FindFirstFile(strHgCmd, &data);
- if (hFind == INVALID_HANDLE_VALUE)
- {
- strHgCmd = strDir + "\\hgtk.exe";
- hFind = ::FindFirstFile(strHgCmd, &data);
- if (hFind == INVALID_HANDLE_VALUE)
- {
- strHgCmd = strDir + "\\thg.cmd";
- }
- else
- {
- ::FindClose(hFind);
- }
- }
- else
- {
- ::FindClose(hFind);
- }
-
- strHgCmd = Quote(strHgCmd) + " --nofork " + strCmd;
-
- CString strCwd;
- if (!m_strFolder.IsEmpty())
- {
- strCwd = m_strFolder;
- }
- else if (!m_arrFiles.IsEmpty())
- {
- strCwd = ::PathIsDirectory(m_arrFiles[0]) ? m_arrFiles[0] : DirName(m_arrFiles[0]);
- }
- else
- {
- ATLTRACE("***** RunDialog: can't get cwd\n");
- return;
- }
-
- if (strCmd == "thgstatus")
- {
- if (CTHgStatus::Remove(strCwd) != 0)
- {
- CString strPath = strDir + "\\TortoiseHgOverlayServer.exe";
- LaunchCommand(Quote(strPath), strDir);
- }
- return;
- }
- else if (strCmd == "kiln")
- {
- KilnOpenRepo(hWnd, strCwd);
- return;
- }
- else if (strCmd == "kilnfiles")
- {
- KilnOpenFiles(hWnd, strCwd, m_arrFiles);
- return;
- }
-
- if (!m_arrFiles.IsEmpty())
- {
- CString strTempFile = GetTemporaryFile();
- if (strTempFile.IsEmpty())
- {
- ATLTRACE("***** RunDialog: error: GetTemporaryFile returned empty string\n");
- return;
- }
-
- ATLTRACE("RunDialog: temp file = %s\n", (LPCTSTR)strTempFile);
- HANDLE hTempFile = ::CreateFile(strTempFile, GENERIC_WRITE, FILE_SHARE_READ, 0,
- CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
-
- if (hTempFile == INVALID_HANDLE_VALUE)
- {
- ATLTRACE("***** RunDialog: error: failed to create file '%s'\n",
- (LPCTSTR)strTempFile);
- return;
- }
-
- for (int i = 0; i < m_arrFiles.GetCount(); i++)
- {
- DWORD dwWritten;
- ATLTRACE("RunDialog: temp file adding '%s'\n", (LPCTSTR)m_arrFiles[i]);
- ::WriteFile(hTempFile, (LPCTSTR)m_arrFiles[i], m_arrFiles[i].GetLength(), &dwWritten, 0);
- ::WriteFile(hTempFile, "\n", 1, &dwWritten, 0);
- }
- ::CloseHandle(hTempFile);
- strHgCmd += " --listfile " + Quote(strTempFile);
- }
-
- LaunchCommand(strHgCmd, strCwd);
-}
-
#ifdef _DEBUG
void CTortoiseHgCmenuBase::PrintDebugHeader(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj)
{
@@ -971,7 +871,7 @@#endif
m_strFolder.Empty();
- m_arrFiles.RemoveAll();
+ m_listFiles.RemoveAll();
if (pDataObj)
{
@@ -989,7 +889,7 @@ if (::DragQueryFile(hDrop, i, szName, MAX_PATH) > 0)
{
ATLTRACE(" DragQueryFile [%d] = '%s'\n", i, szName);
- m_arrFiles.Add(szName);
+ m_listFiles.AddTail(szName);
}
}
}
@@ -1021,7 +921,7 @@
// disable context menu if neither the folder nor the files
// have been found
- if (m_strFolder.IsEmpty() && m_arrFiles.IsEmpty())
+ if (m_strFolder.IsEmpty() && m_listFiles.IsEmpty())
{
ATLTRACE(" shell extension not available on this object\n");
return E_FAIL;
|
@@ -33,13 +33,11 @@ public IShellExtInit
{
protected:
- CAtlArray<CString> m_arrFiles;
+ CAtlList<CString> m_listFiles;
CString m_strFolder;
CMenuDescriptionMap m_mapMenuDesc;
CMenuIdCmdMap m_mapMenuId;
- virtual void RunDialog(HWND hWnd, const CString& strCmd);
-
void TweakMenuForVista(HMENU hMenu);
void InitMenuMaps(const CMenuDescription *pMenuDescs, int nCount);
void InsertMenuItemByName(HMENU hMenu, const CString& strName, UINT indexMenu,
|
@@ -79,15 +79,6 @@ return ResultFromShort(idCmd - idCmdFirst);
}
-void CTortoiseHgDropHandler::RunDialog(HWND hWnd, const CString& strCmd)
-{
- if (strCmd == "drag_move" || strCmd == "drag_copy") {
- // Append the current directory as the dest.
- m_arrFiles.Add(m_strFolder);
- }
- CTortoiseHgCmenuBase::RunDialog(hWnd, strCmd);
-}
-
STDMETHODIMP CTortoiseHgDropHandler::Initialize(LPCITEMIDLIST pIDFolder,
LPDATAOBJECT pDataObj, HKEY hRegKey)
{
@@ -98,7 +89,7 @@#endif
m_strFolder.Empty();
- m_arrFiles.RemoveAll();
+ m_listFiles.RemoveAll();
// if a directory background
if (pIDFolder)
@@ -137,10 +128,10 @@ if (GetHgRepoRoot(szName) != strRoot)
{
ATLTRACE(" '%s' isn't in target dir repository\n", szName);
- m_arrFiles.RemoveAll();
+ m_listFiles.RemoveAll();
break;
}
- m_arrFiles.Add(szName);
+ m_listFiles.AddTail(szName);
}
}
}
@@ -164,7 +155,7 @@
// disable context menu if neither the folder nor the files
// have been found
- if (m_arrFiles.IsEmpty())
+ if (m_listFiles.IsEmpty())
{
ATLTRACE(" shell extension not available on this object\n");
return E_FAIL;
|
@@ -21,9 +21,6 @@ public CTortoiseHgCmenuBase,
public CComCoClass<CTortoiseHgDropHandler, &CLSID_TortoiseHgDropHandler>
{
-protected:
- virtual void RunDialog(HWND hWnd, const CString& strCmd);
-
public:
CTortoiseHgDropHandler();
|
Loading...