1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-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 "TortoiseProc.h"
\r
21 #include "messagebox.h"
\r
22 #include "SVNProgressDlg.h"
\r
24 #include "TGitPath.h"
\r
25 #include "Registry.h"
\r
26 #include "GitStatus.h"
\r
27 #include "AppUtils.h"
\r
28 #include "PathUtils.h"
\r
29 #include "StringUtils.h"
\r
30 #include "TempFile.h"
\r
31 #include "UnicodeUtils.h"
\r
32 #include "SoundUtils.h"
\r
33 #include "GitDiff.h"
\r
35 #include "DropFiles.h"
\r
36 //#include "GitLogHelper.h"
\r
37 #include "RegHistory.h"
\r
38 //#include "ConflictResolveDlg.h"
\r
39 #include "LogFile.h"
\r
40 #include "ShellUpdater.h"
\r
41 #include "IconMenu.h"
\r
42 #include "BugTraqAssociations.h"
\r
45 BOOL CGitProgressDlg::m_bAscending = FALSE;
\r
46 int CGitProgressDlg::m_nSortedColumn = -1;
\r
48 #define TRANSFERTIMER 100
\r
49 #define VISIBLETIMER 101
\r
51 enum SVNProgressDlgContextMenuCommands
\r
53 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
\r
57 ID_CONFLICTUSETHEIRS,
\r
66 IMPLEMENT_DYNAMIC(CGitProgressDlg, CResizableStandAloneDialog)
\r
67 CGitProgressDlg::CGitProgressDlg(CWnd* pParent /*=NULL*/)
\r
68 : CResizableStandAloneDialog(CGitProgressDlg::IDD, pParent)
\r
70 , m_Revision(_T("HEAD"))
\r
71 //, m_RevisionEnd(0)
\r
72 , m_bLockWarning(false)
\r
73 , m_bLockExists(false)
\r
74 , m_bCancelled(FALSE)
\r
75 , m_bThreadRunning(FALSE)
\r
77 , m_bErrorsOccurred(FALSE)
\r
78 , m_bMergesAddsDeletesOccurred(FALSE)
\r
80 , m_options(ProgOptNone)
\r
81 , m_dwCloseOnEnd((DWORD)-1)
\r
82 , m_bFinishedItemAdded(false)
\r
83 , m_bLastVisible(false)
\r
84 // , m_depth(svn_depth_unknown)
\r
86 , m_itemCountTotal(-1)
\r
87 , m_AlwaysConflicted(false)
\r
88 , m_BugTraqProvider(NULL)
\r
89 , sIgnoredIncluded(MAKEINTRESOURCE(IDS_PROGRS_IGNOREDINCLUDED))
\r
90 , sExtExcluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSEXCLUDED))
\r
91 , sExtIncluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSINCLUDED))
\r
92 , sIgnoreAncestry(MAKEINTRESOURCE(IDS_PROGRS_IGNOREANCESTRY))
\r
93 , sRespectAncestry(MAKEINTRESOURCE(IDS_PROGRS_RESPECTANCESTRY))
\r
94 , sDryRun(MAKEINTRESOURCE(IDS_PROGRS_DRYRUN))
\r
95 , sRecordOnly(MAKEINTRESOURCE(IDS_MERGE_RECORDONLY))
\r
100 CGitProgressDlg::~CGitProgressDlg()
\r
102 for (size_t i=0; i<m_arData.size(); i++)
\r
104 delete m_arData[i];
\r
106 if(m_pThread != NULL)
\r
112 void CGitProgressDlg::DoDataExchange(CDataExchange* pDX)
\r
114 CResizableStandAloneDialog::DoDataExchange(pDX);
\r
115 DDX_Control(pDX, IDC_SVNPROGRESS, m_ProgList);
\r
118 BEGIN_MESSAGE_MAP(CGitProgressDlg, CResizableStandAloneDialog)
\r
119 ON_BN_CLICKED(IDC_LOGBUTTON, OnBnClickedLogbutton)
\r
120 ON_NOTIFY(NM_CUSTOMDRAW, IDC_SVNPROGRESS, OnNMCustomdrawSvnprogress)
\r
122 ON_NOTIFY(NM_DBLCLK, IDC_SVNPROGRESS, OnNMDblclkSvnprogress)
\r
123 ON_NOTIFY(HDN_ITEMCLICK, 0, OnHdnItemclickSvnprogress)
\r
125 ON_WM_CONTEXTMENU()
\r
126 ON_REGISTERED_MESSAGE(WM_SVNPROGRESS, OnSVNProgress)
\r
128 ON_EN_SETFOCUS(IDC_INFOTEXT, &CGitProgressDlg::OnEnSetfocusInfotext)
\r
129 ON_NOTIFY(LVN_BEGINDRAG, IDC_SVNPROGRESS, &CGitProgressDlg::OnLvnBegindragSvnprogress)
\r
131 ON_NOTIFY(LVN_GETDISPINFO, IDC_SVNPROGRESS, &CGitProgressDlg::OnLvnGetdispinfoSvnprogress)
\r
132 ON_BN_CLICKED(IDC_NONINTERACTIVE, &CGitProgressDlg::OnBnClickedNoninteractive)
\r
133 ON_MESSAGE(WM_SHOWCONFLICTRESOLVER, OnShowConflictResolver)
\r
136 BOOL CGitProgressDlg::Cancel()
\r
138 return m_bCancelled;
\r
141 LRESULT CGitProgressDlg::OnShowConflictResolver(WPARAM /*wParam*/, LPARAM lParam)
\r
143 CConflictResolveDlg dlg(this);
\r
144 const svn_wc_conflict_description_t *description = (svn_wc_conflict_description_t *)lParam;
\r
147 dlg.SetConflictDescription(description);
\r
148 if (dlg.DoModal() == IDOK)
\r
150 if (dlg.GetResult() == svn_wc_conflict_choose_postpone)
\r
152 // if the result is conflicted and the dialog returned IDOK,
\r
153 // that means we should not ask again in case of a conflict
\r
154 m_AlwaysConflicted = true;
\r
155 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);
\r
158 m_mergedfile = dlg.GetMergedFile();
\r
159 m_bCancelled = dlg.IsCancelled();
\r
160 return dlg.GetResult();
\r
162 return svn_wc_conflict_choose_postpone;
\r
165 svn_wc_conflict_choice_t CGitProgressDlg::ConflictResolveCallback(const svn_wc_conflict_description_t *description, CString& mergedfile)
\r
167 // we only bother the user when merging
\r
168 if (((m_Command == SVNProgress_Merge)||(m_Command == SVNProgress_MergeAll)||(m_Command == SVNProgress_MergeReintegrate))&&(!m_AlwaysConflicted)&&(description))
\r
170 // we're in a worker thread here. That means we must not show a dialog from the thread
\r
171 // but let the UI thread do it.
\r
172 // To do that, we send a message to the UI thread and let it show the conflict resolver dialog.
\r
173 LRESULT dlgResult = ::SendMessage(GetSafeHwnd(), WM_SHOWCONFLICTRESOLVER, 0, (LPARAM)description);
\r
174 mergedfile = m_mergedfile;
\r
175 return (svn_wc_conflict_choice_t)dlgResult;
\r
178 return svn_wc_conflict_choose_postpone;
\r
181 void CGitProgressDlg::AddItemToList()
\r
183 int totalcount = m_ProgList.GetItemCount();
\r
185 m_ProgList.SetItemCountEx(totalcount+1, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL);
\r
186 // make columns width fit
\r
187 if (iFirstResized < 30)
\r
189 // only resize the columns for the first 30 or so entries.
\r
190 // after that, don't resize them anymore because that's an
\r
191 // expensive function call and the columns will be sized
\r
192 // close enough already.
\r
197 // Make sure the item is *entirely* visible even if the horizontal
\r
198 // scroll bar is visible.
\r
199 int count = m_ProgList.GetCountPerPage();
\r
200 if (totalcount <= (m_ProgList.GetTopIndex() + count + nEnsureVisibleCount + 2))
\r
202 nEnsureVisibleCount++;
\r
203 m_bLastVisible = true;
\r
207 nEnsureVisibleCount = 0;
\r
208 if (IsIconic() == 0)
\r
209 m_bLastVisible = false;
\r
213 BOOL CGitProgressDlg::Notify(const CTSVNPath& path, svn_wc_notify_action_t action,
\r
214 svn_node_kind_t kind, const CString& mime_type,
\r
215 svn_wc_notify_state_t content_state,
\r
216 svn_wc_notify_state_t prop_state, LONG rev,
\r
217 const svn_lock_t * lock, svn_wc_notify_lock_state_t lock_state,
\r
218 const CString& changelistname,
\r
219 svn_merge_range_t * range,
\r
220 svn_error_t * err, apr_pool_t * pool)
\r
222 bool bNoNotify = false;
\r
223 bool bDoAddData = true;
\r
224 NotificationData * data = new NotificationData();
\r
226 data->action = action;
\r
228 data->mime_type = mime_type;
\r
229 data->content_state = content_state;
\r
230 data->prop_state = prop_state;
\r
232 data->lock_state = lock_state;
\r
233 data->changelistname = changelistname;
\r
234 if ((lock)&&(lock->owner))
\r
235 data->owner = CUnicodeUtils::GetUnicode(lock->owner);
\r
236 data->sPathColumnText = path.GetUIPathString();
\r
237 if (!m_basePath.IsEmpty())
\r
238 data->basepath = m_basePath;
\r
240 data->merge_range = *range;
\r
241 switch (data->action)
\r
243 case svn_wc_notify_add:
\r
244 case svn_wc_notify_update_add:
\r
245 if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
\r
247 data->color = m_Colors.GetColor(CColors::Conflict);
\r
248 data->bConflictedActionItem = true;
\r
249 data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
\r
254 m_bMergesAddsDeletesOccurred = true;
\r
255 data->sActionColumnText.LoadString(IDS_SVNACTION_ADD);
\r
256 data->color = m_Colors.GetColor(CColors::Added);
\r
259 case svn_wc_notify_commit_added:
\r
260 data->sActionColumnText.LoadString(IDS_SVNACTION_ADDING);
\r
261 data->color = m_Colors.GetColor(CColors::Added);
\r
263 case svn_wc_notify_copy:
\r
264 data->sActionColumnText.LoadString(IDS_SVNACTION_COPY);
\r
266 case svn_wc_notify_commit_modified:
\r
267 data->sActionColumnText.LoadString(IDS_SVNACTION_MODIFIED);
\r
268 data->color = m_Colors.GetColor(CColors::Modified);
\r
270 case svn_wc_notify_delete:
\r
271 case svn_wc_notify_update_delete:
\r
272 data->sActionColumnText.LoadString(IDS_SVNACTION_DELETE);
\r
273 m_bMergesAddsDeletesOccurred = true;
\r
274 data->color = m_Colors.GetColor(CColors::Deleted);
\r
276 case svn_wc_notify_commit_deleted:
\r
277 data->sActionColumnText.LoadString(IDS_SVNACTION_DELETING);
\r
278 data->color = m_Colors.GetColor(CColors::Deleted);
\r
280 case svn_wc_notify_restore:
\r
281 data->sActionColumnText.LoadString(IDS_SVNACTION_RESTORE);
\r
283 case svn_wc_notify_revert:
\r
284 data->sActionColumnText.LoadString(IDS_SVNACTION_REVERT);
\r
286 case svn_wc_notify_resolved:
\r
287 data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);
\r
289 case svn_wc_notify_update_replace:
\r
290 case svn_wc_notify_commit_replaced:
\r
291 data->sActionColumnText.LoadString(IDS_SVNACTION_REPLACED);
\r
292 data->color = m_Colors.GetColor(CColors::Deleted);
\r
294 case svn_wc_notify_exists:
\r
295 if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
\r
297 data->color = m_Colors.GetColor(CColors::Conflict);
\r
298 data->bConflictedActionItem = true;
\r
300 data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
\r
302 else if ((data->content_state == svn_wc_notify_state_merged) || (data->prop_state == svn_wc_notify_state_merged))
\r
304 data->color = m_Colors.GetColor(CColors::Merged);
\r
305 m_bMergesAddsDeletesOccurred = true;
\r
306 data->sActionColumnText.LoadString(IDS_SVNACTION_MERGED);
\r
309 data->sActionColumnText.LoadString(IDS_SVNACTION_EXISTS);
\r
311 case svn_wc_notify_update_update:
\r
312 // if this is an inoperative dir change, don't show the notification.
\r
313 // an inoperative dir change is when a directory gets updated without
\r
314 // any real change in either text or properties.
\r
315 if ((kind == svn_node_dir)
\r
316 && ((prop_state == svn_wc_notify_state_inapplicable)
\r
317 || (prop_state == svn_wc_notify_state_unknown)
\r
318 || (prop_state == svn_wc_notify_state_unchanged)))
\r
323 if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
\r
325 data->color = m_Colors.GetColor(CColors::Conflict);
\r
326 data->bConflictedActionItem = true;
\r
328 data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
\r
330 else if ((data->content_state == svn_wc_notify_state_merged) || (data->prop_state == svn_wc_notify_state_merged))
\r
332 data->color = m_Colors.GetColor(CColors::Merged);
\r
333 m_bMergesAddsDeletesOccurred = true;
\r
334 data->sActionColumnText.LoadString(IDS_SVNACTION_MERGED);
\r
336 else if (((data->content_state != svn_wc_notify_state_unchanged)&&(data->content_state != svn_wc_notify_state_unknown)) ||
\r
337 ((data->prop_state != svn_wc_notify_state_unchanged)&&(data->prop_state != svn_wc_notify_state_unknown)))
\r
339 data->sActionColumnText.LoadString(IDS_SVNACTION_UPDATE);
\r
346 if (lock_state == svn_wc_notify_lock_state_unlocked)
\r
348 CString temp(MAKEINTRESOURCE(IDS_SVNACTION_UNLOCKED));
\r
349 data->sActionColumnText += _T(", ") + temp;
\r
353 case svn_wc_notify_update_external:
\r
354 // For some reason we build a list of externals...
\r
355 m_ExtStack.AddHead(path.GetUIPathString());
\r
356 data->sActionColumnText.LoadString(IDS_SVNACTION_EXTERNAL);
\r
357 data->bAuxItem = true;
\r
360 case svn_wc_notify_update_completed:
\r
362 data->sActionColumnText.LoadString(IDS_SVNACTION_COMPLETED);
\r
363 data->bAuxItem = true;
\r
364 bool bEmpty = !!m_ExtStack.IsEmpty();
\r
366 data->sPathColumnText.Format(IDS_PROGRS_PATHATREV, (LPCTSTR)m_ExtStack.RemoveHead(), rev);
\r
368 data->sPathColumnText.Format(IDS_PROGRS_ATREV, rev);
\r
370 if ((m_nConflicts>0)&&(bEmpty))
\r
372 // We're going to add another aux item - let's shove this current onto the list first
\r
373 // I don't really like this, but it will do for the moment.
\r
374 m_arData.push_back(data);
\r
377 data = new NotificationData();
\r
378 data->bAuxItem = true;
\r
379 data->sActionColumnText.LoadString(IDS_PROGRS_CONFLICTSOCCURED_WARNING);
\r
380 data->sPathColumnText.LoadString(IDS_PROGRS_CONFLICTSOCCURED);
\r
381 data->color = m_Colors.GetColor(CColors::Conflict);
\r
382 CSoundUtils::PlayTSVNWarning();
\r
383 // This item will now be added after the switch statement
\r
385 if (!m_basePath.IsEmpty())
\r
386 m_FinishedRevMap[m_basePath.GetSVNApiPath(pool)] = rev;
\r
387 m_RevisionEnd = rev;
\r
388 m_bFinishedItemAdded = true;
\r
391 case svn_wc_notify_commit_postfix_txdelta:
\r
392 data->sActionColumnText.LoadString(IDS_SVNACTION_POSTFIX);
\r
394 case svn_wc_notify_failed_revert:
\r
395 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDREVERT);
\r
397 case svn_wc_notify_status_completed:
\r
398 case svn_wc_notify_status_external:
\r
399 data->sActionColumnText.LoadString(IDS_SVNACTION_STATUS);
\r
401 case svn_wc_notify_skip:
\r
402 if ((content_state == svn_wc_notify_state_missing)||(content_state == svn_wc_notify_state_obstructed)||(content_state == svn_wc_notify_state_conflicted))
\r
404 data->sActionColumnText.LoadString(IDS_SVNACTION_SKIPMISSING);
\r
406 // The color settings dialog describes the red color with
\r
407 // "possible or real conflict / obstructed" which also applies to
\r
408 // skipped targets during a merge. So we just use the same color.
\r
409 data->color = m_Colors.GetColor(CColors::Conflict);
\r
412 data->sActionColumnText.LoadString(IDS_SVNACTION_SKIP);
\r
414 case svn_wc_notify_locked:
\r
415 if ((lock)&&(lock->owner))
\r
416 data->sActionColumnText.Format(IDS_SVNACTION_LOCKEDBY, (LPCTSTR)CUnicodeUtils::GetUnicode(lock->owner));
\r
418 case svn_wc_notify_unlocked:
\r
419 data->sActionColumnText.LoadString(IDS_SVNACTION_UNLOCKED);
\r
421 case svn_wc_notify_failed_lock:
\r
422 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDLOCK);
\r
423 m_arData.push_back(data);
\r
425 ReportError(SVN::GetErrorString(err));
\r
426 bDoAddData = false;
\r
427 if (err->apr_err == SVN_ERR_FS_OUT_OF_DATE)
\r
428 m_bLockWarning = true;
\r
429 if (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED)
\r
430 m_bLockExists = true;
\r
432 case svn_wc_notify_failed_unlock:
\r
433 data->sActionColumnText.LoadString(IDS_SVNACTION_FAILEDUNLOCK);
\r
434 m_arData.push_back(data);
\r
436 ReportError(SVN::GetErrorString(err));
\r
437 bDoAddData = false;
\r
438 if (err->apr_err == SVN_ERR_FS_OUT_OF_DATE)
\r
439 m_bLockWarning = true;
\r
441 case svn_wc_notify_changelist_set:
\r
442 data->sActionColumnText.Format(IDS_SVNACTION_CHANGELISTSET, (LPCTSTR)data->changelistname);
\r
444 case svn_wc_notify_changelist_clear:
\r
445 data->sActionColumnText.LoadString(IDS_SVNACTION_CHANGELISTCLEAR);
\r
447 case svn_wc_notify_changelist_moved:
\r
448 data->sActionColumnText.Format(IDS_SVNACTION_CHANGELISTMOVED, (LPCTSTR)data->changelistname);
\r
450 case svn_wc_notify_foreign_merge_begin:
\r
451 case svn_wc_notify_merge_begin:
\r
453 data->sActionColumnText.LoadString(IDS_SVNACTION_MERGEBEGINNONE);
\r
454 else if ((data->merge_range.start == data->merge_range.end) || (data->merge_range.start == data->merge_range.end - 1))
\r
455 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINSINGLE, data->merge_range.end);
\r
456 else if (data->merge_range.start - 1 == data->merge_range.end)
\r
457 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINSINGLEREVERSE, data->merge_range.start);
\r
458 else if (data->merge_range.start < data->merge_range.end)
\r
459 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINMULTIPLE, data->merge_range.start + 1, data->merge_range.end);
\r
461 data->sActionColumnText.Format(IDS_SVNACTION_MERGEBEGINMULTIPLEREVERSE, data->merge_range.start, data->merge_range.end + 1);
\r
462 data->bAuxItem = true;
\r
466 } // switch (data->action)
\r
474 m_arData.push_back(data);
\r
476 if ((!data->bAuxItem)&&(m_itemCount > 0))
\r
480 CProgressCtrl * progControl = (CProgressCtrl *)GetDlgItem(IDC_PROGRESSBAR);
\r
481 progControl->ShowWindow(SW_SHOW);
\r
482 progControl->SetPos(m_itemCountTotal - m_itemCount);
\r
483 progControl->SetRange32(0, m_itemCountTotal);
\r
486 if ((action == svn_wc_notify_commit_postfix_txdelta)&&(bSecondResized == FALSE))
\r
489 bSecondResized = TRUE;
\r
496 CString CGitProgressDlg::BuildInfoString()
\r
506 int conflicted = 0;
\r
513 for (size_t i=0; i<m_arData.size(); ++i)
\r
515 const NotificationData * dat = m_arData[i];
\r
516 switch (dat->action)
\r
518 case svn_wc_notify_add:
\r
519 case svn_wc_notify_update_add:
\r
520 case svn_wc_notify_commit_added:
\r
521 if (dat->bConflictedActionItem)
\r
526 case svn_wc_notify_copy:
\r
529 case svn_wc_notify_delete:
\r
530 case svn_wc_notify_update_delete:
\r
531 case svn_wc_notify_commit_deleted:
\r
534 case svn_wc_notify_restore:
\r
537 case svn_wc_notify_revert:
\r
540 case svn_wc_notify_resolved:
\r
543 case svn_wc_notify_update_update:
\r
544 if (dat->bConflictedActionItem)
\r
546 else if ((dat->content_state == svn_wc_notify_state_merged) || (dat->prop_state == svn_wc_notify_state_merged))
\r
551 case svn_wc_notify_commit_modified:
\r
554 case svn_wc_notify_skip:
\r
557 case svn_wc_notify_commit_replaced:
\r
564 temp.LoadString(IDS_SVNACTION_CONFLICTED);
\r
566 temp.Format(_T(":%d "), conflicted);
\r
571 temp.LoadString(IDS_SVNACTION_SKIP);
\r
573 infotext.AppendFormat(_T(":%d "), skipped);
\r
577 temp.LoadString(IDS_SVNACTION_MERGED);
\r
579 infotext.AppendFormat(_T(":%d "), merged);
\r
583 temp.LoadString(IDS_SVNACTION_ADD);
\r
585 infotext.AppendFormat(_T(":%d "), added);
\r
589 temp.LoadString(IDS_SVNACTION_DELETE);
\r
591 infotext.AppendFormat(_T(":%d "), deleted);
\r
595 temp.LoadString(IDS_SVNACTION_MODIFIED);
\r
597 infotext.AppendFormat(_T(":%d "), modified);
\r
601 temp.LoadString(IDS_SVNACTION_COPY);
\r
603 infotext.AppendFormat(_T(":%d "), copied);
\r
607 temp.LoadString(IDS_SVNACTION_REPLACED);
\r
609 infotext.AppendFormat(_T(":%d "), replaced);
\r
613 temp.LoadString(IDS_SVNACTION_UPDATE);
\r
615 infotext.AppendFormat(_T(":%d "), updated);
\r
619 temp.LoadString(IDS_SVNACTION_RESTORE);
\r
621 infotext.AppendFormat(_T(":%d "), restored);
\r
625 temp.LoadString(IDS_SVNACTION_REVERT);
\r
627 infotext.AppendFormat(_T(":%d "), reverted);
\r
631 temp.LoadString(IDS_SVNACTION_RESOLVE);
\r
633 infotext.AppendFormat(_T(":%d "), resolved);
\r
638 void CGitProgressDlg::SetSelectedList(const CTSVNPathList& selPaths)
\r
640 m_selectedPaths = selPaths;
\r
643 void CGitProgressDlg::ResizeColumns()
\r
645 m_ProgList.SetRedraw(FALSE);
\r
647 TCHAR textbuf[MAX_PATH];
\r
649 int maxcol = ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItemCount()-1;
\r
650 for (int col = 0; col <= maxcol; col++)
\r
652 // find the longest width of all items
\r
653 int count = m_ProgList.GetItemCount();
\r
655 hdi.mask = HDI_TEXT;
\r
656 hdi.pszText = textbuf;
\r
657 hdi.cchTextMax = sizeof(textbuf);
\r
658 ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItem(col, &hdi);
\r
659 int cx = m_ProgList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
661 for (int index = 0; index<count; ++index)
\r
663 // get the width of the string and add 12 pixels for the column separator and margins
\r
664 int linewidth = cx;
\r
668 linewidth = m_ProgList.GetStringWidth(m_arData[index]->sActionColumnText) + 12;
\r
671 linewidth = m_ProgList.GetStringWidth(m_arData[index]->sPathColumnText) + 12;
\r
674 linewidth = m_ProgList.GetStringWidth(m_arData[index]->mime_type) + 12;
\r
677 if (cx < linewidth)
\r
680 m_ProgList.SetColumnWidth(col, cx);
\r
683 m_ProgList.SetRedraw(TRUE);
\r
686 BOOL CGitProgressDlg::OnInitDialog()
\r
688 __super::OnInitDialog();
\r
690 m_ProgList.SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
\r
692 m_ProgList.DeleteAllItems();
\r
693 int c = ((CHeaderCtrl*)(m_ProgList.GetDlgItem(0)))->GetItemCount()-1;
\r
695 m_ProgList.DeleteColumn(c--);
\r
697 temp.LoadString(IDS_PROGRS_ACTION);
\r
698 m_ProgList.InsertColumn(0, temp);
\r
699 temp.LoadString(IDS_PROGRS_PATH);
\r
700 m_ProgList.InsertColumn(1, temp);
\r
701 temp.LoadString(IDS_PROGRS_MIMETYPE);
\r
702 m_ProgList.InsertColumn(2, temp);
\r
704 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
\r
705 if (m_pThread==NULL)
\r
707 ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
\r
711 m_pThread->m_bAutoDelete = FALSE;
\r
712 m_pThread->ResumeThread();
\r
717 // Call this early so that the column headings aren't hidden before any
\r
718 // text gets added.
\r
721 SetTimer(VISIBLETIMER, 300, NULL);
\r
723 AddAnchor(IDC_SVNPROGRESS, TOP_LEFT, BOTTOM_RIGHT);
\r
724 AddAnchor(IDC_PROGRESSLABEL, BOTTOM_LEFT, BOTTOM_CENTER);
\r
725 AddAnchor(IDC_PROGRESSBAR, BOTTOM_CENTER, BOTTOM_RIGHT);
\r
726 AddAnchor(IDC_INFOTEXT, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
727 AddAnchor(IDC_NONINTERACTIVE, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
728 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
729 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
730 AddAnchor(IDC_LOGBUTTON, BOTTOM_RIGHT);
\r
731 SetPromptParentWindow(this->m_hWnd);
\r
733 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
734 EnableSaveRestore(_T("SVNProgressDlg"));
\r
738 bool CGitProgressDlg::SetBackgroundImage(UINT nID)
\r
740 return CAppUtils::SetListCtrlBackgroundImage(m_ProgList.GetSafeHwnd(), nID);
\r
743 void CGitProgressDlg::ReportSVNError()
\r
745 ReportError(GetLastErrorMessage());
\r
748 void CGitProgressDlg::ReportError(const CString& sError)
\r
750 CSoundUtils::PlayTSVNError();
\r
751 ReportString(sError, CString(MAKEINTRESOURCE(IDS_ERR_ERROR)), m_Colors.GetColor(CColors::Conflict));
\r
752 m_bErrorsOccurred = true;
\r
755 void CGitProgressDlg::ReportWarning(const CString& sWarning)
\r
757 CSoundUtils::PlayTSVNWarning();
\r
758 ReportString(sWarning, CString(MAKEINTRESOURCE(IDS_WARN_WARNING)), m_Colors.GetColor(CColors::Conflict));
\r
761 void CGitProgressDlg::ReportNotification(const CString& sNotification)
\r
763 CSoundUtils::PlayTSVNNotification();
\r
764 ReportString(sNotification, CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));
\r
767 void CGitProgressDlg::ReportCmd(const CString& sCmd)
\r
769 ReportString(sCmd, CString(MAKEINTRESOURCE(IDS_PROGRS_CMDINFO)), m_Colors.GetColor(CColors::Cmd));
\r
772 void CGitProgressDlg::ReportString(CString sMessage, const CString& sMsgKind, COLORREF color)
\r
774 // instead of showing a dialog box with the error message or notification,
\r
775 // just insert the error text into the list control.
\r
776 // that way the user isn't 'interrupted' by a dialog box popping up!
\r
778 // the message may be split up into different lines
\r
779 // so add a new entry for each line of the message
\r
780 while (!sMessage.IsEmpty())
\r
782 NotificationData * data = new NotificationData();
\r
783 data->bAuxItem = true;
\r
784 data->sActionColumnText = sMsgKind;
\r
785 if (sMessage.Find('\n')>=0)
\r
786 data->sPathColumnText = sMessage.Left(sMessage.Find('\n'));
\r
788 data->sPathColumnText = sMessage;
\r
789 data->sPathColumnText.Trim(_T("\n\r"));
\r
790 data->color = color;
\r
791 if (sMessage.Find('\n')>=0)
\r
793 sMessage = sMessage.Mid(sMessage.Find('\n'));
\r
794 sMessage.Trim(_T("\n\r"));
\r
798 m_arData.push_back(data);
\r
803 UINT CGitProgressDlg::ProgressThreadEntry(LPVOID pVoid)
\r
805 return ((CGitProgressDlg*)pVoid)->ProgressThread();
\r
808 UINT CGitProgressDlg::ProgressThread()
\r
810 // The SetParams function should have loaded something for us
\r
813 CString sWindowTitle;
\r
814 bool localoperation = false;
\r
815 bool bSuccess = false;
\r
816 m_AlwaysConflicted = false;
\r
818 DialogEnableWindow(IDOK, FALSE);
\r
819 DialogEnableWindow(IDCANCEL, TRUE);
\r
820 SetAndClearProgressInfo(m_hWnd);
\r
821 m_itemCount = m_itemCountTotal;
\r
823 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
825 bSecondResized = FALSE;
\r
826 m_bFinishedItemAdded = false;
\r
827 CTime startTime = CTime::GetCurrentTime();
\r
830 case SVNProgress_Add:
\r
831 bSuccess = CmdAdd(sWindowTitle, localoperation);
\r
833 case SVNProgress_Checkout:
\r
834 bSuccess = CmdCheckout(sWindowTitle, localoperation);
\r
836 case SVNProgress_Commit:
\r
837 bSuccess = CmdCommit(sWindowTitle, localoperation);
\r
839 case SVNProgress_Copy:
\r
840 bSuccess = CmdCopy(sWindowTitle, localoperation);
\r
842 case SVNProgress_Export:
\r
843 bSuccess = CmdExport(sWindowTitle, localoperation);
\r
845 case SVNProgress_Import:
\r
846 bSuccess = CmdImport(sWindowTitle, localoperation);
\r
848 case SVNProgress_Lock:
\r
849 bSuccess = CmdLock(sWindowTitle, localoperation);
\r
851 case SVNProgress_Merge:
\r
852 bSuccess = CmdMerge(sWindowTitle, localoperation);
\r
854 case SVNProgress_MergeAll:
\r
855 bSuccess = CmdMergeAll(sWindowTitle, localoperation);
\r
857 case SVNProgress_MergeReintegrate:
\r
858 bSuccess = CmdMergeReintegrate(sWindowTitle, localoperation);
\r
860 case SVNProgress_Rename:
\r
861 bSuccess = CmdRename(sWindowTitle, localoperation);
\r
863 case SVNProgress_Resolve:
\r
864 bSuccess = CmdResolve(sWindowTitle, localoperation);
\r
866 case SVNProgress_Revert:
\r
867 bSuccess = CmdRevert(sWindowTitle, localoperation);
\r
869 case SVNProgress_Switch:
\r
870 bSuccess = CmdSwitch(sWindowTitle, localoperation);
\r
872 case SVNProgress_Unlock:
\r
873 bSuccess = CmdUnlock(sWindowTitle, localoperation);
\r
875 case SVNProgress_Update:
\r
876 bSuccess = CmdUpdate(sWindowTitle, localoperation);
\r
880 temp.LoadString(IDS_PROGRS_TITLEFAILED);
\r
882 temp.LoadString(IDS_PROGRS_TITLEFIN);
\r
883 sWindowTitle = sWindowTitle + _T(" ") + temp;
\r
884 SetWindowText(sWindowTitle);
\r
886 KillTimer(TRANSFERTIMER);
\r
887 KillTimer(VISIBLETIMER);
\r
889 DialogEnableWindow(IDCANCEL, FALSE);
\r
890 DialogEnableWindow(IDOK, TRUE);
\r
892 CString info = BuildInfoString();
\r
894 info.LoadString(IDS_PROGRS_INFOFAILED);
\r
895 SetDlgItemText(IDC_INFOTEXT, info);
\r
897 SendMessage(DM_SETDEFID, IDOK);
\r
898 GetDlgItem(IDOK)->SetFocus();
\r
900 CString sFinalInfo;
\r
901 if (!m_sTotalBytesTransferred.IsEmpty())
\r
903 CTimeSpan time = CTime::GetCurrentTime() - startTime;
\r
904 temp.Format(IDS_PROGRS_TIME, (LONG)time.GetTotalMinutes(), (LONG)time.GetSeconds());
\r
905 sFinalInfo.Format(IDS_PROGRS_FINALINFO, m_sTotalBytesTransferred, (LPCTSTR)temp);
\r
906 SetDlgItemText(IDC_PROGRESSLABEL, sFinalInfo);
\r
909 GetDlgItem(IDC_PROGRESSLABEL)->ShowWindow(SW_HIDE);
\r
911 GetDlgItem(IDC_PROGRESSBAR)->ShowWindow(SW_HIDE);
\r
913 if (!m_bFinishedItemAdded)
\r
915 // there's no "finished: xxx" line at the end. We add one here to make
\r
916 // sure the user sees that the command is actually finished.
\r
917 NotificationData * data = new NotificationData();
\r
918 data->bAuxItem = true;
\r
919 data->sActionColumnText.LoadString(IDS_PROGRS_FINISHED);
\r
920 m_arData.push_back(data);
\r
924 int count = m_ProgList.GetItemCount();
\r
925 if ((count > 0)&&(m_bLastVisible))
\r
926 m_ProgList.EnsureVisible(count-1, FALSE);
\r
929 if (logfile.Open())
\r
931 logfile.AddTimeLine();
\r
932 for (size_t i=0; i<m_arData.size(); i++)
\r
934 NotificationData * data = m_arData[i];
\r
935 temp.Format(_T("%-20s : %s"), (LPCTSTR)data->sActionColumnText, (LPCTSTR)data->sPathColumnText);
\r
936 logfile.AddLine(temp);
\r
938 if (!sFinalInfo.IsEmpty())
\r
939 logfile.AddLine(sFinalInfo);
\r
943 m_bCancelled = TRUE;
\r
944 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
947 DWORD dwAutoClose = CRegStdWORD(_T("Software\\TortoiseSVN\\AutoClose"));
\r
948 if (m_options & ProgOptDryRun)
\r
949 dwAutoClose = 0; // dry run means progress dialog doesn't auto close at all
\r
950 if (!m_bLastVisible)
\r
952 if (m_dwCloseOnEnd != (DWORD)-1)
\r
953 dwAutoClose = m_dwCloseOnEnd; // command line value has priority over setting value
\r
954 if ((dwAutoClose == CLOSE_NOERRORS)&&(!m_bErrorsOccurred))
\r
955 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
\r
956 if ((dwAutoClose == CLOSE_NOCONFLICTS)&&(!m_bErrorsOccurred)&&(m_nConflicts==0))
\r
957 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
\r
958 if ((dwAutoClose == CLOSE_NOMERGES)&&(!m_bErrorsOccurred)&&(m_nConflicts==0)&&(!m_bMergesAddsDeletesOccurred))
\r
959 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
\r
960 if ((dwAutoClose == CLOSE_LOCAL)&&(!m_bErrorsOccurred)&&(m_nConflicts==0)&&(localoperation))
\r
961 PostMessage(WM_COMMAND, 1, (LPARAM)GetDlgItem(IDOK)->m_hWnd);
\r
963 //Don't do anything here which might cause messages to be sent to the window
\r
964 //The window thread is probably now blocked in OnOK if we've done an auto close
\r
968 void CGitProgressDlg::OnBnClickedLogbutton()
\r
970 if (m_targetPathList.GetCount() != 1)
\r
972 StringRevMap::iterator it = m_UpdateStartRevMap.begin();
\r
973 svn_revnum_t rev = -1;
\r
974 if (it != m_UpdateStartRevMap.end())
\r
979 dlg.SetParams(m_targetPathList[0], m_RevisionEnd, m_RevisionEnd, rev, 0, TRUE);
\r
984 void CGitProgressDlg::OnClose()
\r
988 TerminateThread(m_pThread->m_hThread, (DWORD)-1);
\r
989 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
993 m_bCancelled = TRUE;
\r
996 DialogEnableWindow(IDCANCEL, TRUE);
\r
997 __super::OnClose();
\r
1000 void CGitProgressDlg::OnOK()
\r
1002 if ((m_bCancelled)&&(!m_bThreadRunning))
\r
1004 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish
\r
1005 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you
\r
1006 // don't do any more operations on the window which might require message passing
\r
1007 // If you try to send windows messages once we're waiting here, then the thread can't finished
\r
1008 // because the Window's message loop is blocked at this wait
\r
1009 WaitForSingleObject(m_pThread->m_hThread, 10000);
\r
1012 m_bCancelled = TRUE;
\r
1015 void CGitProgressDlg::OnCancel()
\r
1017 if ((m_bCancelled)&&(!m_bThreadRunning))
\r
1018 __super::OnCancel();
\r
1019 m_bCancelled = TRUE;
\r
1022 void CGitProgressDlg::OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
\r
1024 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
1028 if (pDispInfo->item.mask & LVIF_TEXT)
\r
1030 if (pDispInfo->item.iItem < (int)m_arData.size())
\r
1032 const NotificationData * data = m_arData[pDispInfo->item.iItem];
\r
1033 switch (pDispInfo->item.iSubItem)
\r
1036 lstrcpyn(m_columnbuf, data->sActionColumnText, MAX_PATH);
\r
1039 lstrcpyn(m_columnbuf, data->sPathColumnText, pDispInfo->item.cchTextMax);
\r
1040 if (!data->bAuxItem)
\r
1042 int cWidth = m_ProgList.GetColumnWidth(1);
\r
1043 cWidth = max(12, cWidth-12);
\r
1044 CDC * pDC = m_ProgList.GetDC();
\r
1047 CFont * pFont = pDC->SelectObject(m_ProgList.GetFont());
\r
1048 PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);
\r
1049 pDC->SelectObject(pFont);
\r
1055 lstrcpyn(m_columnbuf, data->mime_type, MAX_PATH);
\r
1058 m_columnbuf[0] = 0;
\r
1060 pDispInfo->item.pszText = m_columnbuf;
\r
1067 void CGitProgressDlg::OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
\r
1069 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
1071 // Take the default processing unless we set this to something else below.
\r
1072 *pResult = CDRF_DODEFAULT;
\r
1074 // First thing - check the draw stage. If it's the control's prepaint
\r
1075 // stage, then tell Windows we want messages for every item.
\r
1077 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
\r
1079 *pResult = CDRF_NOTIFYITEMDRAW;
\r
1081 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
\r
1083 // This is the prepaint stage for an item. Here's where we set the
\r
1084 // item's text color. Our return value will tell Windows to draw the
\r
1085 // item itself, but it will use the new color we set here.
\r
1087 // Tell Windows to paint the control itself.
\r
1088 *pResult = CDRF_DODEFAULT;
\r
1090 ASSERT(pLVCD->nmcd.dwItemSpec < m_arData.size());
\r
1091 if(pLVCD->nmcd.dwItemSpec >= m_arData.size())
\r
1095 const NotificationData * data = m_arData[pLVCD->nmcd.dwItemSpec];
\r
1096 ASSERT(data != NULL);
\r
1100 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
1101 pLVCD->clrText = data->color;
\r
1105 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
\r
1107 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
1109 if (pNMLV->iItem < 0)
\r
1111 if (m_options & ProgOptDryRun)
\r
1112 return; //don't do anything in a dry-run.
\r
1114 const NotificationData * data = m_arData[pNMLV->iItem];
\r
1118 if (data->bConflictedActionItem)
\r
1120 // We've double-clicked on a conflicted item - do a three-way merge on it
\r
1121 SVNDiff::StartConflictEditor(data->path);
\r
1123 else if ((data->action == svn_wc_notify_update_update) && ((data->content_state == svn_wc_notify_state_merged)||(SVNProgress_Merge == m_Command)) || (data->action == svn_wc_notify_resolved))
\r
1125 // This is a modified file which has been merged on update. Diff it against base
\r
1126 CTSVNPath temporaryFile;
\r
1127 SVNDiff diff(this, this->m_hWnd, true);
\r
1128 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1129 svn_revnum_t baseRev = 0;
\r
1130 diff.DiffFileAgainstBase(data->path, baseRev);
\r
1132 else if ((!data->bAuxItem)&&(data->path.Exists())&&(!data->path.IsDirectory()))
\r
1134 bool bOpenWith = false;
\r
1135 int ret = (int)ShellExecute(m_hWnd, NULL, data->path.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);
\r
1136 if (ret <= HINSTANCE_ERROR)
\r
1140 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1141 cmd += data->path.GetWinPathString() + _T(" ");
\r
1142 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1147 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
\r
1149 LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
\r
1150 if (m_bThreadRunning)
\r
1152 if (m_nSortedColumn == phdr->iItem)
\r
1153 m_bAscending = !m_bAscending;
\r
1155 m_bAscending = TRUE;
\r
1156 m_nSortedColumn = phdr->iItem;
\r
1160 m_ProgList.SetRedraw(FALSE);
\r
1161 m_ProgList.DeleteAllItems();
\r
1162 m_ProgList.SetItemCountEx (static_cast<int>(m_arData.size()));
\r
1164 m_ProgList.SetRedraw(TRUE);
\r
1169 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData* pData)
\r
1171 return pData->bAuxItem;
\r
1174 LRESULT CGitProgressDlg::OnSVNProgress(WPARAM /*wParam*/, LPARAM lParam)
\r
1176 SVNProgress * pProgressData = (SVNProgress *)lParam;
\r
1177 CProgressCtrl * progControl = (CProgressCtrl *)GetDlgItem(IDC_PROGRESSBAR);
\r
1178 if ((pProgressData->total > 1000)&&(!progControl->IsWindowVisible()))
\r
1180 progControl->ShowWindow(SW_SHOW);
\r
1182 if (((pProgressData->total < 0)&&(pProgressData->progress > 1000)&&(progControl->IsWindowVisible()))&&(m_itemCountTotal<0))
\r
1184 progControl->ShowWindow(SW_HIDE);
\r
1186 if (!GetDlgItem(IDC_PROGRESSLABEL)->IsWindowVisible())
\r
1187 GetDlgItem(IDC_PROGRESSLABEL)->ShowWindow(SW_SHOW);
\r
1188 SetTimer(TRANSFERTIMER, 2000, NULL);
\r
1189 if ((pProgressData->total > 0)&&(pProgressData->progress > 1000))
\r
1191 progControl->SetPos((int)pProgressData->progress);
\r
1192 progControl->SetRange32(0, (int)pProgressData->total);
\r
1195 if (pProgressData->overall_total < 1024)
\r
1196 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALBYTESTRANSFERRED, pProgressData->overall_total);
\r
1197 else if (pProgressData->overall_total < 1200000)
\r
1198 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALTRANSFERRED, pProgressData->overall_total / 1024);
\r
1200 m_sTotalBytesTransferred.Format(IDS_SVN_PROGRESS_TOTALMBTRANSFERRED, (double)((double)pProgressData->overall_total / 1024000.0));
\r
1201 progText.Format(IDS_SVN_PROGRESS_TOTALANDSPEED, (LPCTSTR)m_sTotalBytesTransferred, (LPCTSTR)pProgressData->SpeedString);
\r
1202 SetDlgItemText(IDC_PROGRESSLABEL, progText);
\r
1206 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent)
\r
1208 if (nIDEvent == TRANSFERTIMER)
\r
1211 CString progSpeed;
\r
1212 progSpeed.Format(IDS_SVN_PROGRESS_BYTES_SEC, 0);
\r
1213 progText.Format(IDS_SVN_PROGRESS_TOTALANDSPEED, (LPCTSTR)m_sTotalBytesTransferred, (LPCTSTR)progSpeed);
\r
1214 SetDlgItemText(IDC_PROGRESSLABEL, progText);
\r
1215 KillTimer(TRANSFERTIMER);
\r
1217 if (nIDEvent == VISIBLETIMER)
\r
1219 if (nEnsureVisibleCount)
\r
1220 m_ProgList.EnsureVisible(m_ProgList.GetItemCount()-1, false);
\r
1221 nEnsureVisibleCount = 0;
\r
1225 void CGitProgressDlg::Sort()
\r
1227 if(m_arData.size() < 2)
\r
1232 // We need to sort the blocks which lie between the auxiliary entries
\r
1233 // This is so that any aux data stays where it was
\r
1234 NotificationDataVect::iterator actionBlockBegin;
\r
1235 NotificationDataVect::iterator actionBlockEnd = m_arData.begin(); // We start searching from here
\r
1239 // Search to the start of the non-aux entry in the next block
\r
1240 actionBlockBegin = std::find_if(actionBlockEnd, m_arData.end(), std::not1(std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux)));
\r
1241 if(actionBlockBegin == m_arData.end())
\r
1243 // There are no more actions
\r
1246 // Now search to find the end of the block
\r
1247 actionBlockEnd = std::find_if(actionBlockBegin+1, m_arData.end(), std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux));
\r
1248 // Now sort the block
\r
1249 std::sort(actionBlockBegin, actionBlockEnd, &CGitProgressDlg::SortCompare);
\r
1253 bool CGitProgressDlg::SortCompare(const NotificationData * pData1, const NotificationData * pData2)
\r
1256 switch (m_nSortedColumn)
\r
1258 case 0: //action column
\r
1259 result = pData1->sActionColumnText.Compare(pData2->sActionColumnText);
\r
1261 case 1: //path column
\r
1262 // Compare happens after switch()
\r
1264 case 2: //mime-type column
\r
1265 result = pData1->mime_type.Compare(pData2->mime_type);
\r
1271 // Sort by path if everything else is equal
\r
1274 result = CTSVNPath::Compare(pData1->path, pData2->path);
\r
1277 if (!m_bAscending)
\r
1279 return result < 0;
\r
1282 BOOL CGitProgressDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
1284 if (!GetDlgItem(IDOK)->IsWindowEnabled())
\r
1286 // only show the wait cursor over the list control
\r
1287 if ((pWnd)&&(pWnd == GetDlgItem(IDC_SVNPROGRESS)))
\r
1289 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r
1294 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
1296 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
1299 BOOL CGitProgressDlg::PreTranslateMessage(MSG* pMsg)
\r
1301 if (pMsg->message == WM_KEYDOWN)
\r
1303 if (pMsg->wParam == VK_ESCAPE)
\r
1305 // pressing the ESC key should close the dialog. But since we disabled the escape
\r
1306 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
\r
1307 // this won't work.
\r
1308 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
\r
1309 // the impression that the OK button was pressed.
\r
1310 if ((!m_bThreadRunning)&&(!GetDlgItem(IDCANCEL)->IsWindowEnabled())
\r
1311 &&(GetDlgItem(IDOK)->IsWindowEnabled())&&(GetDlgItem(IDOK)->IsWindowVisible()))
\r
1313 // since we convert ESC to RETURN, make sure the OK button has the focus.
\r
1314 GetDlgItem(IDOK)->SetFocus();
\r
1315 pMsg->wParam = VK_RETURN;
\r
1318 if (pMsg->wParam == 'A')
\r
1320 if (GetKeyState(VK_CONTROL)&0x8000)
\r
1322 // Ctrl-A -> select all
\r
1323 m_ProgList.SetSelectionMark(0);
\r
1324 for (int i=0; i<m_ProgList.GetItemCount(); ++i)
\r
1326 m_ProgList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
\r
1330 if ((pMsg->wParam == 'C')||(pMsg->wParam == VK_INSERT))
\r
1332 int selIndex = m_ProgList.GetSelectionMark();
\r
1333 if (selIndex >= 0)
\r
1335 if (GetKeyState(VK_CONTROL)&0x8000)
\r
1337 //Ctrl-C -> copy to clipboard
\r
1338 CString sClipdata;
\r
1339 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
\r
1344 int nItem = m_ProgList.GetNextSelectedItem(pos);
\r
1345 CString sAction = m_ProgList.GetItemText(nItem, 0);
\r
1346 CString sPath = m_ProgList.GetItemText(nItem, 1);
\r
1347 CString sMime = m_ProgList.GetItemText(nItem, 2);
\r
1348 CString sLogCopyText;
\r
1349 sLogCopyText.Format(_T("%s: %s %s\r\n"),
\r
1350 (LPCTSTR)sAction, (LPCTSTR)sPath, (LPCTSTR)sMime);
\r
1351 sClipdata += sLogCopyText;
\r
1353 CStringUtils::WriteAsciiStringToClipboard(sClipdata);
\r
1358 } // if (pMsg->message == WM_KEYDOWN)
\r
1359 return __super::PreTranslateMessage(pMsg);
\r
1362 void CGitProgressDlg::OnContextMenu(CWnd* pWnd, CPoint point)
\r
1364 if (m_options & ProgOptDryRun)
\r
1365 return; // don't do anything in a dry-run.
\r
1367 if (pWnd == &m_ProgList)
\r
1369 int selIndex = m_ProgList.GetSelectionMark();
\r
1370 if ((point.x == -1) && (point.y == -1))
\r
1372 // Menu was invoked from the keyboard rather than by right-clicking
\r
1374 m_ProgList.GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
1375 m_ProgList.ClientToScreen(&rect);
\r
1376 point = rect.CenterPoint();
\r
1379 if ((selIndex >= 0)&&(!m_bThreadRunning))
\r
1381 // entry is selected, thread has finished with updating so show the popup menu
\r
1383 if (popup.CreatePopupMenu())
\r
1385 bool bAdded = false;
\r
1386 NotificationData * data = m_arData[selIndex];
\r
1387 if ((data)&&(!data->path.IsDirectory()))
\r
1389 if (data->action == svn_wc_notify_update_update || data->action == svn_wc_notify_resolved)
\r
1391 if (m_ProgList.GetSelectedCount() == 1)
\r
1393 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1397 if (data->bConflictedActionItem)
\r
1399 if (m_ProgList.GetSelectedCount() == 1)
\r
1401 popup.AppendMenuIcon(ID_EDITCONFLICT, IDS_MENUCONFLICT,IDI_CONFLICT);
\r
1402 popup.SetDefaultItem(ID_EDITCONFLICT, FALSE);
\r
1403 popup.AppendMenuIcon(ID_CONFLICTRESOLVE, IDS_SVNPROGRESS_MENUMARKASRESOLVED,IDI_RESOLVE);
\r
1405 popup.AppendMenuIcon(ID_CONFLICTUSETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS,IDI_RESOLVE);
\r
1406 popup.AppendMenuIcon(ID_CONFLICTUSEMINE, IDS_SVNPROGRESS_MENUUSEMINE,IDI_RESOLVE);
\r
1408 else if ((data->content_state == svn_wc_notify_state_merged)||(SVNProgress_Merge == m_Command)||(data->action == svn_wc_notify_resolved))
\r
1409 popup.SetDefaultItem(ID_COMPARE, FALSE);
\r
1411 if (m_ProgList.GetSelectedCount() == 1)
\r
1413 if ((data->action == svn_wc_notify_add)||
\r
1414 (data->action == svn_wc_notify_update_add)||
\r
1415 (data->action == svn_wc_notify_commit_added)||
\r
1416 (data->action == svn_wc_notify_commit_modified)||
\r
1417 (data->action == svn_wc_notify_restore)||
\r
1418 (data->action == svn_wc_notify_revert)||
\r
1419 (data->action == svn_wc_notify_resolved)||
\r
1420 (data->action == svn_wc_notify_commit_replaced)||
\r
1421 (data->action == svn_wc_notify_commit_modified)||
\r
1422 (data->action == svn_wc_notify_commit_postfix_txdelta)||
\r
1423 (data->action == svn_wc_notify_update_update))
\r
1425 popup.AppendMenuIcon(ID_LOG, IDS_MENULOG,IDI_LOG);
\r
1426 if (data->action == svn_wc_notify_update_update)
\r
1427 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1428 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
1429 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
1433 } // if ((data)&&(!data->path.IsDirectory()))
\r
1434 if (m_ProgList.GetSelectedCount() == 1)
\r
1438 CString sPath = GetPathFromColumnText(data->sPathColumnText);
\r
1439 if ((!sPath.IsEmpty())&&(!SVN::PathIsURL(CTSVNPath(sPath))))
\r
1441 CTSVNPath path = CTSVNPath(sPath);
\r
1442 if (path.GetDirectory().Exists())
\r
1444 popup.AppendMenuIcon(ID_EXPLORE, IDS_SVNPROGRESS_MENUOPENPARENT, IDI_EXPLORER);
\r
1450 if (m_ProgList.GetSelectedCount() > 0)
\r
1453 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1454 popup.AppendMenuIcon(ID_COPY, IDS_LOG_POPUP_COPYTOCLIPBOARD,IDI_COPYCLIP);
\r
1459 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1460 DialogEnableWindow(IDOK, FALSE);
\r
1461 this->SetPromptApp(&theApp);
\r
1462 theApp.DoWaitCursor(1);
\r
1463 bool bOpenWith = false;
\r
1469 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
\r
1472 int nItem = m_ProgList.GetNextSelectedItem(pos);
\r
1473 NotificationData * data = m_arData[nItem];
\r
1476 sLines += data->sPathColumnText;
\r
1477 sLines += _T("\r\n");
\r
1480 sLines.TrimRight();
\r
1481 if (!sLines.IsEmpty())
\r
1483 CStringUtils::WriteAsciiStringToClipboard(sLines, GetSafeHwnd());
\r
1489 CString sPath = GetPathFromColumnText(data->sPathColumnText);
\r
1491 CTSVNPath path = CTSVNPath(sPath);
\r
1492 ShellExecute(m_hWnd, _T("explore"), path.GetDirectory().GetWinPath(), NULL, path.GetDirectory().GetWinPath(), SW_SHOW);
\r
1497 svn_revnum_t rev = -1;
\r
1498 StringRevMap::iterator it = m_UpdateStartRevMap.end();
\r
1499 if (data->basepath.IsEmpty())
\r
1500 it = m_UpdateStartRevMap.begin();
\r
1502 it = m_UpdateStartRevMap.find(data->basepath.GetSVNApiPath(pool));
\r
1503 if (it != m_UpdateStartRevMap.end())
\r
1505 // if the file was merged during update, do a three way diff between OLD, MINE, THEIRS
\r
1506 if (data->content_state == svn_wc_notify_state_merged)
\r
1508 CTSVNPath basefile = CTempFiles::Instance().GetTempFilePath(false, data->path, rev);
\r
1509 CTSVNPath newfile = CTempFiles::Instance().GetTempFilePath(false, data->path, SVNRev::REV_HEAD);
\r
1511 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_WC), rev, basefile))
\r
1513 CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
1514 DialogEnableWindow(IDOK, TRUE);
\r
1517 // If necessary, convert the line-endings on the file before diffing
\r
1518 if ((DWORD)CRegDWORD(_T("Software\\TortoiseSVN\\ConvertBase"), TRUE))
\r
1520 CTSVNPath temporaryFile = CTempFiles::Instance().GetTempFilePath(false, data->path, SVNRev::REV_BASE);
\r
1521 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_BASE), SVNRev(SVNRev::REV_BASE), temporaryFile))
\r
1523 temporaryFile.Reset();
\r
1528 newfile = temporaryFile;
\r
1532 SetFileAttributes(newfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1533 SetFileAttributes(basefile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1534 CString revname, wcname, basename;
\r
1535 revname.Format(_T("%s Revision %ld"), (LPCTSTR)data->path.GetUIFileOrDirectoryName(), rev);
\r
1536 wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());
\r
1537 basename.Format(IDS_DIFF_BASENAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());
\r
1538 CAppUtils::StartExtMerge(basefile, newfile, data->path, data->path, basename, revname, wcname, CString(), true);
\r
1542 CTSVNPath tempfile = CTempFiles::Instance().GetTempFilePath(false, data->path, rev);
\r
1544 if (!svn.Cat(data->path, SVNRev(SVNRev::REV_WC), rev, tempfile))
\r
1546 CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
1547 DialogEnableWindow(IDOK, TRUE);
\r
1552 SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
\r
1553 CString revname, wcname;
\r
1554 revname.Format(_T("%s Revision %ld"), (LPCTSTR)data->path.GetUIFileOrDirectoryName(), rev);
\r
1555 wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)data->path.GetUIFileOrDirectoryName());
\r
1556 CAppUtils::StartExtDiff(
\r
1557 tempfile, data->path, revname, wcname,
\r
1558 CAppUtils::DiffFlags().AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000)));
\r
1563 case ID_EDITCONFLICT:
\r
1565 CString sPath = GetPathFromColumnText(data->sPathColumnText);
\r
1566 SVNDiff::StartConflictEditor(CTSVNPath(sPath));
\r
1569 case ID_CONFLICTUSETHEIRS:
\r
1570 case ID_CONFLICTUSEMINE:
\r
1571 case ID_CONFLICTRESOLVE:
\r
1573 svn_wc_conflict_choice_t result = svn_wc_conflict_choose_merged;
\r
1576 case ID_CONFLICTUSETHEIRS:
\r
1577 result = svn_wc_conflict_choose_theirs_full;
\r
1579 case ID_CONFLICTUSEMINE:
\r
1580 result = svn_wc_conflict_choose_mine_full;
\r
1582 case ID_CONFLICTRESOLVE:
\r
1583 result = svn_wc_conflict_choose_merged;
\r
1587 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
\r
1588 CString sResolvedPaths;
\r
1591 int nItem = m_ProgList.GetNextSelectedItem(pos);
\r
1592 NotificationData * data = m_arData[nItem];
\r
1595 if (data->bConflictedActionItem)
\r
1597 if (!svn.Resolve(data->path, result, FALSE))
\r
1599 CMessageBox::Show(m_hWnd, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);
\r
1600 DialogEnableWindow(IDOK, TRUE);
\r
1605 data->color = ::GetSysColor(COLOR_WINDOWTEXT);
\r
1606 data->action = svn_wc_notify_resolved;
\r
1607 data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);
\r
1608 data->bConflictedActionItem = false;
\r
1611 if (m_nConflicts==0)
\r
1613 // When the last conflict is resolved we remove
\r
1614 // the warning which we assume is in the last line.
\r
1615 int nIndex = m_ProgList.GetItemCount()-1;
\r
1616 VERIFY(m_ProgList.DeleteItem(nIndex));
\r
1618 delete m_arData[nIndex];
\r
1619 m_arData.pop_back();
\r
1621 sResolvedPaths += data->path.GetWinPathString() + _T("\n");
\r
1626 m_ProgList.Invalidate();
\r
1627 CString info = BuildInfoString();
\r
1628 SetDlgItemText(IDC_INFOTEXT, info);
\r
1630 if (!sResolvedPaths.IsEmpty())
\r
1633 msg.Format(IDS_SVNPROGRESS_RESOLVED, (LPCTSTR)sResolvedPaths);
\r
1634 CMessageBox::Show(m_hWnd, msg, _T("TortoiseSVN"), MB_OK | MB_ICONINFORMATION);
\r
1640 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseSVN\\NumberOfLogs"), 100);
\r
1641 int limit = (int)(DWORD)reg;
\r
1642 svn_revnum_t rev = m_RevisionEnd;
\r
1643 if (!data->basepath.IsEmpty())
\r
1645 StringRevMap::iterator it = m_FinishedRevMap.find(data->basepath.GetSVNApiPath(pool));
\r
1646 if (it != m_FinishedRevMap.end())
\r
1650 // fetch the log from HEAD, not the revision we updated to:
\r
1651 // the path might be inside an external folder which has its own
\r
1653 CString sPath = GetPathFromColumnText(data->sPathColumnText);
\r
1654 dlg.SetParams(CTSVNPath(sPath), SVNRev(), SVNRev::REV_HEAD, 1, limit, TRUE);
\r
1663 CString sWinPath = GetPathFromColumnText(data->sPathColumnText);
\r
1665 ret = (int)ShellExecute(this->m_hWnd, NULL, (LPCTSTR)sWinPath, NULL, NULL, SW_SHOWNORMAL);
\r
1666 if ((ret <= HINSTANCE_ERROR)||bOpenWith)
\r
1668 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
\r
1669 cmd += sWinPath + _T(" ");
\r
1670 CAppUtils::LaunchApplication(cmd, NULL, false);
\r
1674 DialogEnableWindow(IDOK, TRUE);
\r
1675 theApp.DoWaitCursor(-1);
\r
1682 void CGitProgressDlg::OnEnSetfocusInfotext()
\r
1685 GetDlgItemText(IDC_INFOTEXT, sTemp);
\r
1686 if (sTemp.IsEmpty())
\r
1687 GetDlgItem(IDC_INFOTEXT)->HideCaret();
\r
1690 void CGitProgressDlg::OnLvnBegindragSvnprogress(NMHDR* , LRESULT *pResult)
\r
1692 //LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
1694 int selIndex = m_ProgList.GetSelectionMark();
\r
1698 CDropFiles dropFiles; // class for creating DROPFILES struct
\r
1701 POSITION pos = m_ProgList.GetFirstSelectedItemPosition();
\r
1702 while ( (index = m_ProgList.GetNextSelectedItem(pos)) >= 0 )
\r
1704 NotificationData * data = m_arData[index];
\r
1706 if ( data->kind==svn_node_file || data->kind==svn_node_dir )
\r
1708 CString sPath = GetPathFromColumnText(data->sPathColumnText);
\r
1710 dropFiles.AddFile( sPath );
\r
1714 if ( dropFiles.GetCount()>0 )
\r
1716 dropFiles.CreateStructure();
\r
1722 void CGitProgressDlg::OnSize(UINT nType, int cx, int cy)
\r
1724 CResizableStandAloneDialog::OnSize(nType, cx, cy);
\r
1725 if ((nType == SIZE_RESTORED)&&(m_bLastVisible))
\r
1727 int count = m_ProgList.GetItemCount();
\r
1729 m_ProgList.EnsureVisible(count-1, false);
\r
1733 //////////////////////////////////////////////////////////////////////////
\r
1735 //////////////////////////////////////////////////////////////////////////
\r
1736 bool CGitProgressDlg::CmdAdd(CString& sWindowTitle, bool& localoperation)
\r
1738 localoperation = true;
\r
1739 sWindowTitle.LoadString(IDS_PROGRS_TITLE_ADD);
\r
1740 SetWindowText(sWindowTitle);
\r
1741 SetBackgroundImage(IDI_ADD_BKG);
\r
1742 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD)));
\r
1743 if (!Add(m_targetPathList, &m_ProjectProperties, svn_depth_empty, FALSE, TRUE, TRUE))
\r
1748 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
\r
1752 bool CGitProgressDlg::CmdCheckout(CString& sWindowTitle, bool& /*localoperation*/)
\r
1754 ASSERT(m_targetPathList.GetCount() == 1);
\r
1755 sWindowTitle.LoadString(IDS_PROGRS_TITLE_CHECKOUT);
\r
1756 SetBackgroundImage(IDI_CHECKOUT_BKG);
\r
1757 CTSVNPathList urls;
\r
1758 urls.LoadFromAsteriskSeparatedString(m_url.GetSVNPathString());
\r
1759 CTSVNPath checkoutdir = m_targetPathList[0];
\r
1760 for (int i=0; i<urls.GetCount(); ++i)
\r
1762 sWindowTitle = urls[i].GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;
\r
1763 SetWindowText(sWindowTitle);
\r
1764 checkoutdir = m_targetPathList[0];
\r
1765 if (urls.GetCount() > 1)
\r
1767 CString fileordir = urls[i].GetFileOrDirectoryName();
\r
1768 fileordir = CPathUtils::PathUnescape(fileordir);
\r
1769 checkoutdir.AppendPathString(fileordir);
\r
1772 sCmdInfo.Format(IDS_PROGRS_CMD_CHECKOUT,
\r
1773 (LPCTSTR)urls[i].GetSVNPathString(), (LPCTSTR)m_Revision.ToString(),
\r
1774 (LPCTSTR)SVNStatus::GetDepthString(m_depth),
\r
1775 m_options & ProgOptIgnoreExternals ? (LPCTSTR)sExtExcluded : (LPCTSTR)sExtIncluded);
\r
1776 ReportCmd(sCmdInfo);
\r
1778 if (!Checkout(urls[i], checkoutdir, m_Revision, m_Revision, m_depth, m_options & ProgOptIgnoreExternals))
\r
1780 if (m_ProgList.GetItemCount()!=0)
\r
1785 // if the checkout fails with the peg revision set to the checkout revision,
\r
1786 // try again with HEAD as the peg revision.
\r
1789 if (!Checkout(urls[i], checkoutdir, SVNRev::REV_HEAD, m_Revision, m_depth, m_options & ProgOptIgnoreExternals))
\r
1800 bool CGitProgressDlg::CmdCommit(CString& sWindowTitle, bool& /*localoperation*/)
\r
1802 sWindowTitle.LoadString(IDS_PROGRS_TITLE_COMMIT);
\r
1803 SetWindowText(sWindowTitle);
\r
1804 SetBackgroundImage(IDI_COMMIT_BKG);
\r
1805 if (m_targetPathList.GetCount()==0)
\r
1807 SetWindowText(sWindowTitle);
\r
1809 DialogEnableWindow(IDCANCEL, FALSE);
\r
1810 DialogEnableWindow(IDOK, TRUE);
\r
1812 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1815 if (m_targetPathList.GetCount()==1)
\r
1817 sWindowTitle = m_targetPathList[0].GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;
\r
1818 SetWindowText(sWindowTitle);
\r
1820 BOOL isTag = FALSE;
\r
1821 BOOL bURLFetched = FALSE;
\r
1823 for (int i=0; i<m_targetPathList.GetCount(); ++i)
\r
1825 if (bURLFetched == FALSE)
\r
1827 url = GetURLFromPath(m_targetPathList[i]);
\r
1828 if (!url.IsEmpty())
\r
1829 bURLFetched = TRUE;
\r
1830 CString urllower = url;
\r
1831 urllower.MakeLower();
\r
1832 // test if the commit goes to a tag.
\r
1833 // now since Subversion doesn't force users to
\r
1834 // create tags in the recommended /tags/ folder
\r
1835 // only a warning is shown. This won't work if the tags
\r
1836 // are stored in a non-recommended place, but the check
\r
1837 // still helps those who do.
\r
1838 if (urllower.Find(_T("/tags/"))>=0)
\r
1845 if (CMessageBox::Show(m_hWnd, IDS_PROGRS_COMMITT_TRUNK, IDS_APPNAME, MB_YESNO | MB_DEFBUTTON2 | MB_ICONEXCLAMATION)==IDNO)
\r
1848 DWORD exitcode = 0;
\r
1850 if (CHooks::Instance().PreCommit(m_selectedPaths, m_depth, m_sMessage, exitcode, error))
\r
1855 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
\r
1856 ReportError(temp);
\r
1861 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_COMMIT)));
\r
1862 CStringArray changelists;
\r
1863 if (!m_changelist.IsEmpty())
\r
1864 changelists.Add(m_changelist);
\r
1865 bool commitSuccessful = true;
\r
1866 if (!Commit(m_targetPathList, m_sMessage, changelists, m_keepchangelist,
\r
1867 m_depth, m_options & ProgOptKeeplocks))
\r
1870 error = GetLastErrorMessage();
\r
1871 // if a non-recursive commit failed with SVN_ERR_UNSUPPORTED_FEATURE,
\r
1872 // that means a folder deletion couldn't be committed.
\r
1873 if ((m_Revision != 0)&&(Err->apr_err == SVN_ERR_UNSUPPORTED_FEATURE))
\r
1875 ReportError(CString(MAKEINTRESOURCE(IDS_PROGRS_NONRECURSIVEHINT)));
\r
1877 commitSuccessful = false;
\r
1880 if (!PostCommitErr.IsEmpty())
\r
1882 ReportWarning(PostCommitErr);
\r
1884 if (commitSuccessful)
\r
1886 if (m_BugTraqProvider)
\r
1888 CComPtr<IBugTraqProvider2> pProvider = NULL;
\r
1889 HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider);
\r
1890 if (SUCCEEDED(hr))
\r
1892 BSTR commonRoot = SysAllocString(m_targetPathList.GetCommonRoot().GetDirectory().GetWinPath());
\r
1893 SAFEARRAY *pathList = SafeArrayCreateVector(VT_BSTR, 0, m_targetPathList.GetCount());
\r
1895 for (LONG index = 0; index < m_targetPathList.GetCount(); ++index)
\r
1896 SafeArrayPutElement(pathList, &index, m_targetPathList[index].GetSVNPathString().AllocSysString());
\r
1898 BSTR logMessage = m_sMessage.AllocSysString();
\r
1901 if (FAILED(hr = pProvider->OnCommitFinished(GetSafeHwnd(),
\r
1905 (LONG)m_RevisionEnd,
\r
1908 CString sErr = temp;
\r
1909 if (!sErr.IsEmpty())
\r
1910 ReportError(temp);
\r
1913 SysFreeString(temp);
\r
1917 if (CHooks::Instance().PostCommit(m_selectedPaths, m_depth, m_RevisionEnd, m_sMessage, exitcode, error))
\r
1922 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
\r
1923 ReportError(temp);
\r
1930 bool CGitProgressDlg::CmdCopy(CString& sWindowTitle, bool& /*localoperation*/)
\r
1932 ASSERT(m_targetPathList.GetCount() == 1);
\r
1933 sWindowTitle.LoadString(IDS_PROGRS_TITLE_COPY);
\r
1934 SetWindowText(sWindowTitle);
\r
1935 SetBackgroundImage(IDI_COPY_BKG);
\r
1938 sCmdInfo.Format(IDS_PROGRS_CMD_COPY,
\r
1939 m_targetPathList[0].IsUrl() ? (LPCTSTR)m_targetPathList[0].GetSVNPathString() : m_targetPathList[0].GetWinPath(),
\r
1940 (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString());
\r
1941 ReportCmd(sCmdInfo);
\r
1943 if (!Copy(m_targetPathList, m_url, m_Revision, m_pegRev, m_sMessage))
\r
1948 if (m_options & ProgOptSwitchAfterCopy)
\r
1950 sCmdInfo.Format(IDS_PROGRS_CMD_SWITCH,
\r
1951 m_targetPathList[0].GetWinPath(),
\r
1952 (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString());
\r
1953 ReportCmd(sCmdInfo);
\r
1954 if (!Switch(m_targetPathList[0], m_url, SVNRev::REV_HEAD, SVNRev::REV_HEAD, m_depth, TRUE, m_options & ProgOptIgnoreExternals))
\r
1956 if (!Switch(m_targetPathList[0], m_url, SVNRev::REV_HEAD, m_Revision, m_depth, TRUE, m_options & ProgOptIgnoreExternals))
\r
1965 if (SVN::PathIsURL(m_url))
\r
1967 CString sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING));
\r
1968 ReportNotification(sMsg);
\r
1974 bool CGitProgressDlg::CmdExport(CString& sWindowTitle, bool& /*localoperation*/)
\r
1976 ASSERT(m_targetPathList.GetCount() == 1);
\r
1977 sWindowTitle.LoadString(IDS_PROGRS_TITLE_EXPORT);
\r
1978 sWindowTitle = m_url.GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;
\r
1979 SetWindowText(sWindowTitle);
\r
1980 SetBackgroundImage(IDI_EXPORT_BKG);
\r
1982 if (m_options & ProgOptEolCRLF)
\r
1984 if (m_options & ProgOptEolLF)
\r
1986 if (m_options & ProgOptEolCR)
\r
1988 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_EXPORT)));
\r
1989 if (!Export(m_url, m_targetPathList[0], m_Revision, m_Revision, TRUE, m_options & ProgOptIgnoreExternals, m_depth, NULL, FALSE, eol))
\r
1997 bool CGitProgressDlg::CmdImport(CString& sWindowTitle, bool& /*localoperation*/)
\r
1999 ASSERT(m_targetPathList.GetCount() == 1);
\r
2000 sWindowTitle.LoadString(IDS_PROGRS_TITLE_IMPORT);
\r
2001 sWindowTitle = m_targetPathList[0].GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle;
\r
2002 SetWindowText(sWindowTitle);
\r
2003 SetBackgroundImage(IDI_IMPORT_BKG);
\r
2005 sCmdInfo.Format(IDS_PROGRS_CMD_IMPORT,
\r
2006 m_targetPathList[0].GetWinPath(), (LPCTSTR)m_url.GetSVNPathString(),
\r
2007 m_options & ProgOptIncludeIgnored ? (LPCTSTR)(_T(", ") + sIgnoredIncluded) : _T(""));
\r
2008 ReportCmd(sCmdInfo);
\r
2009 if (!Import(m_targetPathList[0], m_url, m_sMessage, &m_ProjectProperties, svn_depth_infinity, m_options & ProgOptIncludeIgnored ? true : false, false))
\r
2017 bool CGitProgressDlg::CmdLock(CString& sWindowTitle, bool& /*localoperation*/)
\r
2019 sWindowTitle.LoadString(IDS_PROGRS_TITLE_LOCK);
\r
2020 SetWindowText(sWindowTitle);
\r
2021 SetBackgroundImage(IDI_LOCK_BKG);
\r
2022 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_LOCK)));
\r
2023 if (!Lock(m_targetPathList, m_options & ProgOptLockForce, m_sMessage))
\r
2028 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
\r
2029 if (m_bLockWarning)
\r
2031 // the lock failed, because the file was outdated.
\r
2032 // ask the user whether to update the file and try again
\r
2033 if (CMessageBox::Show(m_hWnd, IDS_WARN_LOCKOUTDATED, IDS_APPNAME, MB_ICONQUESTION|MB_YESNO)==IDYES)
\r
2035 ReportString(CString(MAKEINTRESOURCE(IDS_SVNPROGRESS_UPDATEANDRETRY)), CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));
\r
2036 if (!Update(m_targetPathList, SVNRev::REV_HEAD, svn_depth_files, false, true))
\r
2041 if (!Lock(m_targetPathList, m_options & ProgOptLockForce, m_sMessage))
\r
2048 if (m_bLockExists)
\r
2050 // the locking failed because there already is a lock.
\r
2051 // if the locking-dialog is skipped in the settings, tell the
\r
2052 // user how to steal the lock anyway (i.e., how to get the lock
\r
2053 // dialog back without changing the settings)
\r
2054 if (!DWORD(CRegDWORD(_T("Software\\TortoiseSVN\\ShowLockDlg"), TRUE)))
\r
2056 ReportString(CString(MAKEINTRESOURCE(IDS_SVNPROGRESS_LOCKHINT)), CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));
\r
2063 bool CGitProgressDlg::CmdMerge(CString& sWindowTitle, bool& /*localoperation*/)
\r
2065 bool bFailed = false;
\r
2066 ASSERT(m_targetPathList.GetCount() == 1);
\r
2067 sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGE);
\r
2068 SetBackgroundImage(IDI_MERGE_BKG);
\r
2069 if (m_options & ProgOptDryRun)
\r
2071 sWindowTitle += _T(" ") + sDryRun;
\r
2073 if (m_options & ProgOptRecordOnly)
\r
2075 sWindowTitle += _T(" ") + sRecordOnly;
\r
2077 SetWindowText(sWindowTitle);
\r
2079 GetDlgItem(IDC_INFOTEXT)->ShowWindow(SW_HIDE);
\r
2080 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);
\r
2081 CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseSVN\\MergeNonInteractive"), FALSE);
\r
2082 if (DWORD(nonint))
\r
2084 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);
\r
2085 m_AlwaysConflicted = true;
\r
2087 // we only accept a revision list to merge for peg merges
\r
2088 ATLASSERT((m_revisionArray.GetCount()==0) || (m_revisionArray.GetCount() && (m_url.IsEquivalentTo(m_url2))));
\r
2090 if (m_url.IsEquivalentTo(m_url2))
\r
2092 CString sSuggestedMessage;
\r
2093 CString sMergedLogMessage;
\r
2094 CString sSeparator = CRegString(_T("Software\\TortoiseSVN\\MergeLogSeparator"), _T("........"));
\r
2097 // Merging revisions %s of %s to %s into %s, %s%s
\r
2099 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEPEG,
\r
2100 (LPCTSTR)m_revisionArray.ToListString(),
\r
2101 (LPCTSTR)m_url.GetSVNPathString(),
\r
2102 m_targetPathList[0].GetWinPath(),
\r
2103 m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry,
\r
2104 m_options & ProgOptDryRun ? ((LPCTSTR)_T(", ") + sDryRun) : _T(""));
\r
2105 ReportCmd(sCmdInfo);
\r
2107 if (!PegMerge(m_url, m_revisionArray,
\r
2108 m_pegRev.IsValid() ? m_pegRev : (m_url.IsUrl() ? SVNRev::REV_HEAD : SVNRev(SVNRev::REV_WC)),
\r
2109 m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))
\r
2111 // if the merge fails with the peg revision set,
\r
2112 // try again with HEAD as the peg revision.
\r
2113 if (!PegMerge(m_url, m_revisionArray, SVNRev::REV_HEAD,
\r
2114 m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))
\r
2124 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEURL,
\r
2125 (LPCTSTR)m_url.GetSVNPathString(), (LPCTSTR)m_Revision.ToString(),
\r
2126 (LPCTSTR)m_url2.GetSVNPathString(), (LPCTSTR)m_RevisionEnd.ToString(),
\r
2127 m_targetPathList[0].GetWinPath(),
\r
2128 m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry,
\r
2129 m_options & ProgOptDryRun ? ((LPCTSTR)_T(", ") + sDryRun) : _T(""));
\r
2130 ReportCmd(sCmdInfo);
\r
2132 if (!Merge(m_url, m_Revision, m_url2, m_RevisionEnd, m_targetPathList[0],
\r
2133 true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), !!(m_options & ProgOptDryRun), !!(m_options & ProgOptRecordOnly)))
\r
2139 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
\r
2140 GetDlgItem(IDC_INFOTEXT)->ShowWindow(SW_SHOW);
\r
2144 bool CGitProgressDlg::CmdMergeAll(CString& sWindowTitle, bool& /*localoperation*/)
\r
2146 ASSERT(m_targetPathList.GetCount() == 1);
\r
2147 sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGE);
\r
2148 SetBackgroundImage(IDI_MERGE_BKG);
\r
2149 SetWindowText(sWindowTitle);
\r
2151 ATLASSERT(m_targetPathList.GetCount() == 1);
\r
2154 sCmdInfo.LoadString(IDS_PROGRS_INFOGETTINGINFO);
\r
2155 ReportCmd(sCmdInfo);
\r
2156 CTSVNPathList suggestedSources;
\r
2157 if (!SuggestMergeSources(m_targetPathList[0], m_Revision, suggestedSources))
\r
2163 if (suggestedSources.GetCount() == 0)
\r
2166 sErr.Format(IDS_PROGRS_MERGEALLNOSOURCES, m_targetPathList[0].GetWinPath());
\r
2167 ReportError(sErr);
\r
2170 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEALL,
\r
2171 (LPCTSTR)suggestedSources[0].GetSVNPathString(),
\r
2172 m_targetPathList[0].GetWinPath(),
\r
2173 m_options & ProgOptIgnoreAncestry ? (LPCTSTR)sIgnoreAncestry : (LPCTSTR)sRespectAncestry);
\r
2174 ReportCmd(sCmdInfo);
\r
2176 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);
\r
2177 CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseSVN\\MergeNonInteractive"), FALSE);
\r
2178 if (DWORD(nonint))
\r
2180 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);
\r
2181 m_AlwaysConflicted = true;
\r
2184 SVNRevRangeArray revarray;
\r
2185 if (!PegMerge(suggestedSources[0], revarray,
\r
2187 m_targetPathList[0], true, m_depth, m_diffoptions, !!(m_options & ProgOptIgnoreAncestry), FALSE))
\r
2189 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
\r
2194 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
\r
2198 bool CGitProgressDlg::CmdMergeReintegrate(CString& sWindowTitle, bool& /*localoperation*/)
\r
2200 ASSERT(m_targetPathList.GetCount() == 1);
\r
2201 sWindowTitle.LoadString(IDS_PROGRS_TITLE_MERGEREINTEGRATE);
\r
2202 SetBackgroundImage(IDI_MERGE_BKG);
\r
2203 SetWindowText(sWindowTitle);
\r
2206 sCmdInfo.Format(IDS_PROGRS_CMD_MERGEREINTEGRATE,
\r
2207 (LPCTSTR)m_url.GetSVNPathString(),
\r
2208 m_targetPathList[0].GetWinPath());
\r
2209 ReportCmd(sCmdInfo);
\r
2211 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_SHOW);
\r
2212 CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseSVN\\MergeNonInteractive"), FALSE);
\r
2213 if (DWORD(nonint))
\r
2215 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_SETCHECK, BST_CHECKED, 0);
\r
2216 m_AlwaysConflicted = true;
\r
2219 if (!MergeReintegrate(m_url, SVNRev::REV_HEAD, m_targetPathList[0], !!(m_options & ProgOptDryRun), m_diffoptions))
\r
2222 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
\r
2226 GetDlgItem(IDC_NONINTERACTIVE)->ShowWindow(SW_HIDE);
\r
2230 bool CGitProgressDlg::CmdRename(CString& sWindowTitle, bool& localoperation)
\r
2232 ASSERT(m_targetPathList.GetCount() == 1);
\r
2233 if ((!m_targetPathList[0].IsUrl())&&(!m_url.IsUrl()))
\r
2234 localoperation = true;
\r
2235 sWindowTitle.LoadString(IDS_PROGRS_TITLE_RENAME);
\r
2236 SetWindowText(sWindowTitle);
\r
2237 SetBackgroundImage(IDI_RENAME_BKG);
\r
2238 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RENAME)));
\r
2239 if (!Move(m_targetPathList, m_url, m_Revision, m_sMessage))
\r
2247 bool CGitProgressDlg::CmdResolve(CString& sWindowTitle, bool& localoperation)
\r
2249 localoperation = true;
\r
2250 ASSERT(m_targetPathList.GetCount() == 1);
\r
2251 sWindowTitle.LoadString(IDS_PROGRS_TITLE_RESOLVE);
\r
2252 SetWindowText(sWindowTitle);
\r
2253 SetBackgroundImage(IDI_RESOLVE_BKG);
\r
2254 // check if the file may still have conflict markers in it.
\r
2255 BOOL bMarkers = FALSE;
\r
2256 if ((m_options & ProgOptSkipConflictCheck) == 0)
\r
2260 for (INT_PTR fileindex=0; (fileindex<m_targetPathList.GetCount()) && (bMarkers==FALSE); ++fileindex)
\r
2262 if (!m_targetPathList[fileindex].IsDirectory())
\r
2264 CStdioFile file(m_targetPathList[fileindex].GetWinPath(), CFile::typeBinary | CFile::modeRead);
\r
2265 CString strLine = _T("");
\r
2266 while (file.ReadString(strLine))
\r
2268 if (strLine.Find(_T("<<<<<<<"))==0)
\r
2278 catch (CFileException* pE)
\r
2280 TRACE(_T("CFileException in Resolve!\n"));
\r
2281 TCHAR error[10000] = {0};
\r
2282 pE->GetErrorMessage(error, 10000);
\r
2283 ReportError(error);
\r
2290 if (CMessageBox::Show(m_hWnd, IDS_PROGRS_REVERTMARKERS, IDS_APPNAME, MB_YESNO | MB_ICONQUESTION)==IDYES)
\r
2292 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE)));
\r
2293 for (INT_PTR fileindex=0; fileindex<m_targetPathList.GetCount(); ++fileindex)
\r
2294 Resolve(m_targetPathList[fileindex], svn_wc_conflict_choose_merged, true);
\r
2299 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE)));
\r
2300 for (INT_PTR fileindex=0; fileindex<m_targetPathList.GetCount(); ++fileindex)
\r
2301 Resolve(m_targetPathList[fileindex], svn_wc_conflict_choose_merged, true);
\r
2303 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
\r
2307 bool CGitProgressDlg::CmdRevert(CString& sWindowTitle, bool& localoperation)
\r
2309 localoperation = true;
\r
2310 sWindowTitle.LoadString(IDS_PROGRS_TITLE_REVERT);
\r
2311 SetWindowText(sWindowTitle);
\r
2312 SetBackgroundImage(IDI_REVERT_BKG);
\r
2314 CTSVNPathList delList = m_selectedPaths;
\r
2315 if (DWORD(CRegDWORD(_T("Software\\TortoiseSVN\\RevertWithRecycleBin"), TRUE)))
\r
2316 delList.DeleteAllFiles(true);
\r
2318 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT)));
\r
2319 if (!Revert(m_targetPathList, CStringArray(), !!(m_options & ProgOptRecursive)))
\r
2324 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
\r
2328 bool CGitProgressDlg::CmdSwitch(CString& sWindowTitle, bool& /*localoperation*/)
\r
2330 ASSERT(m_targetPathList.GetCount() == 1);
\r
2332 sWindowTitle.LoadString(IDS_PROGRS_TITLE_SWITCH);
\r
2333 SetWindowText(sWindowTitle);
\r
2334 SetBackgroundImage(IDI_SWITCH_BKG);
\r
2336 if (st.GetStatus(m_targetPathList[0]) != (-2))
\r
2338 if (st.status->entry != NULL)
\r
2340 rev = st.status->entry->revision;
\r
2345 sCmdInfo.Format(IDS_PROGRS_CMD_SWITCH,
\r
2346 m_targetPathList[0].GetWinPath(), (LPCTSTR)m_url.GetSVNPathString(),
\r
2347 (LPCTSTR)m_Revision.ToString());
\r
2348 ReportCmd(sCmdInfo);
\r
2350 bool depthIsSticky = true;
\r
2351 if (m_depth == svn_depth_unknown)
\r
2352 depthIsSticky = false;
\r
2353 if (!Switch(m_targetPathList[0], m_url, m_Revision, m_Revision, m_depth, depthIsSticky, m_options & ProgOptIgnoreExternals))
\r
2358 m_UpdateStartRevMap[m_targetPathList[0].GetSVNApiPath(pool)] = rev;
\r
2359 if ((m_RevisionEnd >= 0)&&(rev >= 0)
\r
2360 &&((LONG)m_RevisionEnd > (LONG)rev))
\r
2362 GetDlgItem(IDC_LOGBUTTON)->ShowWindow(SW_SHOW);
\r
2367 bool CGitProgressDlg::CmdUnlock(CString& sWindowTitle, bool& /*localoperation*/)
\r
2369 sWindowTitle.LoadString(IDS_PROGRS_TITLE_UNLOCK);
\r
2370 SetWindowText(sWindowTitle);
\r
2371 SetBackgroundImage(IDI_UNLOCK_BKG);
\r
2372 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_UNLOCK)));
\r
2373 if (!Unlock(m_targetPathList, m_options & ProgOptLockForce))
\r
2378 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
\r
2382 bool CGitProgressDlg::CmdUpdate(CString& sWindowTitle, bool& /*localoperation*/)
\r
2384 sWindowTitle.LoadString(IDS_PROGRS_TITLE_UPDATE);
\r
2385 SetWindowText(sWindowTitle);
\r
2386 SetBackgroundImage(IDI_UPDATE_BKG);
\r
2388 int targetcount = m_targetPathList.GetCount();
\r
2391 StringRevMap uuidmap;
\r
2392 SVNRev revstore = m_Revision;
\r
2394 for(int nItem = 0; nItem < targetcount; nItem++)
\r
2396 const CTSVNPath& targetPath = m_targetPathList[nItem];
\r
2398 LONG headrev = -1;
\r
2399 m_Revision = revstore;
\r
2400 if (m_Revision.IsHead())
\r
2402 if ((targetcount > 1)&&((headrev = st.GetStatus(targetPath, true)) != (-2)))
\r
2404 if (st.status->entry != NULL)
\r
2407 m_UpdateStartRevMap[targetPath.GetSVNApiPath(pool)] = st.status->entry->cmt_rev;
\r
2408 if (st.status->entry->uuid)
\r
2410 uuid = st.status->entry->uuid;
\r
2411 StringRevMap::iterator iter = uuidmap.lower_bound(uuid);
\r
2412 if (iter == uuidmap.end() || iter->first != uuid)
\r
2414 uuidmap.insert(iter, std::make_pair(uuid, headrev));
\r
2418 headrev = iter->second;
\r
2419 m_Revision = headrev;
\r
2422 m_Revision = headrev;
\r
2427 if ((headrev = st.GetStatus(targetPath, FALSE)) != (-2))
\r
2429 if (st.status->entry != NULL)
\r
2430 m_UpdateStartRevMap[targetPath.GetSVNApiPath(pool)] = st.status->entry->cmt_rev;
\r
2433 if (uuidmap.size() > 1)
\r
2434 m_Revision = SVNRev::REV_HEAD;
\r
2435 } // if (m_Revision.IsHead())
\r
2436 } // for(int nItem = 0; nItem < targetcount; nItem++)
\r
2437 sWindowTitle = m_targetPathList.GetCommonRoot().GetWinPathString()+_T(" - ")+sWindowTitle;
\r
2438 SetWindowText(sWindowTitle);
\r
2440 DWORD exitcode = 0;
\r
2442 if (CHooks::Instance().PreUpdate(m_targetPathList, m_depth, nUUIDs > 1 ? revstore : m_Revision, exitcode, error))
\r
2447 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
\r
2448 ReportError(temp);
\r
2452 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_UPDATE)));
\r
2455 // the selected items are from different repositories,
\r
2456 // so we have to update them separately
\r
2457 for(int nItem = 0; nItem < targetcount; nItem++)
\r
2459 const CTSVNPath& targetPath = m_targetPathList[nItem];
\r
2460 m_basePath = targetPath;
\r
2462 sNotify.Format(IDS_PROGRS_UPDATEPATH, m_basePath.GetWinPath());
\r
2463 ReportString(sNotify, CString(MAKEINTRESOURCE(IDS_WARN_NOTE)));
\r
2464 if (!Update(CTSVNPathList(targetPath), revstore, m_depth, TRUE, m_options & ProgOptIgnoreExternals))
\r
2473 // if we have only one target path, but that target path does not exist,
\r
2474 // we have to check whether at least the parent path exists. If not,
\r
2475 // then we have to update all paths in between the first path that exists and the
\r
2476 // parent path of the one we want to update
\r
2477 // This is required so a user can create a sparse checkout without having
\r
2478 // to update all intermediate folders manually
\r
2479 if ((m_targetPathList.GetCount() == 1) && (!m_targetPathList[0].Exists()))
\r
2481 CTSVNPath wcPath = m_targetPathList[0].GetContainingDirectory();
\r
2482 CTSVNPath existingParentPath = wcPath.GetContainingDirectory();
\r
2483 while (!existingParentPath.Exists() && (existingParentPath.GetWinPathString().GetLength() > 2))
\r
2485 existingParentPath = existingParentPath.GetContainingDirectory();
\r
2487 if (existingParentPath.GetWinPathString().GetLength() && !existingParentPath.IsEquivalentTo(wcPath))
\r
2489 // update all intermediate directories with depth 'empty'
\r
2490 CTSVNPath intermediatepath = existingParentPath;
\r
2491 bool bSuccess = true;
\r
2492 while (bSuccess && intermediatepath.IsAncestorOf(wcPath) && !intermediatepath.IsEquivalentTo(wcPath))
\r
2494 CString childname = wcPath.GetWinPathString().Mid(intermediatepath.GetWinPathString().GetLength(),
\r
2495 wcPath.GetWinPathString().Find('\\', intermediatepath.GetWinPathString().GetLength()+1)-intermediatepath.GetWinPathString().GetLength());
\r
2496 if (childname.IsEmpty())
\r
2497 intermediatepath = wcPath;
\r
2499 intermediatepath.AppendPathString(childname);
\r
2500 bSuccess = !!Update(CTSVNPathList(intermediatepath), m_Revision, svn_depth_empty, false, true);
\r
2510 if (!Update(m_targetPathList, m_Revision, m_depth, TRUE, m_options & ProgOptIgnoreExternals))
\r
2516 if (CHooks::Instance().PostUpdate(m_targetPathList, m_depth, m_RevisionEnd, exitcode, error))
\r
2521 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
\r
2522 ReportError(temp);
\r
2527 // after an update, show the user the log button, but only if only one single item was updated
\r
2528 // (either a file or a directory)
\r
2529 if ((m_targetPathList.GetCount() == 1)&&(m_UpdateStartRevMap.size()>0))
\r
2530 GetDlgItem(IDC_LOGBUTTON)->ShowWindow(SW_SHOW);
\r
2535 void CGitProgressDlg::OnBnClickedNoninteractive()
\r
2537 LRESULT res = ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE)->GetSafeHwnd(), BM_GETCHECK, 0, 0);
\r
2538 m_AlwaysConflicted = (res == BST_CHECKED);
\r
2539 CRegDWORD nonint = CRegDWORD(_T("Software\\TortoiseSVN\\MergeNonInteractive"), FALSE);
\r
2540 nonint = m_AlwaysConflicted;
\r
2543 CString CGitProgressDlg::GetPathFromColumnText(const CString& sColumnText)
\r
2545 CString sPath = CPathUtils::ParsePathInString(sColumnText);
\r
2546 if (sPath.Find(':')<0)
\r
2548 // the path is not absolute: add the common root of all paths to it
\r
2549 sPath = m_targetPathList.GetCommonRoot().GetDirectory().GetWinPathString() + _T("\\") + CPathUtils::ParsePathInString(sColumnText);
\r