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