1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "TortoiseProc.h"
22 #include "messagebox.h"
23 #include "GITProgressDlg.h"
27 #include "GitStatus.h"
29 #include "PathUtils.h"
30 #include "StringUtils.h"
32 #include "UnicodeUtils.h"
33 #include "SoundUtils.h"
36 #include "DropFiles.h"
37 //#include "GitLogHelper.h"
38 #include "RegHistory.h"
39 //#include "ConflictResolveDlg.h"
41 #include "ShellUpdater.h"
43 #include "BugTraqAssociations.h"
47 static UINT WM_GITPROGRESS
= RegisterWindowMessage(_T("TORTOISEGIT_GITPROGRESS_MSG"));
49 BOOL
CGitProgressDlg::m_bAscending
= FALSE
;
50 int CGitProgressDlg::m_nSortedColumn
= -1;
52 #define TRANSFERTIMER 100
53 #define VISIBLETIMER 101
55 enum GITProgressDlgContextMenuCommands
57 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
70 IMPLEMENT_DYNAMIC(CGitProgressDlg
, CResizableStandAloneDialog
)
71 CGitProgressDlg::CGitProgressDlg(CWnd
* pParent
/*=NULL*/)
72 : CResizableStandAloneDialog(CGitProgressDlg::IDD
, pParent
)
76 , m_Revision(_T("HEAD"))
78 , m_bLockWarning(false)
79 , m_bLockExists(false)
80 , m_bThreadRunning(FALSE
)
82 , m_bErrorsOccurred(FALSE
)
83 , m_bMergesAddsDeletesOccurred(FALSE
)
85 , m_options(ProgOptNone
)
86 , m_dwCloseOnEnd((DWORD
)-1)
87 , m_bFinishedItemAdded(false)
88 , m_bLastVisible(false)
89 // , m_depth(svn_depth_unknown)
91 , m_itemCountTotal(-1)
92 , m_AlwaysConflicted(false)
93 , m_BugTraqProvider(NULL
)
94 , sIgnoredIncluded(MAKEINTRESOURCE(IDS_PROGRS_IGNOREDINCLUDED
))
95 , sExtExcluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSEXCLUDED
))
96 , sExtIncluded(MAKEINTRESOURCE(IDS_PROGRS_EXTERNALSINCLUDED
))
97 , sIgnoreAncestry(MAKEINTRESOURCE(IDS_PROGRS_IGNOREANCESTRY
))
98 , sRespectAncestry(MAKEINTRESOURCE(IDS_PROGRS_RESPECTANCESTRY
))
99 , sDryRun(MAKEINTRESOURCE(IDS_PROGRS_DRYRUN
))
100 , sRecordOnly(MAKEINTRESOURCE(IDS_MERGE_RECORDONLY
))
105 CGitProgressDlg::~CGitProgressDlg()
107 for (size_t i
=0; i
<m_arData
.size(); i
++)
111 if(m_pThread
!= NULL
)
117 void CGitProgressDlg::DoDataExchange(CDataExchange
* pDX
)
119 CResizableStandAloneDialog::DoDataExchange(pDX
);
120 DDX_Control(pDX
, IDC_SVNPROGRESS
, m_ProgList
);
123 BEGIN_MESSAGE_MAP(CGitProgressDlg
, CResizableStandAloneDialog
)
124 ON_BN_CLICKED(IDC_LOGBUTTON
, OnBnClickedLogbutton
)
125 ON_NOTIFY(NM_CUSTOMDRAW
, IDC_SVNPROGRESS
, OnNMCustomdrawSvnprogress
)
127 ON_NOTIFY(NM_DBLCLK
, IDC_SVNPROGRESS
, OnNMDblclkSvnprogress
)
128 ON_NOTIFY(HDN_ITEMCLICK
, 0, OnHdnItemclickSvnprogress
)
131 ON_REGISTERED_MESSAGE(WM_GITPROGRESS
, OnGitProgress
)
133 ON_EN_SETFOCUS(IDC_INFOTEXT
, &CGitProgressDlg::OnEnSetfocusInfotext
)
134 ON_NOTIFY(LVN_BEGINDRAG
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnBegindragSvnprogress
)
136 ON_NOTIFY(LVN_GETDISPINFO
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnGetdispinfoSvnprogress
)
137 ON_BN_CLICKED(IDC_NONINTERACTIVE
, &CGitProgressDlg::OnBnClickedNoninteractive
)
138 ON_MESSAGE(WM_SHOWCONFLICTRESOLVER
, OnShowConflictResolver
)
139 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED
, OnTaskbarBtnCreated
)
142 BOOL
CGitProgressDlg::Cancel()
147 LRESULT
CGitProgressDlg::OnShowConflictResolver(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
150 CConflictResolveDlg
dlg(this);
151 const svn_wc_conflict_description_t
*description
= (svn_wc_conflict_description_t
*)lParam
;
154 dlg
.SetConflictDescription(description
);
157 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_PAUSED
);
159 if (dlg
.DoModal() == IDOK
)
161 if (dlg
.GetResult() == svn_wc_conflict_choose_postpone
)
163 // if the result is conflicted and the dialog returned IDOK,
164 // that means we should not ask again in case of a conflict
165 m_AlwaysConflicted
= true;
166 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_SETCHECK
, BST_CHECKED
, 0);
169 m_mergedfile
= dlg
.GetMergedFile();
170 m_bCancelled
= dlg
.IsCancelled();
172 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_INDETERMINATE
);
173 return dlg
.GetResult();
176 return svn_wc_conflict_choose_postpone
;
181 svn_wc_conflict_choice_t
CGitProgressDlg::ConflictResolveCallback(const svn_wc_conflict_description_t
*description
, CString
& mergedfile
)
183 // we only bother the user when merging
184 if (((m_Command
== GitProgress_Merge
)||(m_Command
== GitProgress_MergeAll
)||(m_Command
== GitProgress_MergeReintegrate
))&&(!m_AlwaysConflicted
)&&(description
))
186 // we're in a worker thread here. That means we must not show a dialog from the thread
187 // but let the UI thread do it.
188 // To do that, we send a message to the UI thread and let it show the conflict resolver dialog.
189 LRESULT dlgResult
= ::SendMessage(GetSafeHwnd(), WM_SHOWCONFLICTRESOLVER
, 0, (LPARAM
)description
);
190 mergedfile
= m_mergedfile
;
191 return (svn_wc_conflict_choice_t
)dlgResult
;
194 return svn_wc_conflict_choose_postpone
;
197 void CGitProgressDlg::AddItemToList()
199 int totalcount
= m_ProgList
.GetItemCount();
201 m_ProgList
.SetItemCountEx(totalcount
+1, LVSICF_NOSCROLL
|LVSICF_NOINVALIDATEALL
);
202 // make columns width fit
203 if (iFirstResized
< 30)
205 // only resize the columns for the first 30 or so entries.
206 // after that, don't resize them anymore because that's an
207 // expensive function call and the columns will be sized
208 // close enough already.
213 // Make sure the item is *entirely* visible even if the horizontal
214 // scroll bar is visible.
215 int count
= m_ProgList
.GetCountPerPage();
216 if (totalcount
<= (m_ProgList
.GetTopIndex() + count
+ nEnsureVisibleCount
+ 2))
218 nEnsureVisibleCount
++;
219 m_bLastVisible
= true;
223 nEnsureVisibleCount
= 0;
225 m_bLastVisible
= false;
230 BOOL
CGitProgressDlg::Notify(const CTGitPath
& path
, git_wc_notify_action_t action
,
234 svn_node_kind_t kind, const CString& mime_type,
235 svn_wc_notify_state_t content_state,
236 svn_wc_notify_state_t prop_state, LONG rev,
237 const svn_lock_t * lock, svn_wc_notify_lock_state_t lock_state,
238 const CString& changelistname,
239 svn_merge_range_t * range,
240 svn_error_t * err, apr_pool_t * pool
243 bool bNoNotify
= false;
244 bool bDoAddData
= true;
245 NotificationData
* data
= new NotificationData();
247 data
->action
= action
;
248 data
->sPathColumnText
=path
.GetGitPathString();
249 data
->bAuxItem
= false;
252 data
->mime_type
= mime_type
;
253 data
->content_state
= content_state
;
254 data
->prop_state
= prop_state
;
256 data
->lock_state
= lock_state
;
257 data
->changelistname
= changelistname
;
258 if ((lock
)&&(lock
->owner
))
259 data
->owner
= CUnicodeUtils::GetUnicode(lock
->owner
);
260 data
->sPathColumnText
= path
.GetUIPathString();
261 if (!m_basePath
.IsEmpty())
262 data
->basepath
= m_basePath
;
264 data
->merge_range
= *range
;
266 switch (data
->action
)
268 case git_wc_notify_add
:
269 //case svn_wc_notify_update_add:
270 // if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
272 // data->color = m_Colors.GetColor(CColors::Conflict);
273 // data->bConflictedActionItem = true;
274 // data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
279 // m_bMergesAddsDeletesOccurred = true;
280 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADD
);
281 data
->color
= m_Colors
.GetColor(CColors::Added
);
284 case git_wc_notify_sendmail_start
:
285 data
->bAuxItem
= true;
286 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_START
);
287 data
->color
= m_Colors
.GetColor(CColors::Modified
);
290 case git_wc_notify_sendmail_error
:
291 data
->bAuxItem
= true;
292 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_ERROR
);
294 data
->sPathColumnText
= *strErr
;
296 data
->sPathColumnText
.Empty();
297 data
->color
= m_Colors
.GetColor(CColors::Modified
);
300 case git_wc_notify_sendmail_done
:
302 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_DONE
);
303 data
->sPathColumnText
.Empty();
304 data
->color
= m_Colors
.GetColor(CColors::Modified
);
307 case git_wc_notify_sendmail_retry
:
308 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_RETRY
);
309 data
->sPathColumnText
.Empty();
310 data
->color
= m_Colors
.GetColor(CColors::Modified
);
314 case git_wc_notify_resolved
:
315 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
318 case git_wc_notify_revert
:
319 data
->sActionColumnText
.LoadString(IDS_SVNACTION_REVERT
);
323 case svn_wc_notify_commit_added
:
324 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADDING
);
325 data
->color
= m_Colors
.GetColor(CColors::Added
);
327 case svn_wc_notify_copy
:
328 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COPY
);
330 case svn_wc_notify_commit_modified
:
331 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MODIFIED
);
332 data
->color
= m_Colors
.GetColor(CColors::Modified
);
334 case svn_wc_notify_delete
:
335 case svn_wc_notify_update_delete
:
336 data
->sActionColumnText
.LoadString(IDS_SVNACTION_DELETE
);
337 m_bMergesAddsDeletesOccurred
= true;
338 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
340 case svn_wc_notify_commit_deleted
:
341 data
->sActionColumnText
.LoadString(IDS_SVNACTION_DELETING
);
342 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
344 case svn_wc_notify_restore
:
345 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESTORE
);
348 case svn_wc_notify_update_replace
:
349 case svn_wc_notify_commit_replaced
:
350 data
->sActionColumnText
.LoadString(IDS_SVNACTION_REPLACED
);
351 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
353 case svn_wc_notify_exists
:
354 if ((data
->content_state
== svn_wc_notify_state_conflicted
) || (data
->prop_state
== svn_wc_notify_state_conflicted
))
356 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
357 data
->bConflictedActionItem
= true;
359 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CONFLICTED
);
361 else if ((data
->content_state
== svn_wc_notify_state_merged
) || (data
->prop_state
== svn_wc_notify_state_merged
))
363 data
->color
= m_Colors
.GetColor(CColors::Merged
);
364 m_bMergesAddsDeletesOccurred
= true;
365 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGED
);
368 data
->sActionColumnText
.LoadString(IDS_SVNACTION_EXISTS
);
370 case svn_wc_notify_update_update
:
371 // if this is an inoperative dir change, don't show the notification.
372 // an inoperative dir change is when a directory gets updated without
373 // any real change in either text or properties.
374 if ((kind
== svn_node_dir
)
375 && ((prop_state
== svn_wc_notify_state_inapplicable
)
376 || (prop_state
== svn_wc_notify_state_unknown
)
377 || (prop_state
== svn_wc_notify_state_unchanged
)))
382 if ((data
->content_state
== svn_wc_notify_state_conflicted
) || (data
->prop_state
== svn_wc_notify_state_conflicted
))
384 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
385 data
->bConflictedActionItem
= true;
387 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CONFLICTED
);
389 else if ((data
->content_state
== svn_wc_notify_state_merged
) || (data
->prop_state
== svn_wc_notify_state_merged
))
391 data
->color
= m_Colors
.GetColor(CColors::Merged
);
392 m_bMergesAddsDeletesOccurred
= true;
393 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGED
);
395 else if (((data
->content_state
!= svn_wc_notify_state_unchanged
)&&(data
->content_state
!= svn_wc_notify_state_unknown
)) ||
396 ((data
->prop_state
!= svn_wc_notify_state_unchanged
)&&(data
->prop_state
!= svn_wc_notify_state_unknown
)))
398 data
->sActionColumnText
.LoadString(IDS_SVNACTION_UPDATE
);
405 if (lock_state
== svn_wc_notify_lock_state_unlocked
)
407 CString
temp(MAKEINTRESOURCE(IDS_SVNACTION_UNLOCKED
));
408 data
->sActionColumnText
+= _T(", ") + temp
;
412 case svn_wc_notify_update_external
:
413 // For some reason we build a list of externals...
414 m_ExtStack
.AddHead(path
.GetUIPathString());
415 data
->sActionColumnText
.LoadString(IDS_SVNACTION_EXTERNAL
);
416 data
->bAuxItem
= true;
419 case svn_wc_notify_update_completed
:
421 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COMPLETED
);
422 data
->bAuxItem
= true;
423 bool bEmpty
= !!m_ExtStack
.IsEmpty();
425 data
->sPathColumnText
.Format(IDS_PROGRS_PATHATREV
, (LPCTSTR
)m_ExtStack
.RemoveHead(), rev
);
427 data
->sPathColumnText
.Format(IDS_PROGRS_ATREV
, rev
);
429 if ((m_nConflicts
>0)&&(bEmpty
))
431 // We're going to add another aux item - let's shove this current onto the list first
432 // I don't really like this, but it will do for the moment.
433 m_arData
.push_back(data
);
436 data
= new NotificationData();
437 data
->bAuxItem
= true;
438 data
->sActionColumnText
.LoadString(IDS_PROGRS_CONFLICTSOCCURED_WARNING
);
439 data
->sPathColumnText
.LoadString(IDS_PROGRS_CONFLICTSOCCURED
);
440 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
441 CSoundUtils::PlayTSVNWarning();
442 // This item will now be added after the switch statement
444 if (!m_basePath
.IsEmpty())
445 m_FinishedRevMap
[m_basePath
.GetSVNApiPath(pool
)] = rev
;
447 m_bFinishedItemAdded
= true;
450 case svn_wc_notify_commit_postfix_txdelta
:
451 data
->sActionColumnText
.LoadString(IDS_SVNACTION_POSTFIX
);
453 case svn_wc_notify_failed_revert
:
454 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDREVERT
);
456 case svn_wc_notify_status_completed
:
457 case svn_wc_notify_status_external
:
458 data
->sActionColumnText
.LoadString(IDS_SVNACTION_STATUS
);
460 case svn_wc_notify_skip
:
461 if ((content_state
== svn_wc_notify_state_missing
)||(content_state
== svn_wc_notify_state_obstructed
)||(content_state
== svn_wc_notify_state_conflicted
))
463 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SKIPMISSING
);
465 // The color settings dialog describes the red color with
466 // "possible or real conflict / obstructed" which also applies to
467 // skipped targets during a merge. So we just use the same color.
468 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
471 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SKIP
);
473 case svn_wc_notify_locked
:
474 if ((lock
)&&(lock
->owner
))
475 data
->sActionColumnText
.Format(IDS_SVNACTION_LOCKEDBY
, (LPCTSTR
)CUnicodeUtils::GetUnicode(lock
->owner
));
477 case svn_wc_notify_unlocked
:
478 data
->sActionColumnText
.LoadString(IDS_SVNACTION_UNLOCKED
);
480 case svn_wc_notify_failed_lock
:
481 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDLOCK
);
482 m_arData
.push_back(data
);
484 ReportError(SVN::GetErrorString(err
));
486 if (err
->apr_err
== SVN_ERR_FS_OUT_OF_DATE
)
487 m_bLockWarning
= true;
488 if (err
->apr_err
== SVN_ERR_FS_PATH_ALREADY_LOCKED
)
489 m_bLockExists
= true;
491 case svn_wc_notify_failed_unlock
:
492 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDUNLOCK
);
493 m_arData
.push_back(data
);
495 ReportError(SVN::GetErrorString(err
));
497 if (err
->apr_err
== SVN_ERR_FS_OUT_OF_DATE
)
498 m_bLockWarning
= true;
500 case svn_wc_notify_changelist_set
:
501 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTSET
, (LPCTSTR
)data
->changelistname
);
503 case svn_wc_notify_changelist_clear
:
504 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CHANGELISTCLEAR
);
506 case svn_wc_notify_changelist_moved
:
507 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTMOVED
, (LPCTSTR
)data
->changelistname
);
509 case svn_wc_notify_foreign_merge_begin
:
510 case svn_wc_notify_merge_begin
:
512 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGEBEGINNONE
);
513 else if ((data
->merge_range
.start
== data
->merge_range
.end
) || (data
->merge_range
.start
== data
->merge_range
.end
- 1))
514 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINSINGLE
, data
->merge_range
.end
);
515 else if (data
->merge_range
.start
- 1 == data
->merge_range
.end
)
516 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINSINGLEREVERSE
, data
->merge_range
.start
);
517 else if (data
->merge_range
.start
< data
->merge_range
.end
)
518 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINMULTIPLE
, data
->merge_range
.start
+ 1, data
->merge_range
.end
);
520 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINMULTIPLEREVERSE
, data
->merge_range
.start
, data
->merge_range
.end
+ 1);
521 data
->bAuxItem
= true;
526 } // switch (data->action)
534 m_arData
.push_back(data
);
536 if ((!data
->bAuxItem
) && (m_itemCount
> 0))
540 CProgressCtrl
* progControl
= (CProgressCtrl
*)GetDlgItem(IDC_PROGRESSBAR
);
541 progControl
->ShowWindow(SW_SHOW
);
542 progControl
->SetPos(m_itemCountTotal
- m_itemCount
);
543 progControl
->SetRange32(0, m_itemCountTotal
);
546 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
547 m_pTaskbarList
->SetProgressValue(m_hWnd
, m_itemCountTotal
-m_itemCount
, m_itemCountTotal
);
551 //if ((action == svn_wc_notify_commit_postfix_txdelta)&&(bSecondResized == FALSE))
554 // bSecondResized = TRUE;
562 CString
CGitProgressDlg::BuildInfoString()
565 if(this->m_Command
== GitProgress_Resolve
)
566 infotext
= _T("You need commit your change after resolve conflict");
583 for (size_t i
=0; i
<m_arData
.size(); ++i
)
585 const NotificationData
* dat
= m_arData
[i
];
588 case svn_wc_notify_add
:
589 case svn_wc_notify_update_add
:
590 case svn_wc_notify_commit_added
:
591 if (dat
->bConflictedActionItem
)
596 case svn_wc_notify_copy
:
599 case svn_wc_notify_delete
:
600 case svn_wc_notify_update_delete
:
601 case svn_wc_notify_commit_deleted
:
604 case svn_wc_notify_restore
:
607 case svn_wc_notify_revert
:
610 case svn_wc_notify_resolved
:
613 case svn_wc_notify_update_update
:
614 if (dat
->bConflictedActionItem
)
616 else if ((dat
->content_state
== svn_wc_notify_state_merged
) || (dat
->prop_state
== svn_wc_notify_state_merged
))
621 case svn_wc_notify_commit_modified
:
624 case svn_wc_notify_skip
:
627 case svn_wc_notify_commit_replaced
:
634 temp
.LoadString(IDS_SVNACTION_CONFLICTED
);
636 temp
.Format(_T(":%d "), conflicted
);
641 temp
.LoadString(IDS_SVNACTION_SKIP
);
643 infotext
.AppendFormat(_T(":%d "), skipped
);
647 temp
.LoadString(IDS_SVNACTION_MERGED
);
649 infotext
.AppendFormat(_T(":%d "), merged
);
653 temp
.LoadString(IDS_SVNACTION_ADD
);
655 infotext
.AppendFormat(_T(":%d "), added
);
659 temp
.LoadString(IDS_SVNACTION_DELETE
);
661 infotext
.AppendFormat(_T(":%d "), deleted
);
665 temp
.LoadString(IDS_SVNACTION_MODIFIED
);
667 infotext
.AppendFormat(_T(":%d "), modified
);
671 temp
.LoadString(IDS_SVNACTION_COPY
);
673 infotext
.AppendFormat(_T(":%d "), copied
);
677 temp
.LoadString(IDS_SVNACTION_REPLACED
);
679 infotext
.AppendFormat(_T(":%d "), replaced
);
683 temp
.LoadString(IDS_SVNACTION_UPDATE
);
685 infotext
.AppendFormat(_T(":%d "), updated
);
689 temp
.LoadString(IDS_SVNACTION_RESTORE
);
691 infotext
.AppendFormat(_T(":%d "), restored
);
695 temp
.LoadString(IDS_SVNACTION_REVERT
);
697 infotext
.AppendFormat(_T(":%d "), reverted
);
701 temp
.LoadString(IDS_SVNACTION_RESOLVE
);
703 infotext
.AppendFormat(_T(":%d "), resolved
);
709 void CGitProgressDlg::SetSelectedList(const CTGitPathList
& selPaths
)
711 m_selectedPaths
= selPaths
;
714 void CGitProgressDlg::ResizeColumns()
716 m_ProgList
.SetRedraw(FALSE
);
718 TCHAR textbuf
[MAX_PATH
];
720 int maxcol
= ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItemCount()-1;
721 for (int col
= 0; col
<= maxcol
; col
++)
723 // find the longest width of all items
724 int count
= m_ProgList
.GetItemCount();
727 hdi
.pszText
= textbuf
;
728 hdi
.cchTextMax
= sizeof(textbuf
);
729 ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItem(col
, &hdi
);
730 int cx
= m_ProgList
.GetStringWidth(hdi
.pszText
)+20; // 20 pixels for col separator and margin
732 for (int index
= 0; index
<count
; ++index
)
734 // get the width of the string and add 12 pixels for the column separator and margins
739 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sActionColumnText
) + 12;
742 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sPathColumnText
) + 12;
745 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->mime_type
) + 12;
751 m_ProgList
.SetColumnWidth(col
, cx
);
754 m_ProgList
.SetRedraw(TRUE
);
757 BOOL
CGitProgressDlg::OnInitDialog()
759 __super::OnInitDialog();
761 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
762 // do this, Explorer would be unable to send that message to our window if we
763 // were running elevated. It's OK to make the call all the time, since if we're
764 // not elevated, this is a no-op.
765 CHANGEFILTERSTRUCT cfs
= { sizeof(CHANGEFILTERSTRUCT
) };
766 typedef BOOL STDAPICALLTYPE
ChangeWindowMessageFilterExDFN(HWND hWnd
, UINT message
, DWORD action
, PCHANGEFILTERSTRUCT pChangeFilterStruct
);
767 HMODULE hUser
= ::LoadLibrary(_T("user32.dll"));
770 ChangeWindowMessageFilterExDFN
*pfnChangeWindowMessageFilterEx
= (ChangeWindowMessageFilterExDFN
*)GetProcAddress(hUser
, "ChangeWindowMessageFilterEx");
771 if (pfnChangeWindowMessageFilterEx
)
773 pfnChangeWindowMessageFilterEx(m_hWnd
, WM_TASKBARBTNCREATED
, MSGFLT_ALLOW
, &cfs
);
777 m_pTaskbarList
.Release();
778 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);
780 m_ProgList
.SetExtendedStyle (LVS_EX_FULLROWSELECT
| LVS_EX_DOUBLEBUFFER
);
782 m_ProgList
.DeleteAllItems();
783 int c
= ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItemCount()-1;
785 m_ProgList
.DeleteColumn(c
--);
787 temp
.LoadString(IDS_PROGRS_ACTION
);
788 m_ProgList
.InsertColumn(0, temp
);
789 temp
.LoadString(IDS_PROGRS_PATH
);
790 m_ProgList
.InsertColumn(1, temp
);
791 temp
.LoadString(IDS_PROGRS_MIMETYPE
);
792 m_ProgList
.InsertColumn(2, temp
);
794 m_pThread
= AfxBeginThread(ProgressThreadEntry
, this, THREAD_PRIORITY_NORMAL
,0,CREATE_SUSPENDED
);
797 ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED
)));
801 m_pThread
->m_bAutoDelete
= FALSE
;
802 m_pThread
->ResumeThread();
807 // Call this early so that the column headings aren't hidden before any
811 SetTimer(VISIBLETIMER
, 300, NULL
);
813 AddAnchor(IDC_SVNPROGRESS
, TOP_LEFT
, BOTTOM_RIGHT
);
814 AddAnchor(IDC_PROGRESSLABEL
, BOTTOM_LEFT
, BOTTOM_CENTER
);
815 AddAnchor(IDC_PROGRESSBAR
, BOTTOM_CENTER
, BOTTOM_RIGHT
);
816 AddAnchor(IDC_INFOTEXT
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
817 AddAnchor(IDC_NONINTERACTIVE
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
818 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
819 AddAnchor(IDOK
, BOTTOM_RIGHT
);
820 AddAnchor(IDC_LOGBUTTON
, BOTTOM_RIGHT
);
821 //SetPromptParentWindow(this->m_hWnd);
823 CenterWindow(CWnd::FromHandle(hWndExplorer
));
824 EnableSaveRestore(_T("GITProgressDlg"));
828 bool CGitProgressDlg::SetBackgroundImage(UINT nID
)
830 return CAppUtils::SetListCtrlBackgroundImage(m_ProgList
.GetSafeHwnd(), nID
);
833 void CGitProgressDlg::ReportGitError()
835 ReportError(CString(git_lasterror()));
838 void CGitProgressDlg::ReportError(const CString
& sError
)
840 CSoundUtils::PlayTGitError();
841 ReportString(sError
, CString(MAKEINTRESOURCE(IDS_ERR_ERROR
)), m_Colors
.GetColor(CColors::Conflict
));
842 m_bErrorsOccurred
= true;
845 void CGitProgressDlg::ReportWarning(const CString
& sWarning
)
847 CSoundUtils::PlayTGitWarning();
848 ReportString(sWarning
, CString(MAKEINTRESOURCE(IDS_WARN_WARNING
)), m_Colors
.GetColor(CColors::Conflict
));
851 void CGitProgressDlg::ReportNotification(const CString
& sNotification
)
853 CSoundUtils::PlayTGitNotification();
854 ReportString(sNotification
, CString(MAKEINTRESOURCE(IDS_WARN_NOTE
)));
857 void CGitProgressDlg::ReportCmd(const CString
& sCmd
)
859 ReportString(sCmd
, CString(MAKEINTRESOURCE(IDS_PROGRS_CMDINFO
)), m_Colors
.GetColor(CColors::Cmd
));
862 void CGitProgressDlg::ReportString(CString sMessage
, const CString
& sMsgKind
, COLORREF color
)
864 // instead of showing a dialog box with the error message or notification,
865 // just insert the error text into the list control.
866 // that way the user isn't 'interrupted' by a dialog box popping up!
868 // the message may be split up into different lines
869 // so add a new entry for each line of the message
870 while (!sMessage
.IsEmpty())
872 NotificationData
* data
= new NotificationData();
873 data
->bAuxItem
= true;
874 data
->sActionColumnText
= sMsgKind
;
875 if (sMessage
.Find('\n')>=0)
876 data
->sPathColumnText
= sMessage
.Left(sMessage
.Find('\n'));
878 data
->sPathColumnText
= sMessage
;
879 data
->sPathColumnText
.Trim(_T("\n\r"));
881 if (sMessage
.Find('\n')>=0)
883 sMessage
= sMessage
.Mid(sMessage
.Find('\n'));
884 sMessage
.Trim(_T("\n\r"));
888 m_arData
.push_back(data
);
893 UINT
CGitProgressDlg::ProgressThreadEntry(LPVOID pVoid
)
895 return ((CGitProgressDlg
*)pVoid
)->ProgressThread();
898 UINT
CGitProgressDlg::ProgressThread()
900 // The SetParams function should have loaded something for us
903 CString sWindowTitle
;
904 bool localoperation
= false;
905 bool bSuccess
= false;
906 m_AlwaysConflicted
= false;
908 DialogEnableWindow(IDOK
, FALSE
);
909 DialogEnableWindow(IDCANCEL
, TRUE
);
910 // SetAndClearProgressInfo(m_hWnd);
911 m_itemCount
= m_itemCountTotal
;
913 InterlockedExchange(&m_bThreadRunning
, TRUE
);
915 bSecondResized
= FALSE
;
916 m_bFinishedItemAdded
= false;
917 CTime startTime
= CTime::GetCurrentTime();
920 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_INDETERMINATE
);
924 case GitProgress_Add
:
925 bSuccess
= CmdAdd(sWindowTitle
, localoperation
);
927 case GitProgress_Copy
:
928 bSuccess
= CmdCopy(sWindowTitle
, localoperation
);
930 case GitProgress_Export
:
931 bSuccess
= CmdExport(sWindowTitle
, localoperation
);
933 case GitProgress_Rename
:
934 bSuccess
= CmdRename(sWindowTitle
, localoperation
);
936 case GitProgress_Resolve
:
937 bSuccess
= CmdResolve(sWindowTitle
, localoperation
);
939 case GitProgress_Revert
:
940 bSuccess
= CmdRevert(sWindowTitle
, localoperation
);
942 case GitProgress_Switch
:
943 bSuccess
= CmdSwitch(sWindowTitle
, localoperation
);
945 case GitProgress_SendMail
:
946 bSuccess
= CmdSendMail(sWindowTitle
, localoperation
);
950 temp
.LoadString(IDS_PROGRS_TITLEFAILED
);
952 temp
.LoadString(IDS_PROGRS_TITLEFIN
);
953 sWindowTitle
= sWindowTitle
+ _T(" ") + temp
;
954 SetWindowText(sWindowTitle
);
956 KillTimer(TRANSFERTIMER
);
957 KillTimer(VISIBLETIMER
);
961 if (DidErrorsOccur())
963 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
964 m_pTaskbarList
->SetProgressValue(m_hWnd
, 100, 100);
967 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NOPROGRESS
);
970 DialogEnableWindow(IDCANCEL
, FALSE
);
971 DialogEnableWindow(IDOK
, TRUE
);
973 CString info
= BuildInfoString();
975 info
.LoadString(IDS_PROGRS_INFOFAILED
);
976 SetDlgItemText(IDC_INFOTEXT
, info
);
978 SendMessage(DM_SETDEFID
, IDOK
);
979 GetDlgItem(IDOK
)->SetFocus();
982 if (!m_sTotalBytesTransferred
.IsEmpty())
984 CTimeSpan time
= CTime::GetCurrentTime() - startTime
;
985 temp
.Format(IDS_PROGRS_TIME
, (LONG
)time
.GetTotalMinutes(), (LONG
)time
.GetSeconds());
986 sFinalInfo
.Format(IDS_PROGRS_FINALINFO
, m_sTotalBytesTransferred
, (LPCTSTR
)temp
);
987 SetDlgItemText(IDC_PROGRESSLABEL
, sFinalInfo
);
990 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_HIDE
);
992 GetDlgItem(IDC_PROGRESSBAR
)->ShowWindow(SW_HIDE
);
994 if (!m_bFinishedItemAdded
)
996 // there's no "finished: xxx" line at the end. We add one here to make
997 // sure the user sees that the command is actually finished.
998 NotificationData
* data
= new NotificationData();
999 data
->bAuxItem
= true;
1000 data
->sActionColumnText
.LoadString(IDS_PROGRS_FINISHED
);
1001 m_arData
.push_back(data
);
1005 int count
= m_ProgList
.GetItemCount();
1006 if ((count
> 0)&&(m_bLastVisible
))
1007 m_ProgList
.EnsureVisible(count
-1, FALSE
);
1012 logfile
.AddTimeLine();
1013 for (size_t i
=0; i
<m_arData
.size(); i
++)
1015 NotificationData
* data
= m_arData
[i
];
1016 temp
.Format(_T("%-20s : %s"), (LPCTSTR
)data
->sActionColumnText
, (LPCTSTR
)data
->sPathColumnText
);
1017 logfile
.AddLine(temp
);
1019 if (!sFinalInfo
.IsEmpty())
1020 logfile
.AddLine(sFinalInfo
);
1024 m_bCancelled
= TRUE
;
1025 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1029 DWORD dwAutoClose
= CRegStdDWORD(_T("Software\\TortoiseGit\\AutoClose"), CLOSE_MANUAL
);
1030 if (m_options
& ProgOptDryRun
)
1031 dwAutoClose
= 0; // dry run means progress dialog doesn't auto close at all
1032 if (!m_bLastVisible
)
1034 if (m_dwCloseOnEnd
!= (DWORD
)-1)
1035 dwAutoClose
= m_dwCloseOnEnd
; // command line value has priority over setting value
1036 if ((dwAutoClose
== CLOSE_NOERRORS
)&&(!m_bErrorsOccurred
))
1037 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1038 if ((dwAutoClose
== CLOSE_NOCONFLICTS
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0))
1039 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1040 if ((dwAutoClose
== CLOSE_NOMERGES
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(!m_bMergesAddsDeletesOccurred
))
1041 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1042 if ((dwAutoClose
== CLOSE_LOCAL
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(localoperation
))
1043 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1046 //Don't do anything here which might cause messages to be sent to the window
1047 //The window thread is probably now blocked in OnOK if we've done an auto close
1051 void CGitProgressDlg::OnBnClickedLogbutton()
1053 switch(this->m_Command
)
1055 case GitProgress_Add
:
1056 case GitProgress_Resolve
:
1059 cmd
= CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe");
1060 cmd
+= _T(" /command:commit");
1062 cmd
+= _T(" /path:\"")+g_Git
.m_CurrentDir
+_T("\"");
1064 CAppUtils::LaunchApplication(cmd
,NULL
,false);
1065 this->EndDialog(IDOK
);
1070 if (m_targetPathList
.GetCount() != 1)
1072 StringRevMap::iterator it
= m_UpdateStartRevMap
.begin();
1073 svn_revnum_t rev
= -1;
1074 if (it
!= m_UpdateStartRevMap
.end())
1079 dlg
.SetParams(m_targetPathList
[0], m_RevisionEnd
, m_RevisionEnd
, rev
, 0, TRUE
);
1085 void CGitProgressDlg::OnClose()
1089 TerminateThread(m_pThread
->m_hThread
, (DWORD
)-1);
1090 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1094 m_bCancelled
= TRUE
;
1097 DialogEnableWindow(IDCANCEL
, TRUE
);
1101 void CGitProgressDlg::OnOK()
1103 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1105 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish
1106 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you
1107 // don't do any more operations on the window which might require message passing
1108 // If you try to send windows messages once we're waiting here, then the thread can't finished
1109 // because the Window's message loop is blocked at this wait
1110 WaitForSingleObject(m_pThread
->m_hThread
, 10000);
1113 m_bCancelled
= TRUE
;
1116 void CGitProgressDlg::OnCancel()
1118 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1119 __super::OnCancel();
1120 m_bCancelled
= TRUE
;
1123 void CGitProgressDlg::OnLvnGetdispinfoSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1125 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1129 if (pDispInfo
->item
.mask
& LVIF_TEXT
)
1131 if (pDispInfo
->item
.iItem
< (int)m_arData
.size())
1133 const NotificationData
* data
= m_arData
[pDispInfo
->item
.iItem
];
1134 switch (pDispInfo
->item
.iSubItem
)
1137 lstrcpyn(m_columnbuf
, data
->sActionColumnText
, MAX_PATH
);
1140 lstrcpyn(m_columnbuf
, data
->sPathColumnText
, pDispInfo
->item
.cchTextMax
);
1141 if (!data
->bAuxItem
)
1143 int cWidth
= m_ProgList
.GetColumnWidth(1);
1144 cWidth
= max(12, cWidth
-12);
1145 CDC
* pDC
= m_ProgList
.GetDC();
1148 CFont
* pFont
= pDC
->SelectObject(m_ProgList
.GetFont());
1149 PathCompactPath(pDC
->GetSafeHdc(), m_columnbuf
, cWidth
);
1150 pDC
->SelectObject(pFont
);
1156 lstrcpyn(m_columnbuf
, data
->mime_type
, MAX_PATH
);
1161 pDispInfo
->item
.pszText
= m_columnbuf
;
1168 void CGitProgressDlg::OnNMCustomdrawSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1170 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1172 // Take the default processing unless we set this to something else below.
1173 *pResult
= CDRF_DODEFAULT
;
1175 // First thing - check the draw stage. If it's the control's prepaint
1176 // stage, then tell Windows we want messages for every item.
1178 if ( CDDS_PREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1180 *pResult
= CDRF_NOTIFYITEMDRAW
;
1182 else if ( CDDS_ITEMPREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1184 // This is the prepaint stage for an item. Here's where we set the
1185 // item's text color. Our return value will tell Windows to draw the
1186 // item itself, but it will use the new color we set here.
1188 // Tell Windows to paint the control itself.
1189 *pResult
= CDRF_DODEFAULT
;
1191 ASSERT(pLVCD
->nmcd
.dwItemSpec
< m_arData
.size());
1192 if(pLVCD
->nmcd
.dwItemSpec
>= m_arData
.size())
1196 const NotificationData
* data
= m_arData
[pLVCD
->nmcd
.dwItemSpec
];
1197 ASSERT(data
!= NULL
);
1201 // Store the color back in the NMLVCUSTOMDRAW struct.
1202 pLVCD
->clrText
= data
->color
;
1206 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
1209 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1211 if (pNMLV
->iItem
< 0)
1213 if (m_options
& ProgOptDryRun
)
1214 return; //don't do anything in a dry-run.
1216 const NotificationData
* data
= m_arData
[pNMLV
->iItem
];
1220 if (data
->bConflictedActionItem
)
1222 // We've double-clicked on a conflicted item - do a three-way merge on it
1223 SVNDiff::StartConflictEditor(data
->path
);
1225 else if ((data
->action
== svn_wc_notify_update_update
) && ((data
->content_state
== svn_wc_notify_state_merged
)||(GitProgress_Merge
== m_Command
)) || (data
->action
== svn_wc_notify_resolved
))
1227 // This is a modified file which has been merged on update. Diff it against base
1228 CTGitPath temporaryFile
;
1229 SVNDiff
diff(this, this->m_hWnd
, true);
1230 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1231 svn_revnum_t baseRev
= 0;
1232 diff
.DiffFileAgainstBase(data
->path
, baseRev
);
1234 else if ((!data
->bAuxItem
)&&(data
->path
.Exists())&&(!data
->path
.IsDirectory()))
1236 bool bOpenWith
= false;
1237 int ret
= (int)ShellExecute(m_hWnd
, NULL
, data
->path
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1238 if (ret
<= HINSTANCE_ERROR
)
1242 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1243 cmd
+= data
->path
.GetWinPathString() + _T(" ");
1244 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1250 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1252 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1253 if (m_bThreadRunning
)
1255 if (m_nSortedColumn
== phdr
->iItem
)
1256 m_bAscending
= !m_bAscending
;
1258 m_bAscending
= TRUE
;
1259 m_nSortedColumn
= phdr
->iItem
;
1263 m_ProgList
.SetRedraw(FALSE
);
1264 m_ProgList
.DeleteAllItems();
1265 m_ProgList
.SetItemCountEx (static_cast<int>(m_arData
.size()));
1267 m_ProgList
.SetRedraw(TRUE
);
1272 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData
* pData
)
1274 return pData
->bAuxItem
;
1277 LRESULT
CGitProgressDlg::OnGitProgress(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1280 SVNProgress
* pProgressData
= (SVNProgress
*)lParam
;
1281 CProgressCtrl
* progControl
= (CProgressCtrl
*)GetDlgItem(IDC_PROGRESSBAR
);
1282 if ((pProgressData
->total
> 1000)&&(!progControl
->IsWindowVisible()))
1284 progControl
->ShowWindow(SW_SHOW
);
1286 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
1288 if (((pProgressData
->total
< 0)&&(pProgressData
->progress
> 1000)&&(progControl
->IsWindowVisible()))&&(m_itemCountTotal
<0))
1290 progControl
->ShowWindow(SW_HIDE
);
1292 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_INDETERMINATE
);
1294 if (!GetDlgItem(IDC_PROGRESSLABEL
)->IsWindowVisible())
1295 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_SHOW
);
1296 SetTimer(TRANSFERTIMER
, 2000, NULL
);
1297 if ((pProgressData
->total
> 0)&&(pProgressData
->progress
> 1000))
1299 progControl
->SetPos((int)pProgressData
->progress
);
1300 progControl
->SetRange32(0, (int)pProgressData
->total
);
1303 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
1304 m_pTaskbarList
->SetProgressValue(m_hWnd
, pProgressData
->progress
, pProgressData
->total
);
1308 if (pProgressData
->overall_total
< 1024)
1309 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALBYTESTRANSFERRED
, pProgressData
->overall_total
);
1310 else if (pProgressData
->overall_total
< 1200000)
1311 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALTRANSFERRED
, pProgressData
->overall_total
/ 1024);
1313 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALMBTRANSFERRED
, (double)((double)pProgressData
->overall_total
/ 1024000.0));
1314 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)pProgressData
->SpeedString
);
1315 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1320 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent
)
1322 if (nIDEvent
== TRANSFERTIMER
)
1326 progSpeed
.Format(IDS_SVN_PROGRESS_BYTES_SEC
, 0);
1327 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)progSpeed
);
1328 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1329 KillTimer(TRANSFERTIMER
);
1331 if (nIDEvent
== VISIBLETIMER
)
1333 if (nEnsureVisibleCount
)
1334 m_ProgList
.EnsureVisible(m_ProgList
.GetItemCount()-1, false);
1335 nEnsureVisibleCount
= 0;
1339 void CGitProgressDlg::Sort()
1341 if(m_arData
.size() < 2)
1346 // We need to sort the blocks which lie between the auxiliary entries
1347 // This is so that any aux data stays where it was
1348 NotificationDataVect::iterator actionBlockBegin
;
1349 NotificationDataVect::iterator actionBlockEnd
= m_arData
.begin(); // We start searching from here
1353 // Search to the start of the non-aux entry in the next block
1354 actionBlockBegin
= std::find_if(actionBlockEnd
, m_arData
.end(), std::not1(std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
)));
1355 if(actionBlockBegin
== m_arData
.end())
1357 // There are no more actions
1360 // Now search to find the end of the block
1361 actionBlockEnd
= std::find_if(actionBlockBegin
+1, m_arData
.end(), std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
));
1362 // Now sort the block
1363 std::sort(actionBlockBegin
, actionBlockEnd
, &CGitProgressDlg::SortCompare
);
1367 bool CGitProgressDlg::SortCompare(const NotificationData
* pData1
, const NotificationData
* pData2
)
1370 switch (m_nSortedColumn
)
1372 case 0: //action column
1373 result
= pData1
->sActionColumnText
.Compare(pData2
->sActionColumnText
);
1375 case 1: //path column
1376 // Compare happens after switch()
1378 case 2: //mime-type column
1379 result
= pData1
->mime_type
.Compare(pData2
->mime_type
);
1385 // Sort by path if everything else is equal
1388 result
= CTGitPath::Compare(pData1
->path
, pData2
->path
);
1396 BOOL
CGitProgressDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1398 if (!GetDlgItem(IDOK
)->IsWindowEnabled())
1400 // only show the wait cursor over the list control
1401 if ((pWnd
)&&(pWnd
== GetDlgItem(IDC_SVNPROGRESS
)))
1403 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1408 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1410 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1413 BOOL
CGitProgressDlg::PreTranslateMessage(MSG
* pMsg
)
1415 if (pMsg
->message
== WM_KEYDOWN
)
1417 if (pMsg
->wParam
== VK_ESCAPE
)
1419 // pressing the ESC key should close the dialog. But since we disabled the escape
1420 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
1422 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
1423 // the impression that the OK button was pressed.
1424 if ((!m_bThreadRunning
)&&(!GetDlgItem(IDCANCEL
)->IsWindowEnabled())
1425 &&(GetDlgItem(IDOK
)->IsWindowEnabled())&&(GetDlgItem(IDOK
)->IsWindowVisible()))
1427 // since we convert ESC to RETURN, make sure the OK button has the focus.
1428 GetDlgItem(IDOK
)->SetFocus();
1429 pMsg
->wParam
= VK_RETURN
;
1432 if (pMsg
->wParam
== 'A')
1434 if (GetKeyState(VK_CONTROL
)&0x8000)
1436 // Ctrl-A -> select all
1437 m_ProgList
.SetSelectionMark(0);
1438 for (int i
=0; i
<m_ProgList
.GetItemCount(); ++i
)
1440 m_ProgList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
1444 if ((pMsg
->wParam
== 'C')||(pMsg
->wParam
== VK_INSERT
))
1446 int selIndex
= m_ProgList
.GetSelectionMark();
1449 if (GetKeyState(VK_CONTROL
)&0x8000)
1451 //Ctrl-C -> copy to clipboard
1453 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1458 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1459 CString sAction
= m_ProgList
.GetItemText(nItem
, 0);
1460 CString sPath
= m_ProgList
.GetItemText(nItem
, 1);
1461 CString sMime
= m_ProgList
.GetItemText(nItem
, 2);
1462 CString sLogCopyText
;
1463 sLogCopyText
.Format(_T("%s: %s %s\r\n"),
1464 (LPCTSTR
)sAction
, (LPCTSTR
)sPath
, (LPCTSTR
)sMime
);
1465 sClipdata
+= sLogCopyText
;
1467 CStringUtils::WriteAsciiStringToClipboard(sClipdata
);
1472 } // if (pMsg->message == WM_KEYDOWN)
1473 return __super::PreTranslateMessage(pMsg
);
1476 void CGitProgressDlg::OnContextMenu(CWnd
* /*pWnd*/, CPoint
/*point*/)
1479 if (m_options
& ProgOptDryRun
)
1480 return; // don't do anything in a dry-run.
1482 if (pWnd
== &m_ProgList
)
1484 int selIndex
= m_ProgList
.GetSelectionMark();
1485 if ((point
.x
== -1) && (point
.y
== -1))
1487 // Menu was invoked from the keyboard rather than by right-clicking
1489 m_ProgList
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1490 m_ProgList
.ClientToScreen(&rect
);
1491 point
= rect
.CenterPoint();
1494 if ((selIndex
>= 0)&&(!m_bThreadRunning
))
1496 // entry is selected, thread has finished with updating so show the popup menu
1498 if (popup
.CreatePopupMenu())
1500 bool bAdded
= false;
1501 NotificationData
* data
= m_arData
[selIndex
];
1502 if ((data
)&&(!data
->path
.IsDirectory()))
1504 if (data
->action
== svn_wc_notify_update_update
|| data
->action
== svn_wc_notify_resolved
)
1506 if (m_ProgList
.GetSelectedCount() == 1)
1508 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1512 if (data
->bConflictedActionItem
)
1514 if (m_ProgList
.GetSelectedCount() == 1)
1516 popup
.AppendMenuIcon(ID_EDITCONFLICT
, IDS_MENUCONFLICT
,IDI_CONFLICT
);
1517 popup
.SetDefaultItem(ID_EDITCONFLICT
, FALSE
);
1518 popup
.AppendMenuIcon(ID_CONFLICTRESOLVE
, IDS_SVNPROGRESS_MENUMARKASRESOLVED
,IDI_RESOLVE
);
1520 popup
.AppendMenuIcon(ID_CONFLICTUSETHEIRS
, IDS_SVNPROGRESS_MENUUSETHEIRS
,IDI_RESOLVE
);
1521 popup
.AppendMenuIcon(ID_CONFLICTUSEMINE
, IDS_SVNPROGRESS_MENUUSEMINE
,IDI_RESOLVE
);
1523 else if ((data
->content_state
== svn_wc_notify_state_merged
)||(GitProgress_Merge
== m_Command
)||(data
->action
== svn_wc_notify_resolved
))
1524 popup
.SetDefaultItem(ID_COMPARE
, FALSE
);
1526 if (m_ProgList
.GetSelectedCount() == 1)
1528 if ((data
->action
== svn_wc_notify_add
)||
1529 (data
->action
== svn_wc_notify_update_add
)||
1530 (data
->action
== svn_wc_notify_commit_added
)||
1531 (data
->action
== svn_wc_notify_commit_modified
)||
1532 (data
->action
== svn_wc_notify_restore
)||
1533 (data
->action
== svn_wc_notify_revert
)||
1534 (data
->action
== svn_wc_notify_resolved
)||
1535 (data
->action
== svn_wc_notify_commit_replaced
)||
1536 (data
->action
== svn_wc_notify_commit_modified
)||
1537 (data
->action
== svn_wc_notify_commit_postfix_txdelta
)||
1538 (data
->action
== svn_wc_notify_update_update
))
1540 popup
.AppendMenuIcon(ID_LOG
, IDS_MENULOG
,IDI_LOG
);
1541 if (data
->action
== svn_wc_notify_update_update
)
1542 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1543 popup
.AppendMenuIcon(ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
1544 popup
.AppendMenuIcon(ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
1548 } // if ((data)&&(!data->path.IsDirectory()))
1549 if (m_ProgList
.GetSelectedCount() == 1)
1553 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1554 if ((!sPath
.IsEmpty())&&(!SVN::PathIsURL(CTGitPath(sPath
))))
1556 CTGitPath path
= CTGitPath(sPath
);
1557 if (path
.GetDirectory().Exists())
1559 popup
.AppendMenuIcon(ID_EXPLORE
, IDS_SVNPROGRESS_MENUOPENPARENT
, IDI_EXPLORER
);
1565 if (m_ProgList
.GetSelectedCount() > 0)
1568 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1569 popup
.AppendMenuIcon(ID_COPY
, IDS_LOG_POPUP_COPYTOCLIPBOARD
,IDI_COPYCLIP
);
1574 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1575 DialogEnableWindow(IDOK
, FALSE
);
1576 this->SetPromptApp(&theApp
);
1577 theApp
.DoWaitCursor(1);
1578 bool bOpenWith
= false;
1584 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1587 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1588 NotificationData
* data
= m_arData
[nItem
];
1591 sLines
+= data
->sPathColumnText
;
1592 sLines
+= _T("\r\n");
1596 if (!sLines
.IsEmpty())
1598 CStringUtils::WriteAsciiStringToClipboard(sLines
, GetSafeHwnd());
1604 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1606 CTGitPath path
= CTGitPath(sPath
);
1607 ShellExecute(m_hWnd
, _T("explore"), path
.GetDirectory().GetWinPath(), NULL
, path
.GetDirectory().GetWinPath(), SW_SHOW
);
1612 svn_revnum_t rev
= -1;
1613 StringRevMap::iterator it
= m_UpdateStartRevMap
.end();
1614 if (data
->basepath
.IsEmpty())
1615 it
= m_UpdateStartRevMap
.begin();
1617 it
= m_UpdateStartRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1618 if (it
!= m_UpdateStartRevMap
.end())
1620 // if the file was merged during update, do a three way diff between OLD, MINE, THEIRS
1621 if (data
->content_state
== svn_wc_notify_state_merged
)
1623 CTGitPath basefile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1624 CTGitPath newfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_HEAD
);
1626 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, basefile
))
1628 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1629 DialogEnableWindow(IDOK
, TRUE
);
1632 // If necessary, convert the line-endings on the file before diffing
1633 if ((DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"), TRUE
))
1635 CTGitPath temporaryFile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_BASE
);
1636 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_BASE
), SVNRev(SVNRev::REV_BASE
), temporaryFile
))
1638 temporaryFile
.Reset();
1643 newfile
= temporaryFile
;
1647 SetFileAttributes(newfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1648 SetFileAttributes(basefile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1649 CString revname
, wcname
, basename
;
1650 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1651 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1652 basename
.Format(IDS_DIFF_BASENAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1653 CAppUtils::StartExtMerge(basefile
, newfile
, data
->path
, data
->path
, basename
, revname
, wcname
, CString(), true);
1657 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1659 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, tempfile
))
1661 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1662 DialogEnableWindow(IDOK
, TRUE
);
1667 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1668 CString revname
, wcname
;
1669 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1670 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1671 CAppUtils::StartExtDiff(
1672 tempfile
, data
->path
, revname
, wcname
,
1673 CAppUtils::DiffFlags().AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)));
1678 case ID_EDITCONFLICT
:
1680 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1681 SVNDiff::StartConflictEditor(CTGitPath(sPath
));
1684 case ID_CONFLICTUSETHEIRS
:
1685 case ID_CONFLICTUSEMINE
:
1686 case ID_CONFLICTRESOLVE
:
1688 svn_wc_conflict_choice_t result
= svn_wc_conflict_choose_merged
;
1691 case ID_CONFLICTUSETHEIRS
:
1692 result
= svn_wc_conflict_choose_theirs_full
;
1694 case ID_CONFLICTUSEMINE
:
1695 result
= svn_wc_conflict_choose_mine_full
;
1697 case ID_CONFLICTRESOLVE
:
1698 result
= svn_wc_conflict_choose_merged
;
1702 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1703 CString sResolvedPaths
;
1706 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1707 NotificationData
* data
= m_arData
[nItem
];
1710 if (data
->bConflictedActionItem
)
1712 if (!svn
.Resolve(data
->path
, result
, FALSE
))
1714 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1715 DialogEnableWindow(IDOK
, TRUE
);
1720 data
->color
= ::GetSysColor(COLOR_WINDOWTEXT
);
1721 data
->action
= svn_wc_notify_resolved
;
1722 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
1723 data
->bConflictedActionItem
= false;
1726 if (m_nConflicts
==0)
1728 // When the last conflict is resolved we remove
1729 // the warning which we assume is in the last line.
1730 int nIndex
= m_ProgList
.GetItemCount()-1;
1731 VERIFY(m_ProgList
.DeleteItem(nIndex
));
1733 delete m_arData
[nIndex
];
1734 m_arData
.pop_back();
1736 sResolvedPaths
+= data
->path
.GetWinPathString() + _T("\n");
1741 m_ProgList
.Invalidate();
1742 CString info
= BuildInfoString();
1743 SetDlgItemText(IDC_INFOTEXT
, info
);
1745 if (!sResolvedPaths
.IsEmpty())
1748 msg
.Format(IDS_SVNPROGRESS_RESOLVED
, (LPCTSTR
)sResolvedPaths
);
1749 CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseGit"), MB_OK
| MB_ICONINFORMATION
);
1755 svn_revnum_t rev
= m_RevisionEnd
;
1756 if (!data
->basepath
.IsEmpty())
1758 StringRevMap::iterator it
= m_FinishedRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1759 if (it
!= m_FinishedRevMap
.end())
1763 // fetch the log from HEAD, not the revision we updated to:
1764 // the path might be inside an external folder which has its own
1766 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1767 dlg
.SetParams(CTGitPath(sPath
), SVNRev(), SVNRev::REV_HEAD
, 1, -1, TRUE
);
1776 CString sWinPath
= GetPathFromColumnText(data
->sPathColumnText
);
1778 ret
= (int)ShellExecute(this->m_hWnd
, NULL
, (LPCTSTR
)sWinPath
, NULL
, NULL
, SW_SHOWNORMAL
);
1779 if ((ret
<= HINSTANCE_ERROR
)||bOpenWith
)
1781 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1782 cmd
+= sWinPath
+ _T(" ");
1783 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1787 DialogEnableWindow(IDOK
, TRUE
);
1788 theApp
.DoWaitCursor(-1);
1796 void CGitProgressDlg::OnEnSetfocusInfotext()
1799 GetDlgItemText(IDC_INFOTEXT
, sTemp
);
1800 if (sTemp
.IsEmpty())
1801 GetDlgItem(IDC_INFOTEXT
)->HideCaret();
1804 void CGitProgressDlg::OnLvnBegindragSvnprogress(NMHDR
* , LRESULT
*pResult
)
1806 //LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1808 int selIndex
= m_ProgList
.GetSelectionMark();
1812 CDropFiles dropFiles
; // class for creating DROPFILES struct
1815 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1816 while ( (index
= m_ProgList
.GetNextSelectedItem(pos
)) >= 0 )
1818 NotificationData
* data
= m_arData
[index
];
1820 if ( data
->kind
==svn_node_file
|| data
->kind
==svn_node_dir
)
1822 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1824 dropFiles
.AddFile( sPath
);
1828 if ( dropFiles
.GetCount()>0 )
1830 dropFiles
.CreateStructure();
1836 void CGitProgressDlg::OnSize(UINT nType
, int cx
, int cy
)
1838 CResizableStandAloneDialog::OnSize(nType
, cx
, cy
);
1839 if ((nType
== SIZE_RESTORED
)&&(m_bLastVisible
))
1841 if(!m_ProgList
.m_hWnd
)
1844 int count
= m_ProgList
.GetItemCount();
1846 m_ProgList
.EnsureVisible(count
-1, false);
1850 //////////////////////////////////////////////////////////////////////////
1852 //////////////////////////////////////////////////////////////////////////
1853 bool CGitProgressDlg::CmdAdd(CString
& sWindowTitle
, bool& localoperation
)
1855 localoperation
= true;
1856 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_ADD
);
1857 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
1858 SetBackgroundImage(IDI_ADD_BKG
);
1859 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD
)));
1861 // HACK for separate-git-dir, libgit2 doesn't support it atm
1862 if (CTGitPath(g_Git
.m_CurrentDir
+ _T("/.git")).IsDirectory())
1864 git_repository
*repo
= NULL
;
1867 CStringA gitdir
= CUnicodeUtils::GetMulti(CTGitPath(g_Git
.m_CurrentDir
).GetGitPathString() + _T("/.git"), CP_ACP
);
1868 if (git_repository_open(&repo
, gitdir
.GetBuffer()))
1873 if (git_repository_index(&index
, repo
))
1876 git_repository_free(repo
);
1879 if (git_index_read(index
))
1882 git_index_free(index
);
1883 git_repository_free(repo
);
1887 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
1889 if (git_index_add(index
, CStringA(CUnicodeUtils::GetMulti(m_targetPathList
[i
].GetGitPathString(), CP_ACP
)).GetBuffer(), 0))
1892 git_index_free(index
);
1893 git_repository_free(repo
);
1896 Notify(m_targetPathList
[i
],git_wc_notify_add
);
1899 if (git_index_write(index
))
1902 git_index_free(index
);
1903 git_repository_free(repo
);
1907 git_index_free(index
);
1908 git_repository_free(repo
);
1912 for(int i
= 0; i
< m_targetPathList
.GetCount(); i
++)
1915 cmd
.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList
[i
].GetGitPathString());
1916 if(g_Git
.Run(cmd
, &out
, CP_ACP
))
1918 MessageBox(out
, _T("TortoiseGit"), MB_OK
|MB_ICONERROR
);
1919 m_bErrorsOccurred
= true;
1922 Notify(m_targetPathList
[i
], git_wc_notify_add
);
1926 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
1927 m_bErrorsOccurred
=false;
1929 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
1930 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
1934 bool CGitProgressDlg::CmdCopy(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1937 ASSERT(m_targetPathList
.GetCount() == 1);
1938 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_COPY
);
1939 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1940 SetBackgroundImage(IDI_COPY_BKG
);
1943 sCmdInfo
.Format(IDS_PROGRS_CMD_COPY
,
1944 m_targetPathList
[0].IsUrl() ? (LPCTSTR
)m_targetPathList
[0].GetSVNPathString() : m_targetPathList
[0].GetWinPath(),
1945 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1946 ReportCmd(sCmdInfo
);
1948 if (!Copy(m_targetPathList
, m_url
, m_Revision
, m_pegRev
, m_sMessage
))
1953 if (m_options
& ProgOptSwitchAfterCopy
)
1955 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
1956 m_targetPathList
[0].GetWinPath(),
1957 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1958 ReportCmd(sCmdInfo
);
1959 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, SVNRev::REV_HEAD
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
1961 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, m_Revision
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
1970 if (SVN::PathIsURL(m_url
))
1972 CString
sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING
));
1973 ReportNotification(sMsg
);
1980 bool CGitProgressDlg::CmdExport(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1983 ASSERT(m_targetPathList
.GetCount() == 1);
1984 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_EXPORT
);
1985 sWindowTitle
= m_url
.GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle
;
1986 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1987 SetBackgroundImage(IDI_EXPORT_BKG
);
1989 if (m_options
& ProgOptEolCRLF
)
1991 if (m_options
& ProgOptEolLF
)
1993 if (m_options
& ProgOptEolCR
)
1995 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_EXPORT
)));
1996 if (!Export(m_url
, m_targetPathList
[0], m_Revision
, m_Revision
, TRUE
, m_options
& ProgOptIgnoreExternals
, m_depth
, NULL
, FALSE
, eol
))
2005 bool CGitProgressDlg::CmdRename(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2008 ASSERT(m_targetPathList
.GetCount() == 1);
2009 if ((!m_targetPathList
[0].IsUrl())&&(!m_url
.IsUrl()))
2010 localoperation
= true;
2011 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RENAME
);
2012 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2013 SetBackgroundImage(IDI_RENAME_BKG
);
2014 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RENAME
)));
2015 if (!Move(m_targetPathList
, m_url
, m_Revision
, m_sMessage
))
2024 bool CGitProgressDlg::CmdResolve(CString
& sWindowTitle
, bool& localoperation
)
2027 localoperation
= true;
2028 ASSERT(m_targetPathList
.GetCount() == 1);
2029 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RESOLVE
);
2030 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2031 SetBackgroundImage(IDI_RESOLVE_BKG
);
2032 // check if the file may still have conflict markers in it.
2033 //BOOL bMarkers = FALSE;
2035 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
2037 CString cmd
,out
,tempmergefile
;
2038 cmd
.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList
[i
].GetGitPathString());
2039 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
2041 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2042 m_bErrorsOccurred
=true;
2046 CAppUtils::RemoveTempMergeFile((CTGitPath
&)m_targetPathList
[i
]);
2048 Notify(m_targetPathList
[i
],git_wc_notify_resolved
);
2051 if ((m_options
& ProgOptSkipConflictCheck
) == 0)
2055 for (INT_PTR fileindex
=0; (fileindex
<m_targetPathList
.GetCount()) && (bMarkers
==FALSE
); ++fileindex
)
2057 if (!m_targetPathList
[fileindex
].IsDirectory())
2059 CStdioFile
file(m_targetPathList
[fileindex
].GetWinPath(), CFile::typeBinary
| CFile::modeRead
);
2060 CString strLine
= _T("");
2061 while (file
.ReadString(strLine
))
2063 if (strLine
.Find(_T("<<<<<<<"))==0)
2073 catch (CFileException
* pE
)
2075 TRACE(_T("CFileException in Resolve!\n"));
2076 TCHAR error
[10000] = {0};
2077 pE
->GetErrorMessage(error
, 10000);
2085 if (CMessageBox::Show(m_hWnd
, IDS_PROGRS_REVERTMARKERS
, IDS_APPNAME
, MB_YESNO
| MB_ICONQUESTION
)==IDYES
)
2087 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
2088 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
2089 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
2094 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
2095 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
2096 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
2099 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
2101 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
2102 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2107 bool CGitProgressDlg::CmdRevert(CString
& sWindowTitle
, bool& localoperation
)
2110 localoperation
= true;
2111 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_REVERT
);
2112 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2113 SetBackgroundImage(IDI_REVERT_BKG
);
2115 CTGitPathList delList
;
2116 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2120 path
.SetFromWin(g_Git
.m_CurrentDir
+_T("\\")+m_selectedPaths
[i
].GetWinPath());
2121 action
= m_selectedPaths
[i
].m_Action
;
2122 /* rename file can't delete because it needs original file*/
2123 if((!(action
& CTGitPath::LOGACTIONS_ADDED
)) &&
2124 (!(action
& CTGitPath::LOGACTIONS_REPLACED
)))
2125 delList
.AddPath(path
);
2127 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE
)))
2128 delList
.DeleteAllFiles(true);
2130 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT
)));
2131 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2133 if(g_Git
.Revert(_T("HEAD"), (CTGitPath
&)m_selectedPaths
[i
]))
2135 CMessageBox::Show(NULL
,_T("Revert Fail"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2136 m_bErrorsOccurred
=true;
2139 Notify(m_selectedPaths
[i
],git_wc_notify_revert
);
2142 CShellUpdater::Instance().AddPathsForUpdate(m_selectedPaths
);
2147 bool CGitProgressDlg::CmdSwitch(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2150 ASSERT(m_targetPathList
.GetCount() == 1);
2152 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SWITCH
);
2153 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2154 SetBackgroundImage(IDI_SWITCH_BKG
);
2156 if (st
.GetStatus(m_targetPathList
[0]) != (-2))
2158 if (st
.status
->entry
!= NULL
)
2160 rev
= st
.status
->entry
->revision
;
2165 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
2166 m_targetPathList
[0].GetWinPath(), (LPCTSTR
)m_url
.GetSVNPathString(),
2167 (LPCTSTR
)m_Revision
.ToString());
2168 ReportCmd(sCmdInfo
);
2170 bool depthIsSticky
= true;
2171 if (m_depth
== svn_depth_unknown
)
2172 depthIsSticky
= false;
2173 if (!Switch(m_targetPathList
[0], m_url
, m_Revision
, m_Revision
, m_depth
, depthIsSticky
, m_options
& ProgOptIgnoreExternals
))
2178 m_UpdateStartRevMap
[m_targetPathList
[0].GetSVNApiPath(pool
)] = rev
;
2179 if ((m_RevisionEnd
>= 0)&&(rev
>= 0)
2180 &&((LONG
)m_RevisionEnd
> (LONG
)rev
))
2182 GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2188 void CGitProgressDlg::OnBnClickedNoninteractive()
2190 LRESULT res
= ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_GETCHECK
, 0, 0);
2191 m_AlwaysConflicted
= (res
== BST_CHECKED
);
2192 CRegDWORD nonint
= CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE
);
2193 nonint
= m_AlwaysConflicted
;
2196 CString
CGitProgressDlg::GetPathFromColumnText(const CString
& sColumnText
)
2198 CString sPath
= CPathUtils::ParsePathInString(sColumnText
);
2199 if (sPath
.Find(':')<0)
2201 // the path is not absolute: add the common root of all paths to it
2202 sPath
= m_targetPathList
.GetCommonRoot().GetDirectory().GetWinPathString() + _T("\\") + CPathUtils::ParsePathInString(sColumnText
);
2207 bool CGitProgressDlg::CmdSendMail(CString
& sWindowTitle
, bool& /*localoperation*/)
2209 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SENDMAIL
);
2210 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2211 //SetBackgroundImage(IDI_ADD_BKG);
2212 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_SENDMAIL
)));
2214 if(this->m_SendMailFlags
&SENDMAIL_COMBINED
)
2218 Notify(path
,git_wc_notify_sendmail_start
);
2223 if(!!CPatch::SendPatchesCombined(m_targetPathList
,m_SendMailTO
,m_SendMailCC
,m_SendMailSubject
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
),&err
))
2225 Notify(path
,git_wc_notify_sendmail_error
,ret
,&err
);
2235 Notify(path
,git_wc_notify_sendmail_retry
,ret
,&err
);
2239 CString
str(_T("User Canceled"));
2240 Notify(path
,git_wc_notify_sendmail_error
,ret
,&str
);
2245 Notify(path
,git_wc_notify_sendmail_done
,ret
);
2249 for(int i
=0;ret
&& i
<m_targetPathList
.GetCount();i
++)
2252 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_start
);
2257 if(!!patch
.Send((CString
&)m_targetPathList
[i
].GetWinPathString(),this->m_SendMailTO
,
2258 this->m_SendMailCC
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
)))
2260 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&patch
.m_LastError
);
2271 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_retry
,ret
,&patch
.m_LastError
);
2275 CString
str(_T("User Canceled"));
2276 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&str
);
2281 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_done
,ret
);
2287 LRESULT
CGitProgressDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2289 m_pTaskbarList
.Release();
2290 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);