3232 QObject ,
3333 SIGNAL )
3434
35+ from .commitsource import CommitSource
3536from .common import *
3637from .gitutils import *
3738from .logsfetcher import LogsFetcher
@@ -455,23 +456,55 @@ def nextResult(self):
455456
456457class CheckLocalChangesThread (QThread ):
457458
458- checkFinished = Signal (bool , bool )
459+ checkFinished = Signal (Commit , Commit )
459460
460- def __init__ (self , branch , parent = None ):
461+ def __init__ (self , branch , submodules , parent = None ):
461462 super ().__init__ (parent )
462463 self ._branch = branch
464+ self ._submodules = submodules or [None ]
463465
464466 def run (self ):
465467 if self .isInterruptionRequested ():
466468 return
467- hasLCC = Git .hasLocalChanges (self ._branch , True )
468469
469- if self .isInterruptionRequested ():
470- return
471- hasLUC = Git .hasLocalChanges (self ._branch )
470+ lccCommit = Commit ()
471+ lucCommit = Commit ()
472+
473+ for submodule in self ._submodules :
474+ if self .isInterruptionRequested ():
475+ return
476+ hasLCC , hasLUC = self .fetchLocalChanges (submodule )
477+ if hasLCC :
478+ lccCommit .sha1 = Git .LCC_SHA1
479+ if not lccCommit .repoDir :
480+ lccCommit .repoDir = submodule
481+ else :
482+ subCommit = Commit ()
483+ subCommit .sha1 = Git .LCC_SHA1
484+ subCommit .repoDir = submodule
485+ lccCommit .subCommits .append (subCommit )
486+
487+ if hasLUC :
488+ lucCommit .sha1 = Git .LUC_SHA1
489+ if not lucCommit .repoDir :
490+ lucCommit .repoDir = submodule
491+ else :
492+ subCommit = Commit ()
493+ subCommit .sha1 = Git .LUC_SHA1
494+ subCommit .repoDir = submodule
495+ lucCommit .subCommits .append (subCommit )
472496
473497 if not self .isInterruptionRequested ():
474- self .checkFinished .emit (hasLCC , hasLUC )
498+ self .checkFinished .emit (lccCommit , lucCommit )
499+
500+ def fetchLocalChanges (self , repoDir = None ):
501+ hasLCC = Git .hasLocalChanges (self ._branch , True , repoDir )
502+ if self .isInterruptionRequested ():
503+ return False , False
504+ hasLUC = Git .hasLocalChanges (self ._branch , repoDir = repoDir )
505+ if self .isInterruptionRequested ():
506+ return False , False
507+ return hasLCC , hasLUC
475508
476509
477510class LogGraph (QWidget ):
@@ -498,7 +531,7 @@ def paintEvent(self, event):
498531 painter .drawPixmap (0 , 0 , self ._graphImage )
499532
500533
501- class LogView (QAbstractScrollArea ):
534+ class LogView (QAbstractScrollArea , CommitSource ):
502535 currentIndexChanged = Signal (int )
503536 findFinished = Signal (int )
504537 findProgress = Signal (int )
@@ -638,24 +671,22 @@ def showLogs(self, branch, args=None):
638671 self .curBranch = branch
639672 self .args = args
640673
674+ submodules = []
641675 if qApp .settings ().isCompositeMode ():
642676 submodules = self .window ().submodules ()
643- self .fetcher .setSubmodules (submodules )
644- else :
645- self .fetcher .setSubmodules ([])
677+ self .fetcher .setSubmodules (submodules )
646678
647679 self .fetcher .fetch (branch , args )
648680 self .beginFetch .emit ()
649681
650- # TODO:
651682 if self .checkThread :
652683 self .checkThread .disconnect (self )
653684 self .checkThread .requestInterruption ()
654685 self .checkThread .wait ()
655686 self .checkThread = None
656687
657688 if not args :
658- self .checkThread = CheckLocalChangesThread (self .curBranch , self )
689+ self .checkThread = CheckLocalChangesThread (self .curBranch , submodules , self )
659690 self .checkThread .checkFinished .connect (self .__onCheckFinished )
660691 self .checkThread .start ()
661692
@@ -1028,47 +1059,46 @@ def __onFetchFinished(self, exitCode):
10281059 else :
10291060 self .viewport ().update ()
10301061
1031- def __onCheckFinished (self , hasLCC , hasLUC ):
1062+ def __onCheckFinished (self , lccCommit : Commit , lucCommit : Commit ):
10321063 parent_sha1 = self .data [0 ].sha1 if self .data else None
10331064
10341065 self .delayUpdateParents = False
1066+ hasLCC = lccCommit .isValid ()
1067+ hasLUC = lucCommit .isValid ()
1068+
10351069 if hasLCC :
1036- lcc_cmit = Commit ()
1037- lcc_cmit .sha1 = Git .LCC_SHA1
1038- lcc_cmit .comments = self .tr (
1070+ lccCommit .comments = self .tr (
10391071 "Local changes checked in to index but not committed" )
1040- lcc_cmit .parents = [parent_sha1 ] if parent_sha1 else []
1041- lcc_cmit .children = [Git .LUC_SHA1 ] if hasLUC else []
1072+ lccCommit .parents = [parent_sha1 ] if parent_sha1 else []
1073+ lccCommit .children = [Git .LUC_SHA1 ] if hasLUC else []
10421074
1043- self .data .insert (0 , lcc_cmit )
1044- parent_sha1 = lcc_cmit .sha1
1045- self .delayUpdateParents = len (lcc_cmit .parents ) == 0
1075+ self .data .insert (0 , lccCommit )
1076+ parent_sha1 = lccCommit .sha1
1077+ self .delayUpdateParents = len (lccCommit .parents ) == 0
10461078
10471079 if not self .delayUpdateParents :
10481080 if self .data [1 ].children is None :
10491081 self .data [1 ].children = []
10501082
1051- self .data [1 ].children .append (lcc_cmit .sha1 )
1083+ self .data [1 ].children .append (lccCommit .sha1 )
10521084
10531085 if self .curIdx > 0 :
10541086 self .curIdx += 1
10551087
10561088 if hasLUC :
1057- luc_cmit = Commit ()
1058- luc_cmit .sha1 = Git .LUC_SHA1
1059- luc_cmit .comments = self .tr (
1089+ lucCommit .comments = self .tr (
10601090 "Local uncommitted changes, not checked in to index" )
1061- luc_cmit .parents = [parent_sha1 ] if parent_sha1 else []
1062- luc_cmit .children = []
1091+ lucCommit .parents = [parent_sha1 ] if parent_sha1 else []
1092+ lucCommit .children = []
10631093
1064- self .data .insert (0 , luc_cmit )
1094+ self .data .insert (0 , lucCommit )
10651095 self .delayUpdateParents = self .delayUpdateParents or len (
1066- luc_cmit .parents ) == 0
1096+ lucCommit .parents ) == 0
10671097
10681098 if not self .delayUpdateParents and not hasLCC :
10691099 if self .data [1 ].children is None :
10701100 self .data [1 ].children = []
1071- self .data [1 ].children .append (luc_cmit .sha1 )
1101+ self .data [1 ].children .append (lucCommit .sha1 )
10721102
10731103 if self .curIdx > 0 :
10741104 self .curIdx += 1
0 commit comments