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"
45 #include "MassiveGitTask.h"
47 #include "SmartHandle.h"
49 static UINT WM_GITPROGRESS
= RegisterWindowMessage(_T("TORTOISEGIT_GITPROGRESS_MSG"));
51 BOOL
CGitProgressDlg::m_bAscending
= FALSE
;
52 int CGitProgressDlg::m_nSortedColumn
= -1;
54 #define TRANSFERTIMER 100
55 #define VISIBLETIMER 101
57 enum GITProgressDlgContextMenuCommands
59 // needs to start with 1, since 0 is the return value if *nothing* is clicked on in the context menu
72 IMPLEMENT_DYNAMIC(CGitProgressDlg
, CResizableStandAloneDialog
)
73 CGitProgressDlg::CGitProgressDlg(CWnd
* pParent
/*=NULL*/)
74 : CResizableStandAloneDialog(CGitProgressDlg::IDD
, pParent
)
77 , m_bErrorsOccurred(false)
79 , m_Revision(_T("HEAD"))
81 , m_bLockWarning(false)
82 , m_bLockExists(false)
83 , m_bThreadRunning(FALSE
)
85 , m_bMergesAddsDeletesOccurred(FALSE
)
87 , m_options(ProgOptNone
)
88 , m_dwCloseOnEnd((DWORD
)-1)
89 , m_bFinishedItemAdded(false)
90 , m_bLastVisible(false)
91 // , m_depth(svn_depth_unknown)
93 , m_itemCountTotal(-1)
94 , m_AlwaysConflicted(false)
95 , m_BugTraqProvider(NULL
)
96 , sDryRun(MAKEINTRESOURCE(IDS_PROGRS_DRYRUN
))
97 , sRecordOnly(MAKEINTRESOURCE(IDS_MERGE_RECORDONLY
))
102 CGitProgressDlg::~CGitProgressDlg()
104 for (size_t i
=0; i
<m_arData
.size(); i
++)
108 if(m_pThread
!= NULL
)
114 void CGitProgressDlg::DoDataExchange(CDataExchange
* pDX
)
116 CResizableStandAloneDialog::DoDataExchange(pDX
);
117 DDX_Control(pDX
, IDC_SVNPROGRESS
, m_ProgList
);
120 BEGIN_MESSAGE_MAP(CGitProgressDlg
, CResizableStandAloneDialog
)
121 ON_BN_CLICKED(IDC_LOGBUTTON
, OnBnClickedLogbutton
)
122 ON_NOTIFY(NM_CUSTOMDRAW
, IDC_SVNPROGRESS
, OnNMCustomdrawSvnprogress
)
124 ON_NOTIFY(NM_DBLCLK
, IDC_SVNPROGRESS
, OnNMDblclkSvnprogress
)
125 ON_NOTIFY(HDN_ITEMCLICK
, 0, OnHdnItemclickSvnprogress
)
128 ON_REGISTERED_MESSAGE(WM_GITPROGRESS
, OnGitProgress
)
130 ON_EN_SETFOCUS(IDC_INFOTEXT
, &CGitProgressDlg::OnEnSetfocusInfotext
)
131 ON_NOTIFY(LVN_BEGINDRAG
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnBegindragSvnprogress
)
133 ON_NOTIFY(LVN_GETDISPINFO
, IDC_SVNPROGRESS
, &CGitProgressDlg::OnLvnGetdispinfoSvnprogress
)
134 ON_BN_CLICKED(IDC_NONINTERACTIVE
, &CGitProgressDlg::OnBnClickedNoninteractive
)
135 ON_MESSAGE(WM_SHOWCONFLICTRESOLVER
, OnShowConflictResolver
)
136 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED
, OnTaskbarBtnCreated
)
139 BOOL
CGitProgressDlg::Cancel()
144 LRESULT
CGitProgressDlg::OnShowConflictResolver(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
147 CConflictResolveDlg
dlg(this);
148 const svn_wc_conflict_description_t
*description
= (svn_wc_conflict_description_t
*)lParam
;
151 dlg
.SetConflictDescription(description
);
154 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_PAUSED
);
156 if (dlg
.DoModal() == IDOK
)
158 if (dlg
.GetResult() == svn_wc_conflict_choose_postpone
)
160 // if the result is conflicted and the dialog returned IDOK,
161 // that means we should not ask again in case of a conflict
162 m_AlwaysConflicted
= true;
163 ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_SETCHECK
, BST_CHECKED
, 0);
166 m_mergedfile
= dlg
.GetMergedFile();
167 m_bCancelled
= dlg
.IsCancelled();
169 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_INDETERMINATE
);
170 return dlg
.GetResult();
173 return svn_wc_conflict_choose_postpone
;
178 svn_wc_conflict_choice_t
CGitProgressDlg::ConflictResolveCallback(const svn_wc_conflict_description_t
*description
, CString
& mergedfile
)
180 // we only bother the user when merging
181 if (((m_Command
== GitProgress_Merge
)||(m_Command
== GitProgress_MergeAll
)||(m_Command
== GitProgress_MergeReintegrate
))&&(!m_AlwaysConflicted
)&&(description
))
183 // we're in a worker thread here. That means we must not show a dialog from the thread
184 // but let the UI thread do it.
185 // To do that, we send a message to the UI thread and let it show the conflict resolver dialog.
186 LRESULT dlgResult
= ::SendMessage(GetSafeHwnd(), WM_SHOWCONFLICTRESOLVER
, 0, (LPARAM
)description
);
187 mergedfile
= m_mergedfile
;
188 return (svn_wc_conflict_choice_t
)dlgResult
;
191 return svn_wc_conflict_choose_postpone
;
194 void CGitProgressDlg::AddItemToList()
196 int totalcount
= m_ProgList
.GetItemCount();
198 m_ProgList
.SetItemCountEx(totalcount
+1, LVSICF_NOSCROLL
|LVSICF_NOINVALIDATEALL
);
199 // make columns width fit
200 if (iFirstResized
< 30)
202 // only resize the columns for the first 30 or so entries.
203 // after that, don't resize them anymore because that's an
204 // expensive function call and the columns will be sized
205 // close enough already.
210 // Make sure the item is *entirely* visible even if the horizontal
211 // scroll bar is visible.
212 int count
= m_ProgList
.GetCountPerPage();
213 if (totalcount
<= (m_ProgList
.GetTopIndex() + count
+ nEnsureVisibleCount
+ 2))
215 nEnsureVisibleCount
++;
216 m_bLastVisible
= true;
220 nEnsureVisibleCount
= 0;
222 m_bLastVisible
= false;
227 BOOL
CGitProgressDlg::Notify(const CTGitPath
& path
, git_wc_notify_action_t action
,
231 svn_node_kind_t kind, const CString& mime_type,
232 svn_wc_notify_state_t content_state,
233 svn_wc_notify_state_t prop_state, LONG rev,
234 const svn_lock_t * lock, svn_wc_notify_lock_state_t lock_state,
235 const CString& changelistname,
236 svn_merge_range_t * range,
237 svn_error_t * err, apr_pool_t * pool
240 bool bNoNotify
= false;
241 bool bDoAddData
= true;
242 NotificationData
* data
= new NotificationData();
244 data
->action
= action
;
245 data
->sPathColumnText
=path
.GetGitPathString();
246 data
->bAuxItem
= false;
249 data
->mime_type
= mime_type
;
250 data
->content_state
= content_state
;
251 data
->prop_state
= prop_state
;
253 data
->lock_state
= lock_state
;
254 data
->changelistname
= changelistname
;
255 if ((lock
)&&(lock
->owner
))
256 data
->owner
= CUnicodeUtils::GetUnicode(lock
->owner
);
257 data
->sPathColumnText
= path
.GetUIPathString();
258 if (!m_basePath
.IsEmpty())
259 data
->basepath
= m_basePath
;
261 data
->merge_range
= *range
;
263 switch (data
->action
)
265 case git_wc_notify_add
:
266 //case svn_wc_notify_update_add:
267 // if ((data->content_state == svn_wc_notify_state_conflicted) || (data->prop_state == svn_wc_notify_state_conflicted))
269 // data->color = m_Colors.GetColor(CColors::Conflict);
270 // data->bConflictedActionItem = true;
271 // data->sActionColumnText.LoadString(IDS_SVNACTION_CONFLICTED);
276 // m_bMergesAddsDeletesOccurred = true;
277 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADD
);
278 data
->color
= m_Colors
.GetColor(CColors::Added
);
281 case git_wc_notify_sendmail_start
:
282 data
->bAuxItem
= true;
283 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_START
);
284 data
->color
= m_Colors
.GetColor(CColors::Modified
);
287 case git_wc_notify_sendmail_error
:
288 data
->bAuxItem
= true;
289 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_ERROR
);
291 data
->sPathColumnText
= *strErr
;
293 data
->sPathColumnText
.Empty();
294 data
->color
= m_Colors
.GetColor(CColors::Modified
);
297 case git_wc_notify_sendmail_done
:
299 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_DONE
);
300 data
->sPathColumnText
.Empty();
301 data
->color
= m_Colors
.GetColor(CColors::Modified
);
304 case git_wc_notify_sendmail_retry
:
305 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SENDMAIL_RETRY
);
306 data
->sPathColumnText
.Empty();
307 data
->color
= m_Colors
.GetColor(CColors::Modified
);
311 case git_wc_notify_resolved
:
312 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
315 case git_wc_notify_revert
:
316 data
->sActionColumnText
.LoadString(IDS_SVNACTION_REVERT
);
320 case svn_wc_notify_commit_added
:
321 data
->sActionColumnText
.LoadString(IDS_SVNACTION_ADDING
);
322 data
->color
= m_Colors
.GetColor(CColors::Added
);
324 case svn_wc_notify_copy
:
325 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COPY
);
327 case svn_wc_notify_commit_modified
:
328 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MODIFIED
);
329 data
->color
= m_Colors
.GetColor(CColors::Modified
);
331 case svn_wc_notify_delete
:
332 case svn_wc_notify_update_delete
:
333 data
->sActionColumnText
.LoadString(IDS_SVNACTION_DELETE
);
334 m_bMergesAddsDeletesOccurred
= true;
335 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
337 case svn_wc_notify_commit_deleted
:
338 data
->sActionColumnText
.LoadString(IDS_SVNACTION_DELETING
);
339 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
341 case svn_wc_notify_restore
:
342 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESTORE
);
345 case svn_wc_notify_update_replace
:
346 case svn_wc_notify_commit_replaced
:
347 data
->sActionColumnText
.LoadString(IDS_SVNACTION_REPLACED
);
348 data
->color
= m_Colors
.GetColor(CColors::Deleted
);
350 case svn_wc_notify_exists
:
351 if ((data
->content_state
== svn_wc_notify_state_conflicted
) || (data
->prop_state
== svn_wc_notify_state_conflicted
))
353 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
354 data
->bConflictedActionItem
= true;
356 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CONFLICTED
);
358 else if ((data
->content_state
== svn_wc_notify_state_merged
) || (data
->prop_state
== svn_wc_notify_state_merged
))
360 data
->color
= m_Colors
.GetColor(CColors::Merged
);
361 m_bMergesAddsDeletesOccurred
= true;
362 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGED
);
365 data
->sActionColumnText
.LoadString(IDS_SVNACTION_EXISTS
);
367 case svn_wc_notify_update_update
:
368 // if this is an inoperative dir change, don't show the notification.
369 // an inoperative dir change is when a directory gets updated without
370 // any real change in either text or properties.
371 if ((kind
== svn_node_dir
)
372 && ((prop_state
== svn_wc_notify_state_inapplicable
)
373 || (prop_state
== svn_wc_notify_state_unknown
)
374 || (prop_state
== svn_wc_notify_state_unchanged
)))
379 if ((data
->content_state
== svn_wc_notify_state_conflicted
) || (data
->prop_state
== svn_wc_notify_state_conflicted
))
381 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
382 data
->bConflictedActionItem
= true;
384 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CONFLICTED
);
386 else if ((data
->content_state
== svn_wc_notify_state_merged
) || (data
->prop_state
== svn_wc_notify_state_merged
))
388 data
->color
= m_Colors
.GetColor(CColors::Merged
);
389 m_bMergesAddsDeletesOccurred
= true;
390 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGED
);
392 else if (((data
->content_state
!= svn_wc_notify_state_unchanged
)&&(data
->content_state
!= svn_wc_notify_state_unknown
)) ||
393 ((data
->prop_state
!= svn_wc_notify_state_unchanged
)&&(data
->prop_state
!= svn_wc_notify_state_unknown
)))
395 data
->sActionColumnText
.LoadString(IDS_SVNACTION_UPDATE
);
402 if (lock_state
== svn_wc_notify_lock_state_unlocked
)
404 CString
temp(MAKEINTRESOURCE(IDS_SVNACTION_UNLOCKED
));
405 data
->sActionColumnText
+= _T(", ") + temp
;
409 case svn_wc_notify_update_external
:
410 // For some reason we build a list of externals...
411 m_ExtStack
.AddHead(path
.GetUIPathString());
412 data
->sActionColumnText
.LoadString(IDS_SVNACTION_EXTERNAL
);
413 data
->bAuxItem
= true;
416 case svn_wc_notify_update_completed
:
418 data
->sActionColumnText
.LoadString(IDS_SVNACTION_COMPLETED
);
419 data
->bAuxItem
= true;
420 bool bEmpty
= !!m_ExtStack
.IsEmpty();
422 data
->sPathColumnText
.Format(IDS_PROGRS_PATHATREV
, (LPCTSTR
)m_ExtStack
.RemoveHead(), rev
);
424 data
->sPathColumnText
.Format(IDS_PROGRS_ATREV
, rev
);
426 if ((m_nConflicts
>0)&&(bEmpty
))
428 // We're going to add another aux item - let's shove this current onto the list first
429 // I don't really like this, but it will do for the moment.
430 m_arData
.push_back(data
);
433 data
= new NotificationData();
434 data
->bAuxItem
= true;
435 data
->sActionColumnText
.LoadString(IDS_PROGRS_CONFLICTSOCCURED_WARNING
);
436 data
->sPathColumnText
.LoadString(IDS_PROGRS_CONFLICTSOCCURED
);
437 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
438 CSoundUtils::PlayTSVNWarning();
439 // This item will now be added after the switch statement
441 if (!m_basePath
.IsEmpty())
442 m_FinishedRevMap
[m_basePath
.GetSVNApiPath(pool
)] = rev
;
444 m_bFinishedItemAdded
= true;
447 case svn_wc_notify_commit_postfix_txdelta
:
448 data
->sActionColumnText
.LoadString(IDS_SVNACTION_POSTFIX
);
450 case svn_wc_notify_failed_revert
:
451 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDREVERT
);
453 case svn_wc_notify_status_completed
:
454 case svn_wc_notify_status_external
:
455 data
->sActionColumnText
.LoadString(IDS_SVNACTION_STATUS
);
457 case svn_wc_notify_skip
:
458 if ((content_state
== svn_wc_notify_state_missing
)||(content_state
== svn_wc_notify_state_obstructed
)||(content_state
== svn_wc_notify_state_conflicted
))
460 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SKIPMISSING
);
462 // The color settings dialog describes the red color with
463 // "possible or real conflict / obstructed" which also applies to
464 // skipped targets during a merge. So we just use the same color.
465 data
->color
= m_Colors
.GetColor(CColors::Conflict
);
468 data
->sActionColumnText
.LoadString(IDS_SVNACTION_SKIP
);
470 case svn_wc_notify_locked
:
471 if ((lock
)&&(lock
->owner
))
472 data
->sActionColumnText
.Format(IDS_SVNACTION_LOCKEDBY
, (LPCTSTR
)CUnicodeUtils::GetUnicode(lock
->owner
));
474 case svn_wc_notify_unlocked
:
475 data
->sActionColumnText
.LoadString(IDS_SVNACTION_UNLOCKED
);
477 case svn_wc_notify_failed_lock
:
478 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDLOCK
);
479 m_arData
.push_back(data
);
481 ReportError(SVN::GetErrorString(err
));
483 if (err
->apr_err
== SVN_ERR_FS_OUT_OF_DATE
)
484 m_bLockWarning
= true;
485 if (err
->apr_err
== SVN_ERR_FS_PATH_ALREADY_LOCKED
)
486 m_bLockExists
= true;
488 case svn_wc_notify_failed_unlock
:
489 data
->sActionColumnText
.LoadString(IDS_SVNACTION_FAILEDUNLOCK
);
490 m_arData
.push_back(data
);
492 ReportError(SVN::GetErrorString(err
));
494 if (err
->apr_err
== SVN_ERR_FS_OUT_OF_DATE
)
495 m_bLockWarning
= true;
497 case svn_wc_notify_changelist_set
:
498 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTSET
, (LPCTSTR
)data
->changelistname
);
500 case svn_wc_notify_changelist_clear
:
501 data
->sActionColumnText
.LoadString(IDS_SVNACTION_CHANGELISTCLEAR
);
503 case svn_wc_notify_changelist_moved
:
504 data
->sActionColumnText
.Format(IDS_SVNACTION_CHANGELISTMOVED
, (LPCTSTR
)data
->changelistname
);
506 case svn_wc_notify_foreign_merge_begin
:
507 case svn_wc_notify_merge_begin
:
509 data
->sActionColumnText
.LoadString(IDS_SVNACTION_MERGEBEGINNONE
);
510 else if ((data
->merge_range
.start
== data
->merge_range
.end
) || (data
->merge_range
.start
== data
->merge_range
.end
- 1))
511 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINSINGLE
, data
->merge_range
.end
);
512 else if (data
->merge_range
.start
- 1 == data
->merge_range
.end
)
513 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINSINGLEREVERSE
, data
->merge_range
.start
);
514 else if (data
->merge_range
.start
< data
->merge_range
.end
)
515 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINMULTIPLE
, data
->merge_range
.start
+ 1, data
->merge_range
.end
);
517 data
->sActionColumnText
.Format(IDS_SVNACTION_MERGEBEGINMULTIPLEREVERSE
, data
->merge_range
.start
, data
->merge_range
.end
+ 1);
518 data
->bAuxItem
= true;
523 } // switch (data->action)
531 m_arData
.push_back(data
);
533 if ((!data
->bAuxItem
) && (m_itemCount
> 0))
537 CProgressCtrl
* progControl
= (CProgressCtrl
*)GetDlgItem(IDC_PROGRESSBAR
);
538 progControl
->ShowWindow(SW_SHOW
);
539 progControl
->SetPos(m_itemCountTotal
- m_itemCount
);
540 progControl
->SetRange32(0, m_itemCountTotal
);
543 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
544 m_pTaskbarList
->SetProgressValue(m_hWnd
, m_itemCountTotal
-m_itemCount
, m_itemCountTotal
);
548 //if ((action == svn_wc_notify_commit_postfix_txdelta)&&(bSecondResized == FALSE))
551 // bSecondResized = TRUE;
559 CString
CGitProgressDlg::BuildInfoString()
562 if(this->m_Command
== GitProgress_Resolve
)
563 infotext
= _T("You need commit your change after resolve conflict");
580 for (size_t i
=0; i
<m_arData
.size(); ++i
)
582 const NotificationData
* dat
= m_arData
[i
];
585 case svn_wc_notify_add
:
586 case svn_wc_notify_update_add
:
587 case svn_wc_notify_commit_added
:
588 if (dat
->bConflictedActionItem
)
593 case svn_wc_notify_copy
:
596 case svn_wc_notify_delete
:
597 case svn_wc_notify_update_delete
:
598 case svn_wc_notify_commit_deleted
:
601 case svn_wc_notify_restore
:
604 case svn_wc_notify_revert
:
607 case svn_wc_notify_resolved
:
610 case svn_wc_notify_update_update
:
611 if (dat
->bConflictedActionItem
)
613 else if ((dat
->content_state
== svn_wc_notify_state_merged
) || (dat
->prop_state
== svn_wc_notify_state_merged
))
618 case svn_wc_notify_commit_modified
:
621 case svn_wc_notify_skip
:
624 case svn_wc_notify_commit_replaced
:
631 temp
.LoadString(IDS_SVNACTION_CONFLICTED
);
633 temp
.Format(_T(":%d "), conflicted
);
638 temp
.LoadString(IDS_SVNACTION_SKIP
);
640 infotext
.AppendFormat(_T(":%d "), skipped
);
644 temp
.LoadString(IDS_SVNACTION_MERGED
);
646 infotext
.AppendFormat(_T(":%d "), merged
);
650 temp
.LoadString(IDS_SVNACTION_ADD
);
652 infotext
.AppendFormat(_T(":%d "), added
);
656 temp
.LoadString(IDS_SVNACTION_DELETE
);
658 infotext
.AppendFormat(_T(":%d "), deleted
);
662 temp
.LoadString(IDS_SVNACTION_MODIFIED
);
664 infotext
.AppendFormat(_T(":%d "), modified
);
668 temp
.LoadString(IDS_SVNACTION_COPY
);
670 infotext
.AppendFormat(_T(":%d "), copied
);
674 temp
.LoadString(IDS_SVNACTION_REPLACED
);
676 infotext
.AppendFormat(_T(":%d "), replaced
);
680 temp
.LoadString(IDS_SVNACTION_UPDATE
);
682 infotext
.AppendFormat(_T(":%d "), updated
);
686 temp
.LoadString(IDS_SVNACTION_RESTORE
);
688 infotext
.AppendFormat(_T(":%d "), restored
);
692 temp
.LoadString(IDS_SVNACTION_REVERT
);
694 infotext
.AppendFormat(_T(":%d "), reverted
);
698 temp
.LoadString(IDS_SVNACTION_RESOLVE
);
700 infotext
.AppendFormat(_T(":%d "), resolved
);
706 void CGitProgressDlg::SetSelectedList(const CTGitPathList
& selPaths
)
708 m_selectedPaths
= selPaths
;
711 void CGitProgressDlg::ResizeColumns()
713 m_ProgList
.SetRedraw(FALSE
);
715 TCHAR textbuf
[MAX_PATH
];
717 int maxcol
= ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItemCount()-1;
718 for (int col
= 0; col
<= maxcol
; col
++)
720 // find the longest width of all items
721 int count
= m_ProgList
.GetItemCount();
724 hdi
.pszText
= textbuf
;
725 hdi
.cchTextMax
= sizeof(textbuf
);
726 ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItem(col
, &hdi
);
727 int cx
= m_ProgList
.GetStringWidth(hdi
.pszText
)+20; // 20 pixels for col separator and margin
729 for (int index
= 0; index
<count
; ++index
)
731 // get the width of the string and add 12 pixels for the column separator and margins
736 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sActionColumnText
) + 12;
739 linewidth
= m_ProgList
.GetStringWidth(m_arData
[index
]->sPathColumnText
) + 12;
745 m_ProgList
.SetColumnWidth(col
, cx
);
748 m_ProgList
.SetRedraw(TRUE
);
751 BOOL
CGitProgressDlg::OnInitDialog()
753 __super::OnInitDialog();
755 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
756 // do this, Explorer would be unable to send that message to our window if we
757 // were running elevated. It's OK to make the call all the time, since if we're
758 // not elevated, this is a no-op.
759 CHANGEFILTERSTRUCT cfs
= { sizeof(CHANGEFILTERSTRUCT
) };
760 typedef BOOL STDAPICALLTYPE
ChangeWindowMessageFilterExDFN(HWND hWnd
, UINT message
, DWORD action
, PCHANGEFILTERSTRUCT pChangeFilterStruct
);
761 CAutoLibrary hUser
= AtlLoadSystemLibraryUsingFullPath(_T("user32.dll"));
764 ChangeWindowMessageFilterExDFN
*pfnChangeWindowMessageFilterEx
= (ChangeWindowMessageFilterExDFN
*)GetProcAddress(hUser
, "ChangeWindowMessageFilterEx");
765 if (pfnChangeWindowMessageFilterEx
)
767 pfnChangeWindowMessageFilterEx(m_hWnd
, WM_TASKBARBTNCREATED
, MSGFLT_ALLOW
, &cfs
);
770 m_pTaskbarList
.Release();
771 if (FAILED(m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
)))
772 m_pTaskbarList
= nullptr;
774 m_ProgList
.SetExtendedStyle (LVS_EX_FULLROWSELECT
| LVS_EX_DOUBLEBUFFER
);
776 m_ProgList
.DeleteAllItems();
777 int c
= ((CHeaderCtrl
*)(m_ProgList
.GetDlgItem(0)))->GetItemCount()-1;
779 m_ProgList
.DeleteColumn(c
--);
781 temp
.LoadString(IDS_PROGRS_ACTION
);
782 m_ProgList
.InsertColumn(0, temp
);
783 temp
.LoadString(IDS_PROGRS_PATH
);
784 m_ProgList
.InsertColumn(1, temp
);
786 m_pThread
= AfxBeginThread(ProgressThreadEntry
, this, THREAD_PRIORITY_NORMAL
,0,CREATE_SUSPENDED
);
789 ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED
)));
793 m_pThread
->m_bAutoDelete
= FALSE
;
794 m_pThread
->ResumeThread();
799 // Call this early so that the column headings aren't hidden before any
803 SetTimer(VISIBLETIMER
, 300, NULL
);
805 AddAnchor(IDC_SVNPROGRESS
, TOP_LEFT
, BOTTOM_RIGHT
);
806 AddAnchor(IDC_PROGRESSLABEL
, BOTTOM_LEFT
, BOTTOM_CENTER
);
807 AddAnchor(IDC_PROGRESSBAR
, BOTTOM_CENTER
, BOTTOM_RIGHT
);
808 AddAnchor(IDC_INFOTEXT
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
809 AddAnchor(IDC_NONINTERACTIVE
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
810 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
811 AddAnchor(IDOK
, BOTTOM_RIGHT
);
812 AddAnchor(IDC_LOGBUTTON
, BOTTOM_RIGHT
);
813 //SetPromptParentWindow(this->m_hWnd);
815 CenterWindow(CWnd::FromHandle(hWndExplorer
));
816 EnableSaveRestore(_T("GITProgressDlg"));
820 bool CGitProgressDlg::SetBackgroundImage(UINT nID
)
822 return CAppUtils::SetListCtrlBackgroundImage(m_ProgList
.GetSafeHwnd(), nID
);
825 void CGitProgressDlg::ReportGitError()
827 ReportError(CString(giterr_last()->message
));
830 void CGitProgressDlg::ReportError(const CString
& sError
)
832 CSoundUtils::PlayTGitError();
833 ReportString(sError
, CString(MAKEINTRESOURCE(IDS_ERR_ERROR
)), m_Colors
.GetColor(CColors::Conflict
));
834 m_bErrorsOccurred
= true;
837 void CGitProgressDlg::ReportWarning(const CString
& sWarning
)
839 CSoundUtils::PlayTGitWarning();
840 ReportString(sWarning
, CString(MAKEINTRESOURCE(IDS_WARN_WARNING
)), m_Colors
.GetColor(CColors::Conflict
));
843 void CGitProgressDlg::ReportNotification(const CString
& sNotification
)
845 CSoundUtils::PlayTGitNotification();
846 ReportString(sNotification
, CString(MAKEINTRESOURCE(IDS_WARN_NOTE
)));
849 void CGitProgressDlg::ReportCmd(const CString
& sCmd
)
851 ReportString(sCmd
, CString(MAKEINTRESOURCE(IDS_PROGRS_CMDINFO
)), m_Colors
.GetColor(CColors::Cmd
));
854 void CGitProgressDlg::ReportString(CString sMessage
, const CString
& sMsgKind
, COLORREF color
)
856 // instead of showing a dialog box with the error message or notification,
857 // just insert the error text into the list control.
858 // that way the user isn't 'interrupted' by a dialog box popping up!
860 // the message may be split up into different lines
861 // so add a new entry for each line of the message
862 while (!sMessage
.IsEmpty())
864 NotificationData
* data
= new NotificationData();
865 data
->bAuxItem
= true;
866 data
->sActionColumnText
= sMsgKind
;
867 if (sMessage
.Find('\n')>=0)
868 data
->sPathColumnText
= sMessage
.Left(sMessage
.Find('\n'));
870 data
->sPathColumnText
= sMessage
;
871 data
->sPathColumnText
.Trim(_T("\n\r"));
873 if (sMessage
.Find('\n')>=0)
875 sMessage
= sMessage
.Mid(sMessage
.Find('\n'));
876 sMessage
.Trim(_T("\n\r"));
880 m_arData
.push_back(data
);
885 UINT
CGitProgressDlg::ProgressThreadEntry(LPVOID pVoid
)
887 return ((CGitProgressDlg
*)pVoid
)->ProgressThread();
890 UINT
CGitProgressDlg::ProgressThread()
892 // The SetParams function should have loaded something for us
895 CString sWindowTitle
;
896 bool localoperation
= false;
897 bool bSuccess
= false;
898 m_AlwaysConflicted
= false;
900 DialogEnableWindow(IDOK
, FALSE
);
901 DialogEnableWindow(IDCANCEL
, TRUE
);
902 // SetAndClearProgressInfo(m_hWnd);
903 m_itemCount
= m_itemCountTotal
;
905 InterlockedExchange(&m_bThreadRunning
, TRUE
);
907 bSecondResized
= FALSE
;
908 m_bFinishedItemAdded
= false;
909 CTime startTime
= CTime::GetCurrentTime();
912 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_INDETERMINATE
);
916 case GitProgress_Add
:
917 bSuccess
= CmdAdd(sWindowTitle
, localoperation
);
919 case GitProgress_Copy
:
920 bSuccess
= CmdCopy(sWindowTitle
, localoperation
);
922 case GitProgress_Export
:
923 bSuccess
= CmdExport(sWindowTitle
, localoperation
);
925 case GitProgress_Rename
:
926 bSuccess
= CmdRename(sWindowTitle
, localoperation
);
928 case GitProgress_Resolve
:
929 bSuccess
= CmdResolve(sWindowTitle
, localoperation
);
931 case GitProgress_Revert
:
932 bSuccess
= CmdRevert(sWindowTitle
, localoperation
);
934 case GitProgress_Switch
:
935 bSuccess
= CmdSwitch(sWindowTitle
, localoperation
);
937 case GitProgress_SendMail
:
938 bSuccess
= CmdSendMail(sWindowTitle
, localoperation
);
942 temp
.LoadString(IDS_PROGRS_TITLEFAILED
);
944 temp
.LoadString(IDS_PROGRS_TITLEFIN
);
945 sWindowTitle
= sWindowTitle
+ _T(" ") + temp
;
946 SetWindowText(sWindowTitle
);
948 KillTimer(TRANSFERTIMER
);
949 KillTimer(VISIBLETIMER
);
953 if (DidErrorsOccur())
955 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
956 m_pTaskbarList
->SetProgressValue(m_hWnd
, 100, 100);
959 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NOPROGRESS
);
962 DialogEnableWindow(IDCANCEL
, FALSE
);
963 DialogEnableWindow(IDOK
, TRUE
);
965 CString info
= BuildInfoString();
967 info
.LoadString(IDS_PROGRS_INFOFAILED
);
968 SetDlgItemText(IDC_INFOTEXT
, info
);
970 CWnd
* pWndOk
= GetDlgItem(IDOK
);
971 if (pWndOk
&& ::IsWindow(pWndOk
->GetSafeHwnd()))
973 SendMessage(DM_SETDEFID
, IDOK
);
974 GetDlgItem(IDOK
)->SetFocus();
978 if (!m_sTotalBytesTransferred
.IsEmpty())
980 CTimeSpan time
= CTime::GetCurrentTime() - startTime
;
981 temp
.Format(IDS_PROGRS_TIME
, (LONG
)time
.GetTotalMinutes(), (LONG
)time
.GetSeconds());
982 sFinalInfo
.Format(IDS_PROGRS_FINALINFO
, m_sTotalBytesTransferred
, (LPCTSTR
)temp
);
983 SetDlgItemText(IDC_PROGRESSLABEL
, sFinalInfo
);
986 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_HIDE
);
988 GetDlgItem(IDC_PROGRESSBAR
)->ShowWindow(SW_HIDE
);
990 if (!m_bFinishedItemAdded
)
992 // there's no "finished: xxx" line at the end. We add one here to make
993 // sure the user sees that the command is actually finished.
994 NotificationData
* data
= new NotificationData();
995 data
->bAuxItem
= true;
996 data
->sActionColumnText
.LoadString(IDS_PROGRS_FINISHED
);
997 m_arData
.push_back(data
);
1001 int count
= m_ProgList
.GetItemCount();
1002 if ((count
> 0)&&(m_bLastVisible
))
1003 m_ProgList
.EnsureVisible(count
-1, FALSE
);
1008 logfile
.AddTimeLine();
1009 for (size_t i
=0; i
<m_arData
.size(); i
++)
1011 NotificationData
* data
= m_arData
[i
];
1012 temp
.Format(_T("%-20s : %s"), (LPCTSTR
)data
->sActionColumnText
, (LPCTSTR
)data
->sPathColumnText
);
1013 logfile
.AddLine(temp
);
1015 if (!sFinalInfo
.IsEmpty())
1016 logfile
.AddLine(sFinalInfo
);
1020 m_bCancelled
= TRUE
;
1021 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1025 DWORD dwAutoClose
= CRegStdDWORD(_T("Software\\TortoiseGit\\AutoClose"), CLOSE_MANUAL
);
1026 if (m_options
& ProgOptDryRun
)
1027 dwAutoClose
= 0; // dry run means progress dialog doesn't auto close at all
1028 if (!m_bLastVisible
)
1030 if (m_dwCloseOnEnd
!= (DWORD
)-1)
1031 dwAutoClose
= m_dwCloseOnEnd
; // command line value has priority over setting value
1032 if ((dwAutoClose
== CLOSE_NOERRORS
)&&(!m_bErrorsOccurred
))
1033 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1034 if ((dwAutoClose
== CLOSE_NOCONFLICTS
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0))
1035 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1036 if ((dwAutoClose
== CLOSE_NOMERGES
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(!m_bMergesAddsDeletesOccurred
))
1037 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1038 if ((dwAutoClose
== CLOSE_LOCAL
)&&(!m_bErrorsOccurred
)&&(m_nConflicts
==0)&&(localoperation
))
1039 PostMessage(WM_COMMAND
, 1, (LPARAM
)GetDlgItem(IDOK
)->m_hWnd
);
1042 //Don't do anything here which might cause messages to be sent to the window
1043 //The window thread is probably now blocked in OnOK if we've done an auto close
1047 void CGitProgressDlg::OnBnClickedLogbutton()
1049 switch(this->m_Command
)
1051 case GitProgress_Add
:
1052 case GitProgress_Resolve
:
1054 CString cmd
= _T(" /command:commit");
1055 cmd
+= _T(" /path:\"")+g_Git
.m_CurrentDir
+_T("\"");
1057 CAppUtils::RunTortoiseGitProc(cmd
);
1058 this->EndDialog(IDOK
);
1063 if (m_targetPathList
.GetCount() != 1)
1065 StringRevMap::iterator it
= m_UpdateStartRevMap
.begin();
1066 svn_revnum_t rev
= -1;
1067 if (it
!= m_UpdateStartRevMap
.end())
1072 dlg
.SetParams(m_targetPathList
[0], m_RevisionEnd
, m_RevisionEnd
, rev
, 0, TRUE
);
1078 void CGitProgressDlg::OnClose()
1082 TerminateThread(m_pThread
->m_hThread
, (DWORD
)-1);
1083 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1087 m_bCancelled
= TRUE
;
1090 DialogEnableWindow(IDCANCEL
, TRUE
);
1094 void CGitProgressDlg::OnOK()
1096 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1098 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish
1099 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you
1100 // don't do any more operations on the window which might require message passing
1101 // If you try to send windows messages once we're waiting here, then the thread can't finished
1102 // because the Window's message loop is blocked at this wait
1103 WaitForSingleObject(m_pThread
->m_hThread
, 10000);
1106 m_bCancelled
= TRUE
;
1109 void CGitProgressDlg::OnCancel()
1111 if ((m_bCancelled
)&&(!m_bThreadRunning
))
1112 __super::OnCancel();
1113 m_bCancelled
= TRUE
;
1116 void CGitProgressDlg::OnLvnGetdispinfoSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1118 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1122 if (pDispInfo
->item
.mask
& LVIF_TEXT
)
1124 if (pDispInfo
->item
.iItem
< (int)m_arData
.size())
1126 const NotificationData
* data
= m_arData
[pDispInfo
->item
.iItem
];
1127 switch (pDispInfo
->item
.iSubItem
)
1130 lstrcpyn(m_columnbuf
, data
->sActionColumnText
, MAX_PATH
);
1133 lstrcpyn(m_columnbuf
, data
->sPathColumnText
, pDispInfo
->item
.cchTextMax
);
1134 if (!data
->bAuxItem
)
1136 int cWidth
= m_ProgList
.GetColumnWidth(1);
1137 cWidth
= max(12, cWidth
-12);
1138 CDC
* pDC
= m_ProgList
.GetDC();
1141 CFont
* pFont
= pDC
->SelectObject(m_ProgList
.GetFont());
1142 PathCompactPath(pDC
->GetSafeHdc(), m_columnbuf
, cWidth
);
1143 pDC
->SelectObject(pFont
);
1151 pDispInfo
->item
.pszText
= m_columnbuf
;
1158 void CGitProgressDlg::OnNMCustomdrawSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1160 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1162 // Take the default processing unless we set this to something else below.
1163 *pResult
= CDRF_DODEFAULT
;
1165 // First thing - check the draw stage. If it's the control's prepaint
1166 // stage, then tell Windows we want messages for every item.
1168 if ( CDDS_PREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1170 *pResult
= CDRF_NOTIFYITEMDRAW
;
1172 else if ( CDDS_ITEMPREPAINT
== pLVCD
->nmcd
.dwDrawStage
)
1174 // This is the prepaint stage for an item. Here's where we set the
1175 // item's text color. Our return value will tell Windows to draw the
1176 // item itself, but it will use the new color we set here.
1178 // Tell Windows to paint the control itself.
1179 *pResult
= CDRF_DODEFAULT
;
1181 ASSERT(pLVCD
->nmcd
.dwItemSpec
< m_arData
.size());
1182 if(pLVCD
->nmcd
.dwItemSpec
>= m_arData
.size())
1186 const NotificationData
* data
= m_arData
[pLVCD
->nmcd
.dwItemSpec
];
1187 ASSERT(data
!= NULL
);
1191 // Store the color back in the NMLVCUSTOMDRAW struct.
1192 pLVCD
->clrText
= data
->color
;
1196 void CGitProgressDlg::OnNMDblclkSvnprogress(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
1199 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1201 if (pNMLV
->iItem
< 0)
1203 if (m_options
& ProgOptDryRun
)
1204 return; //don't do anything in a dry-run.
1206 const NotificationData
* data
= m_arData
[pNMLV
->iItem
];
1210 if (data
->bConflictedActionItem
)
1212 // We've double-clicked on a conflicted item - do a three-way merge on it
1213 SVNDiff::StartConflictEditor(data
->path
);
1215 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
))
1217 // This is a modified file which has been merged on update. Diff it against base
1218 CTGitPath temporaryFile
;
1219 SVNDiff
diff(this, this->m_hWnd
, true);
1220 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
1221 svn_revnum_t baseRev
= 0;
1222 diff
.DiffFileAgainstBase(data
->path
, baseRev
);
1224 else if ((!data
->bAuxItem
)&&(data
->path
.Exists())&&(!data
->path
.IsDirectory()))
1226 bool bOpenWith
= false;
1227 int ret
= (int)ShellExecute(m_hWnd
, NULL
, data
->path
.GetWinPath(), NULL
, NULL
, SW_SHOWNORMAL
);
1228 if (ret
<= HINSTANCE_ERROR
)
1232 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1233 cmd
+= data
->path
.GetWinPathString() + _T(" ");
1234 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1240 void CGitProgressDlg::OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1242 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1243 if (m_bThreadRunning
)
1245 if (m_nSortedColumn
== phdr
->iItem
)
1246 m_bAscending
= !m_bAscending
;
1248 m_bAscending
= TRUE
;
1249 m_nSortedColumn
= phdr
->iItem
;
1253 m_ProgList
.SetRedraw(FALSE
);
1254 m_ProgList
.DeleteAllItems();
1255 m_ProgList
.SetItemCountEx (static_cast<int>(m_arData
.size()));
1257 m_ProgList
.SetRedraw(TRUE
);
1262 bool CGitProgressDlg::NotificationDataIsAux(const NotificationData
* pData
)
1264 return pData
->bAuxItem
;
1267 LRESULT
CGitProgressDlg::OnGitProgress(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1270 SVNProgress
* pProgressData
= (SVNProgress
*)lParam
;
1271 CProgressCtrl
* progControl
= (CProgressCtrl
*)GetDlgItem(IDC_PROGRESSBAR
);
1272 if ((pProgressData
->total
> 1000)&&(!progControl
->IsWindowVisible()))
1274 progControl
->ShowWindow(SW_SHOW
);
1276 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
1278 if (((pProgressData
->total
< 0)&&(pProgressData
->progress
> 1000)&&(progControl
->IsWindowVisible()))&&(m_itemCountTotal
<0))
1280 progControl
->ShowWindow(SW_HIDE
);
1282 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_INDETERMINATE
);
1284 if (!GetDlgItem(IDC_PROGRESSLABEL
)->IsWindowVisible())
1285 GetDlgItem(IDC_PROGRESSLABEL
)->ShowWindow(SW_SHOW
);
1286 SetTimer(TRANSFERTIMER
, 2000, NULL
);
1287 if ((pProgressData
->total
> 0)&&(pProgressData
->progress
> 1000))
1289 progControl
->SetPos((int)pProgressData
->progress
);
1290 progControl
->SetRange32(0, (int)pProgressData
->total
);
1293 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
1294 m_pTaskbarList
->SetProgressValue(m_hWnd
, pProgressData
->progress
, pProgressData
->total
);
1298 if (pProgressData
->overall_total
< 1024)
1299 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALBYTESTRANSFERRED
, pProgressData
->overall_total
);
1300 else if (pProgressData
->overall_total
< 1200000)
1301 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALTRANSFERRED
, pProgressData
->overall_total
/ 1024);
1303 m_sTotalBytesTransferred
.Format(IDS_SVN_PROGRESS_TOTALMBTRANSFERRED
, (double)((double)pProgressData
->overall_total
/ 1024000.0));
1304 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)pProgressData
->SpeedString
);
1305 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1310 void CGitProgressDlg::OnTimer(UINT_PTR nIDEvent
)
1312 if (nIDEvent
== TRANSFERTIMER
)
1316 progSpeed
.Format(IDS_SVN_PROGRESS_BYTES_SEC
, 0);
1317 progText
.Format(IDS_SVN_PROGRESS_TOTALANDSPEED
, (LPCTSTR
)m_sTotalBytesTransferred
, (LPCTSTR
)progSpeed
);
1318 SetDlgItemText(IDC_PROGRESSLABEL
, progText
);
1319 KillTimer(TRANSFERTIMER
);
1321 if (nIDEvent
== VISIBLETIMER
)
1323 if (nEnsureVisibleCount
)
1324 m_ProgList
.EnsureVisible(m_ProgList
.GetItemCount()-1, false);
1325 nEnsureVisibleCount
= 0;
1329 void CGitProgressDlg::Sort()
1331 if(m_arData
.size() < 2)
1336 // We need to sort the blocks which lie between the auxiliary entries
1337 // This is so that any aux data stays where it was
1338 NotificationDataVect::iterator actionBlockBegin
;
1339 NotificationDataVect::iterator actionBlockEnd
= m_arData
.begin(); // We start searching from here
1343 // Search to the start of the non-aux entry in the next block
1344 actionBlockBegin
= std::find_if(actionBlockEnd
, m_arData
.end(), std::not1(std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
)));
1345 if(actionBlockBegin
== m_arData
.end())
1347 // There are no more actions
1350 // Now search to find the end of the block
1351 actionBlockEnd
= std::find_if(actionBlockBegin
+1, m_arData
.end(), std::ptr_fun(&CGitProgressDlg::NotificationDataIsAux
));
1352 // Now sort the block
1353 std::sort(actionBlockBegin
, actionBlockEnd
, &CGitProgressDlg::SortCompare
);
1357 bool CGitProgressDlg::SortCompare(const NotificationData
* pData1
, const NotificationData
* pData2
)
1360 switch (m_nSortedColumn
)
1362 case 0: //action column
1363 result
= pData1
->sActionColumnText
.Compare(pData2
->sActionColumnText
);
1365 case 1: //path column
1366 // Compare happens after switch()
1372 // Sort by path if everything else is equal
1375 result
= CTGitPath::Compare(pData1
->path
, pData2
->path
);
1383 BOOL
CGitProgressDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1385 if (!GetDlgItem(IDOK
)->IsWindowEnabled())
1387 // only show the wait cursor over the list control
1388 if ((pWnd
)&&(pWnd
== GetDlgItem(IDC_SVNPROGRESS
)))
1390 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1395 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1397 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1400 BOOL
CGitProgressDlg::PreTranslateMessage(MSG
* pMsg
)
1402 if (pMsg
->message
== WM_KEYDOWN
)
1404 if (pMsg
->wParam
== VK_ESCAPE
)
1406 // pressing the ESC key should close the dialog. But since we disabled the escape
1407 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
1409 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
1410 // the impression that the OK button was pressed.
1411 if ((!m_bThreadRunning
)&&(!GetDlgItem(IDCANCEL
)->IsWindowEnabled())
1412 &&(GetDlgItem(IDOK
)->IsWindowEnabled())&&(GetDlgItem(IDOK
)->IsWindowVisible()))
1414 // since we convert ESC to RETURN, make sure the OK button has the focus.
1415 GetDlgItem(IDOK
)->SetFocus();
1416 pMsg
->wParam
= VK_RETURN
;
1419 if (pMsg
->wParam
== 'A')
1421 if (GetKeyState(VK_CONTROL
)&0x8000)
1423 // Ctrl-A -> select all
1424 m_ProgList
.SetSelectionMark(0);
1425 for (int i
=0; i
<m_ProgList
.GetItemCount(); ++i
)
1427 m_ProgList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
1431 if ((pMsg
->wParam
== 'C')||(pMsg
->wParam
== VK_INSERT
))
1433 int selIndex
= m_ProgList
.GetSelectionMark();
1436 if (GetKeyState(VK_CONTROL
)&0x8000)
1438 //Ctrl-C -> copy to clipboard
1440 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1445 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1446 CString sAction
= m_ProgList
.GetItemText(nItem
, 0);
1447 CString sPath
= m_ProgList
.GetItemText(nItem
, 1);
1448 CString sMime
= m_ProgList
.GetItemText(nItem
, 2);
1449 CString sLogCopyText
;
1450 sLogCopyText
.Format(_T("%s: %s %s\r\n"),
1451 (LPCTSTR
)sAction
, (LPCTSTR
)sPath
, (LPCTSTR
)sMime
);
1452 sClipdata
+= sLogCopyText
;
1454 CStringUtils::WriteAsciiStringToClipboard(sClipdata
);
1459 } // if (pMsg->message == WM_KEYDOWN)
1460 return __super::PreTranslateMessage(pMsg
);
1463 void CGitProgressDlg::OnContextMenu(CWnd
* /*pWnd*/, CPoint
/*point*/)
1466 if (m_options
& ProgOptDryRun
)
1467 return; // don't do anything in a dry-run.
1469 if (pWnd
== &m_ProgList
)
1471 int selIndex
= m_ProgList
.GetSelectionMark();
1472 if ((point
.x
== -1) && (point
.y
== -1))
1474 // Menu was invoked from the keyboard rather than by right-clicking
1476 m_ProgList
.GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1477 m_ProgList
.ClientToScreen(&rect
);
1478 point
= rect
.CenterPoint();
1481 if ((selIndex
>= 0)&&(!m_bThreadRunning
))
1483 // entry is selected, thread has finished with updating so show the popup menu
1485 if (popup
.CreatePopupMenu())
1487 bool bAdded
= false;
1488 NotificationData
* data
= m_arData
[selIndex
];
1489 if ((data
)&&(!data
->path
.IsDirectory()))
1491 if (data
->action
== svn_wc_notify_update_update
|| data
->action
== svn_wc_notify_resolved
)
1493 if (m_ProgList
.GetSelectedCount() == 1)
1495 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1499 if (data
->bConflictedActionItem
)
1501 if (m_ProgList
.GetSelectedCount() == 1)
1503 popup
.AppendMenuIcon(ID_EDITCONFLICT
, IDS_MENUCONFLICT
,IDI_CONFLICT
);
1504 popup
.SetDefaultItem(ID_EDITCONFLICT
, FALSE
);
1505 popup
.AppendMenuIcon(ID_CONFLICTRESOLVE
, IDS_SVNPROGRESS_MENUMARKASRESOLVED
,IDI_RESOLVE
);
1507 popup
.AppendMenuIcon(ID_CONFLICTUSETHEIRS
, IDS_SVNPROGRESS_MENUUSETHEIRS
,IDI_RESOLVE
);
1508 popup
.AppendMenuIcon(ID_CONFLICTUSEMINE
, IDS_SVNPROGRESS_MENUUSEMINE
,IDI_RESOLVE
);
1510 else if ((data
->content_state
== svn_wc_notify_state_merged
)||(GitProgress_Merge
== m_Command
)||(data
->action
== svn_wc_notify_resolved
))
1511 popup
.SetDefaultItem(ID_COMPARE
, FALSE
);
1513 if (m_ProgList
.GetSelectedCount() == 1)
1515 if ((data
->action
== svn_wc_notify_add
)||
1516 (data
->action
== svn_wc_notify_update_add
)||
1517 (data
->action
== svn_wc_notify_commit_added
)||
1518 (data
->action
== svn_wc_notify_commit_modified
)||
1519 (data
->action
== svn_wc_notify_restore
)||
1520 (data
->action
== svn_wc_notify_revert
)||
1521 (data
->action
== svn_wc_notify_resolved
)||
1522 (data
->action
== svn_wc_notify_commit_replaced
)||
1523 (data
->action
== svn_wc_notify_commit_modified
)||
1524 (data
->action
== svn_wc_notify_commit_postfix_txdelta
)||
1525 (data
->action
== svn_wc_notify_update_update
))
1527 popup
.AppendMenuIcon(ID_LOG
, IDS_MENULOG
,IDI_LOG
);
1528 if (data
->action
== svn_wc_notify_update_update
)
1529 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1530 popup
.AppendMenuIcon(ID_OPEN
, IDS_LOG_POPUP_OPEN
, IDI_OPEN
);
1531 popup
.AppendMenuIcon(ID_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
1535 } // if ((data)&&(!data->path.IsDirectory()))
1536 if (m_ProgList
.GetSelectedCount() == 1)
1540 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1541 if ((!sPath
.IsEmpty())&&(!SVN::PathIsURL(CTGitPath(sPath
))))
1543 CTGitPath path
= CTGitPath(sPath
);
1544 if (path
.GetDirectory().Exists())
1546 popup
.AppendMenuIcon(ID_EXPLORE
, IDS_SVNPROGRESS_MENUOPENPARENT
, IDI_EXPLORER
);
1552 if (m_ProgList
.GetSelectedCount() > 0)
1555 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1556 popup
.AppendMenuIcon(ID_COPY
, IDS_LOG_POPUP_COPYTOCLIPBOARD
,IDI_COPYCLIP
);
1561 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1562 DialogEnableWindow(IDOK
, FALSE
);
1563 this->SetPromptApp(&theApp
);
1564 theApp
.DoWaitCursor(1);
1565 bool bOpenWith
= false;
1571 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1574 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1575 NotificationData
* data
= m_arData
[nItem
];
1578 sLines
+= data
->sPathColumnText
;
1579 sLines
+= _T("\r\n");
1583 if (!sLines
.IsEmpty())
1585 CStringUtils::WriteAsciiStringToClipboard(sLines
, GetSafeHwnd());
1591 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1593 CTGitPath path
= CTGitPath(sPath
);
1594 ShellExecute(m_hWnd
, _T("explore"), path
.GetDirectory().GetWinPath(), NULL
, path
.GetDirectory().GetWinPath(), SW_SHOW
);
1599 svn_revnum_t rev
= -1;
1600 StringRevMap::iterator it
= m_UpdateStartRevMap
.end();
1601 if (data
->basepath
.IsEmpty())
1602 it
= m_UpdateStartRevMap
.begin();
1604 it
= m_UpdateStartRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1605 if (it
!= m_UpdateStartRevMap
.end())
1607 // if the file was merged during update, do a three way diff between OLD, MINE, THEIRS
1608 if (data
->content_state
== svn_wc_notify_state_merged
)
1610 CTGitPath basefile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1611 CTGitPath newfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_HEAD
);
1613 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, basefile
))
1615 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1616 DialogEnableWindow(IDOK
, TRUE
);
1619 // If necessary, convert the line-endings on the file before diffing
1620 if ((DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"), TRUE
))
1622 CTGitPath temporaryFile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, SVNRev::REV_BASE
);
1623 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_BASE
), SVNRev(SVNRev::REV_BASE
), temporaryFile
))
1625 temporaryFile
.Reset();
1630 newfile
= temporaryFile
;
1634 SetFileAttributes(newfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1635 SetFileAttributes(basefile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1636 CString revname
, wcname
, basename
;
1637 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1638 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1639 basename
.Format(IDS_DIFF_BASENAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1640 CAppUtils::StartExtMerge(basefile
, newfile
, data
->path
, data
->path
, basename
, revname
, wcname
, CString(), true);
1644 CTGitPath tempfile
= CTempFiles::Instance().GetTempFilePath(false, data
->path
, rev
);
1646 if (!svn
.Cat(data
->path
, SVNRev(SVNRev::REV_WC
), rev
, tempfile
))
1648 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1649 DialogEnableWindow(IDOK
, TRUE
);
1654 SetFileAttributes(tempfile
.GetWinPath(), FILE_ATTRIBUTE_READONLY
);
1655 CString revname
, wcname
;
1656 revname
.Format(_T("%s Revision %ld"), (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName(), rev
);
1657 wcname
.Format(IDS_DIFF_WCNAME
, (LPCTSTR
)data
->path
.GetUIFileOrDirectoryName());
1658 CAppUtils::StartExtDiff(
1659 tempfile
, data
->path
, revname
, wcname
,
1660 CAppUtils::DiffFlags().AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)));
1665 case ID_EDITCONFLICT
:
1667 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1668 SVNDiff::StartConflictEditor(CTGitPath(sPath
));
1671 case ID_CONFLICTUSETHEIRS
:
1672 case ID_CONFLICTUSEMINE
:
1673 case ID_CONFLICTRESOLVE
:
1675 svn_wc_conflict_choice_t result
= svn_wc_conflict_choose_merged
;
1678 case ID_CONFLICTUSETHEIRS
:
1679 result
= svn_wc_conflict_choose_theirs_full
;
1681 case ID_CONFLICTUSEMINE
:
1682 result
= svn_wc_conflict_choose_mine_full
;
1684 case ID_CONFLICTRESOLVE
:
1685 result
= svn_wc_conflict_choose_merged
;
1689 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1690 CString sResolvedPaths
;
1693 int nItem
= m_ProgList
.GetNextSelectedItem(pos
);
1694 NotificationData
* data
= m_arData
[nItem
];
1697 if (data
->bConflictedActionItem
)
1699 if (!svn
.Resolve(data
->path
, result
, FALSE
))
1701 CMessageBox::Show(m_hWnd
, svn
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
1702 DialogEnableWindow(IDOK
, TRUE
);
1707 data
->color
= ::GetSysColor(COLOR_WINDOWTEXT
);
1708 data
->action
= svn_wc_notify_resolved
;
1709 data
->sActionColumnText
.LoadString(IDS_SVNACTION_RESOLVE
);
1710 data
->bConflictedActionItem
= false;
1713 if (m_nConflicts
==0)
1715 // When the last conflict is resolved we remove
1716 // the warning which we assume is in the last line.
1717 int nIndex
= m_ProgList
.GetItemCount()-1;
1718 VERIFY(m_ProgList
.DeleteItem(nIndex
));
1720 delete m_arData
[nIndex
];
1721 m_arData
.pop_back();
1723 sResolvedPaths
+= data
->path
.GetWinPathString() + _T("\n");
1728 m_ProgList
.Invalidate();
1729 CString info
= BuildInfoString();
1730 SetDlgItemText(IDC_INFOTEXT
, info
);
1732 if (!sResolvedPaths
.IsEmpty())
1735 msg
.Format(IDS_SVNPROGRESS_RESOLVED
, (LPCTSTR
)sResolvedPaths
);
1736 CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseGit"), MB_OK
| MB_ICONINFORMATION
);
1742 svn_revnum_t rev
= m_RevisionEnd
;
1743 if (!data
->basepath
.IsEmpty())
1745 StringRevMap::iterator it
= m_FinishedRevMap
.find(data
->basepath
.GetSVNApiPath(pool
));
1746 if (it
!= m_FinishedRevMap
.end())
1750 // fetch the log from HEAD, not the revision we updated to:
1751 // the path might be inside an external folder which has its own
1753 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1754 dlg
.SetParams(CTGitPath(sPath
), SVNRev(), SVNRev::REV_HEAD
, 1, -1, TRUE
);
1763 CString sWinPath
= GetPathFromColumnText(data
->sPathColumnText
);
1765 ret
= (int)ShellExecute(this->m_hWnd
, NULL
, (LPCTSTR
)sWinPath
, NULL
, NULL
, SW_SHOWNORMAL
);
1766 if ((ret
<= HINSTANCE_ERROR
)||bOpenWith
)
1768 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
1769 cmd
+= sWinPath
+ _T(" ");
1770 CAppUtils::LaunchApplication(cmd
, NULL
, false);
1774 DialogEnableWindow(IDOK
, TRUE
);
1775 theApp
.DoWaitCursor(-1);
1783 void CGitProgressDlg::OnEnSetfocusInfotext()
1786 GetDlgItemText(IDC_INFOTEXT
, sTemp
);
1787 if (sTemp
.IsEmpty())
1788 GetDlgItem(IDC_INFOTEXT
)->HideCaret();
1791 void CGitProgressDlg::OnLvnBegindragSvnprogress(NMHDR
* , LRESULT
*pResult
)
1793 //LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1795 int selIndex
= m_ProgList
.GetSelectionMark();
1799 CDropFiles dropFiles
; // class for creating DROPFILES struct
1802 POSITION pos
= m_ProgList
.GetFirstSelectedItemPosition();
1803 while ( (index
= m_ProgList
.GetNextSelectedItem(pos
)) >= 0 )
1805 NotificationData
* data
= m_arData
[index
];
1807 if ( data
->kind
==svn_node_file
|| data
->kind
==svn_node_dir
)
1809 CString sPath
= GetPathFromColumnText(data
->sPathColumnText
);
1811 dropFiles
.AddFile( sPath
);
1815 if ( dropFiles
.GetCount()>0 )
1817 dropFiles
.CreateStructure();
1823 void CGitProgressDlg::OnSize(UINT nType
, int cx
, int cy
)
1825 CResizableStandAloneDialog::OnSize(nType
, cx
, cy
);
1826 if ((nType
== SIZE_RESTORED
)&&(m_bLastVisible
))
1828 if(!m_ProgList
.m_hWnd
)
1831 int count
= m_ProgList
.GetItemCount();
1833 m_ProgList
.EnsureVisible(count
-1, false);
1837 //////////////////////////////////////////////////////////////////////////
1839 //////////////////////////////////////////////////////////////////////////
1840 bool CGitProgressDlg::CmdAdd(CString
& sWindowTitle
, bool& localoperation
)
1842 localoperation
= true;
1843 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_ADD
);
1844 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
1845 SetBackgroundImage(IDI_ADD_BKG
);
1846 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_ADD
)));
1848 if (CRegDWORD(_T("Software\\TortoiseGit\\UseLibgit2"), TRUE
) == TRUE
)
1850 git_repository
*repo
= NULL
;
1853 CStringA gitdir
= CUnicodeUtils::GetMulti(CTGitPath(g_Git
.m_CurrentDir
).GetGitPathString(), CP_UTF8
);
1854 if (git_repository_open(&repo
, gitdir
.GetBuffer()))
1856 gitdir
.ReleaseBuffer();
1860 gitdir
.ReleaseBuffer();
1862 git_config
* config
;
1863 git_config_new(&config
);
1865 CStringA projectConfigA
= CUnicodeUtils::GetMulti(g_Git
.GetGitLocalConfig(), CP_UTF8
);
1866 if (git_config_add_file_ondisk(config
, projectConfigA
.GetBuffer(), 4, FALSE
))
1868 projectConfigA
.ReleaseBuffer();
1870 git_config_free(config
);
1871 git_repository_free(repo
);
1874 projectConfigA
.ReleaseBuffer();
1875 CString globalConfig
= g_Git
.GetGitGlobalConfig();
1876 if (PathFileExists(globalConfig
))
1878 CStringA globalConfigA
= CUnicodeUtils::GetMulti(globalConfig
, CP_UTF8
);
1879 if (git_config_add_file_ondisk(config
, globalConfigA
.GetBuffer(), 3, FALSE
))
1881 globalConfigA
.ReleaseBuffer();
1883 git_config_free(config
);
1884 git_repository_free(repo
);
1887 globalConfigA
.ReleaseBuffer();
1889 CString globalXDGConfig
= g_Git
.GetGitGlobalXDGConfig();
1890 if (PathFileExists(globalXDGConfig
))
1892 CStringA globalXDGConfigA
= CUnicodeUtils::GetMulti(globalXDGConfig
, CP_UTF8
);
1893 if (git_config_add_file_ondisk(config
, globalXDGConfigA
.GetBuffer(), 2, FALSE
))
1895 globalXDGConfigA
.ReleaseBuffer();
1897 git_config_free(config
);
1898 git_repository_free(repo
);
1901 globalXDGConfigA
.ReleaseBuffer();
1903 CString systemConfig
= g_Git
.GetGitSystemConfig();
1904 if (!systemConfig
.IsEmpty())
1906 CStringA systemConfigA
= CUnicodeUtils::GetMulti(systemConfig
, CP_UTF8
);
1907 if (git_config_add_file_ondisk(config
, systemConfigA
.GetBuffer(), 1, FALSE
))
1909 systemConfigA
.ReleaseBuffer();
1911 git_config_free(config
);
1912 git_repository_free(repo
);
1915 systemConfigA
.ReleaseBuffer();
1918 git_repository_set_config(repo
, config
);
1920 if (git_repository_index(&index
, repo
))
1923 git_repository_free(repo
);
1926 if (git_index_read(index
))
1929 git_index_free(index
);
1930 git_repository_free(repo
);
1934 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
1936 if (git_index_add_from_workdir(index
, CStringA(CUnicodeUtils::GetMulti(m_targetPathList
[i
].GetGitPathString(), CP_UTF8
)).GetBuffer()))
1939 git_index_free(index
);
1940 git_repository_free(repo
);
1943 Notify(m_targetPathList
[i
],git_wc_notify_add
);
1946 if (git_index_write(index
))
1949 git_index_free(index
);
1950 git_repository_free(repo
);
1954 git_index_free(index
);
1955 git_repository_free(repo
);
1959 CMassiveGitTask
mgt(L
"add -f");
1960 mgt
.ExecuteWithNotify(&m_targetPathList
, m_bCancelled
, git_wc_notify_add
, this, &CGitProgressDlg::Notify
);
1963 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
1965 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
1966 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
1970 bool CGitProgressDlg::CmdCopy(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
1973 ASSERT(m_targetPathList
.GetCount() == 1);
1974 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_COPY
);
1975 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
1976 SetBackgroundImage(IDI_COPY_BKG
);
1979 sCmdInfo
.Format(IDS_PROGRS_CMD_COPY
,
1980 m_targetPathList
[0].IsUrl() ? (LPCTSTR
)m_targetPathList
[0].GetSVNPathString() : m_targetPathList
[0].GetWinPath(),
1981 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1982 ReportCmd(sCmdInfo
);
1984 if (!Copy(m_targetPathList
, m_url
, m_Revision
, m_pegRev
, m_sMessage
))
1989 if (m_options
& ProgOptSwitchAfterCopy
)
1991 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
1992 m_targetPathList
[0].GetWinPath(),
1993 (LPCTSTR
)m_url
.GetSVNPathString(), (LPCTSTR
)m_Revision
.ToString());
1994 ReportCmd(sCmdInfo
);
1995 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, SVNRev::REV_HEAD
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
1997 if (!Switch(m_targetPathList
[0], m_url
, SVNRev::REV_HEAD
, m_Revision
, m_depth
, TRUE
, m_options
& ProgOptIgnoreExternals
))
2006 if (SVN::PathIsURL(m_url
))
2008 CString
sMsg(MAKEINTRESOURCE(IDS_PROGRS_COPY_WARNING
));
2009 ReportNotification(sMsg
);
2016 bool CGitProgressDlg::CmdExport(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2019 ASSERT(m_targetPathList
.GetCount() == 1);
2020 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_EXPORT
);
2021 sWindowTitle
= m_url
.GetUIFileOrDirectoryName()+_T(" - ")+sWindowTitle
;
2022 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2023 SetBackgroundImage(IDI_EXPORT_BKG
);
2025 if (m_options
& ProgOptEolCRLF
)
2027 if (m_options
& ProgOptEolLF
)
2029 if (m_options
& ProgOptEolCR
)
2031 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_EXPORT
)));
2032 if (!Export(m_url
, m_targetPathList
[0], m_Revision
, m_Revision
, TRUE
, m_options
& ProgOptIgnoreExternals
, m_depth
, NULL
, FALSE
, eol
))
2041 bool CGitProgressDlg::CmdRename(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2044 ASSERT(m_targetPathList
.GetCount() == 1);
2045 if ((!m_targetPathList
[0].IsUrl())&&(!m_url
.IsUrl()))
2046 localoperation
= true;
2047 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RENAME
);
2048 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2049 SetBackgroundImage(IDI_RENAME_BKG
);
2050 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RENAME
)));
2051 if (!Move(m_targetPathList
, m_url
, m_Revision
, m_sMessage
))
2060 bool CGitProgressDlg::CmdResolve(CString
& sWindowTitle
, bool& localoperation
)
2063 localoperation
= true;
2064 ASSERT(m_targetPathList
.GetCount() == 1);
2065 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_RESOLVE
);
2066 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2067 SetBackgroundImage(IDI_RESOLVE_BKG
);
2068 // check if the file may still have conflict markers in it.
2069 //BOOL bMarkers = FALSE;
2071 for(int i
=0;i
<m_targetPathList
.GetCount();i
++)
2073 CString cmd
,out
,tempmergefile
;
2074 cmd
.Format(_T("git.exe add -f -- \"%s\""),m_targetPathList
[i
].GetGitPathString());
2075 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2077 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2078 m_bErrorsOccurred
=true;
2082 CAppUtils::RemoveTempMergeFile((CTGitPath
&)m_targetPathList
[i
]);
2084 Notify(m_targetPathList
[i
],git_wc_notify_resolved
);
2087 if ((m_options
& ProgOptSkipConflictCheck
) == 0)
2091 for (INT_PTR fileindex
=0; (fileindex
<m_targetPathList
.GetCount()) && (bMarkers
==FALSE
); ++fileindex
)
2093 if (!m_targetPathList
[fileindex
].IsDirectory())
2095 CStdioFile
file(m_targetPathList
[fileindex
].GetWinPath(), CFile::typeBinary
| CFile::modeRead
);
2096 CString strLine
= _T("");
2097 while (file
.ReadString(strLine
))
2099 if (strLine
.Find(_T("<<<<<<<"))==0)
2109 catch (CFileException
* pE
)
2111 TRACE(_T("CFileException in Resolve!\n"));
2112 TCHAR error
[10000] = {0};
2113 pE
->GetErrorMessage(error
, 10000);
2121 if (CMessageBox::Show(m_hWnd
, IDS_PROGRS_REVERTMARKERS
, IDS_APPNAME
, MB_YESNO
| MB_ICONQUESTION
)==IDYES
)
2123 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
2124 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
2125 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
2130 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_RESOLVE
)));
2131 for (INT_PTR fileindex
=0; fileindex
<m_targetPathList
.GetCount(); ++fileindex
)
2132 Resolve(m_targetPathList
[fileindex
], svn_wc_conflict_choose_merged
, true);
2135 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList
);
2137 this->GetDlgItem(IDC_LOGBUTTON
)->SetWindowText(_T("Commit ..."));
2138 this->GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2143 bool CGitProgressDlg::CmdRevert(CString
& sWindowTitle
, bool& localoperation
)
2146 localoperation
= true;
2147 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_REVERT
);
2148 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2149 SetBackgroundImage(IDI_REVERT_BKG
);
2151 CTGitPathList delList
;
2152 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2156 path
.SetFromWin(g_Git
.m_CurrentDir
+_T("\\")+m_selectedPaths
[i
].GetWinPath());
2157 action
= m_selectedPaths
[i
].m_Action
;
2158 /* rename file can't delete because it needs original file*/
2159 if((!(action
& CTGitPath::LOGACTIONS_ADDED
)) &&
2160 (!(action
& CTGitPath::LOGACTIONS_REPLACED
)))
2161 delList
.AddPath(path
);
2163 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE
)))
2164 delList
.DeleteAllFiles(true);
2166 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_REVERT
)));
2167 for(int i
=0;i
<m_selectedPaths
.GetCount();i
++)
2169 if(g_Git
.Revert(_T("HEAD"), (CTGitPath
&)m_selectedPaths
[i
]))
2171 CMessageBox::Show(NULL
,_T("Revert Fail"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2172 m_bErrorsOccurred
=true;
2175 Notify(m_selectedPaths
[i
],git_wc_notify_revert
);
2178 CShellUpdater::Instance().AddPathsForUpdate(m_selectedPaths
);
2183 bool CGitProgressDlg::CmdSwitch(CString
& /*sWindowTitle*/, bool& /*localoperation*/)
2186 ASSERT(m_targetPathList
.GetCount() == 1);
2188 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SWITCH
);
2189 SetWindowText(sWindowTitle
); // needs to be updated, see TSVN rev. 21375
2190 SetBackgroundImage(IDI_SWITCH_BKG
);
2192 if (st
.GetStatus(m_targetPathList
[0]) != (-2))
2194 if (st
.status
->entry
!= NULL
)
2196 rev
= st
.status
->entry
->revision
;
2201 sCmdInfo
.Format(IDS_PROGRS_CMD_SWITCH
,
2202 m_targetPathList
[0].GetWinPath(), (LPCTSTR
)m_url
.GetSVNPathString(),
2203 (LPCTSTR
)m_Revision
.ToString());
2204 ReportCmd(sCmdInfo
);
2206 bool depthIsSticky
= true;
2207 if (m_depth
== svn_depth_unknown
)
2208 depthIsSticky
= false;
2209 if (!Switch(m_targetPathList
[0], m_url
, m_Revision
, m_Revision
, m_depth
, depthIsSticky
, m_options
& ProgOptIgnoreExternals
))
2214 m_UpdateStartRevMap
[m_targetPathList
[0].GetSVNApiPath(pool
)] = rev
;
2215 if ((m_RevisionEnd
>= 0)&&(rev
>= 0)
2216 &&((LONG
)m_RevisionEnd
> (LONG
)rev
))
2218 GetDlgItem(IDC_LOGBUTTON
)->ShowWindow(SW_SHOW
);
2224 void CGitProgressDlg::OnBnClickedNoninteractive()
2226 LRESULT res
= ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_GETCHECK
, 0, 0);
2227 m_AlwaysConflicted
= (res
== BST_CHECKED
);
2228 CRegDWORD nonint
= CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE
);
2229 nonint
= m_AlwaysConflicted
;
2232 CString
CGitProgressDlg::GetPathFromColumnText(const CString
& sColumnText
)
2234 CString sPath
= CPathUtils::ParsePathInString(sColumnText
);
2235 if (sPath
.Find(':')<0)
2237 // the path is not absolute: add the common root of all paths to it
2238 sPath
= m_targetPathList
.GetCommonRoot().GetDirectory().GetWinPathString() + _T("\\") + CPathUtils::ParsePathInString(sColumnText
);
2243 bool CGitProgressDlg::CmdSendMail(CString
& sWindowTitle
, bool& /*localoperation*/)
2245 sWindowTitle
.LoadString(IDS_PROGRS_TITLE_SENDMAIL
);
2246 CAppUtils::SetWindowTitle(m_hWnd
, m_targetPathList
.GetCommonRoot().GetUIPathString(), sWindowTitle
);
2247 //SetBackgroundImage(IDI_ADD_BKG);
2248 ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_SENDMAIL
)));
2250 if(this->m_SendMailFlags
&SENDMAIL_COMBINED
)
2254 Notify(path
,git_wc_notify_sendmail_start
);
2259 if(!!CPatch::SendPatchesCombined(m_targetPathList
,m_SendMailTO
,m_SendMailCC
,m_SendMailSubject
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
),&err
))
2261 Notify(path
,git_wc_notify_sendmail_error
,ret
,&err
);
2271 Notify(path
,git_wc_notify_sendmail_retry
,ret
,&err
);
2275 CString
str(_T("User Canceled"));
2276 Notify(path
,git_wc_notify_sendmail_error
,ret
,&str
);
2281 Notify(path
,git_wc_notify_sendmail_done
,ret
);
2285 for(int i
=0;ret
&& i
<m_targetPathList
.GetCount();i
++)
2288 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_start
);
2293 if(!!patch
.Send((CString
&)m_targetPathList
[i
].GetWinPathString(),this->m_SendMailTO
,
2294 this->m_SendMailCC
,!!(this->m_SendMailFlags
&SENDMAIL_ATTACHMENT
),!!(this->m_SendMailFlags
&SENDMAIL_MAPI
)))
2296 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&patch
.m_LastError
);
2307 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_retry
,ret
,&patch
.m_LastError
);
2311 CString
str(_T("User Canceled"));
2312 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_error
,ret
,&str
);
2317 Notify(m_targetPathList
[i
],git_wc_notify_sendmail_done
,ret
);
2323 LRESULT
CGitProgressDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2325 m_pTaskbarList
.Release();
2326 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);