1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "RepositoryBrowserCommand.h"
\r
22 #include "RepositoryBrowser.h"
\r
25 #include "PathUtils.h"
\r
26 #include "UnicodeUtils.h"
\r
28 bool RepositoryBrowserCommand::Execute()
\r
33 if (!cmdLinePath.IsEmpty())
\r
35 if (cmdLinePath.GetSVNPathString().Left(4).CompareNoCase(_T("svn:"))==0)
\r
37 // If the path starts with "svn:" and there is another protocol
\r
38 // found in the path (a "://" found after the "svn:") then
\r
39 // remove "svn:" from the beginning of the path.
\r
40 if (cmdLinePath.GetSVNPathString().Find(_T("://"), 4)>=0)
\r
41 cmdLinePath.SetFromSVN(cmdLinePath.GetSVNPathString().Mid(4));
\r
44 url = svn.GetURLFromPath(cmdLinePath);
\r
48 if (SVN::PathIsURL(cmdLinePath))
\r
49 url = cmdLinePath.GetSVNPathString();
\r
50 else if (svn.IsRepository(cmdLinePath))
\r
52 // The path points to a local repository.
\r
53 // Add 'file:///' so the repository browser recognizes
\r
54 // it as an URL to the local repository.
\r
55 if (cmdLinePath.GetWinPathString().GetAt(0) == '\\') // starts with '\' means an UNC path
\r
57 CString p = cmdLinePath.GetWinPathString();
\r
59 if (CPathUtils::PathEscape(CUnicodeUtils::GetUTF8(p)).Find('%') >= 0)
\r
61 // the path has special chars which will get escaped!
\r
62 url = _T("file:///\\")+p;
\r
65 url = _T("file://")+p;
\r
68 url = _T("file:///")+cmdLinePath.GetWinPathString();
\r
69 url.Replace('\\', '/');
\r
73 if (cmdLinePath.GetUIPathString().Left(7).CompareNoCase(_T("file://"))==0)
\r
75 cmdLinePath.SetFromUnknown(cmdLinePath.GetUIPathString().Mid(7));
\r
77 bFile = PathFileExists(cmdLinePath.GetWinPath()) ? !cmdLinePath.IsDirectory() : FALSE;
\r
82 if (urldlg.DoModal() != IDOK)
\r
89 CString val = parser.GetVal(_T("rev"));
\r
91 CRepositoryBrowser dlg(url, rev);
\r
92 if (!cmdLinePath.IsUrl())
\r
93 dlg.m_ProjectProperties.ReadProps(cmdLinePath);
\r
96 if (parser.HasVal(_T("projectpropertiespath")))
\r
98 dlg.m_ProjectProperties.ReadProps(CTSVNPath(parser.GetVal(_T("projectpropertiespath"))));
\r
101 dlg.m_path = cmdLinePath;
\r