@@ -646,15 +646,16 @@ def determine_wants(
646646 if remote_refs [lh ] not in self .repo .object_store
647647 ]
648648
649- try :
649+ with reraise (
650+ Exception , SCMError (f"'{ url } ' is not a valid Git remote or URL" )
651+ ):
650652 _remote , location = get_remote_repo (self .repo , url )
651653 client , path = get_transport_and_path (location , ** kwargs )
652- except Exception as exc :
653- raise SCMError (
654- f"'{ url } ' is not a valid Git remote or URL"
655- ) from exc
656654
657- try :
655+ with reraise (
656+ (NotGitRepository , KeyError ),
657+ SCMError (f"Git failed to fetch ref from '{ url } '" ),
658+ ):
658659 fetch_result = client .fetch (
659660 path ,
660661 self .repo ,
@@ -663,37 +664,37 @@ def determine_wants(
663664 else None ,
664665 determine_wants = determine_wants ,
665666 )
666- except NotGitRepository as exc :
667- raise SCMError (f"Git failed to fetch ref from '{ url } '" ) from exc
668-
669- result = {}
670-
671- for (lh , rh , _ ) in fetch_refs :
672- refname = os .fsdecode (rh )
673- if rh in self .repo .refs :
674- if self .repo .refs [rh ] == fetch_result .refs [lh ]:
675- result [refname ] = SyncStatus .UP_TO_DATE
676- continue
677- try :
678- check_diverged (
679- self .repo , self .repo .refs [rh ], fetch_result .refs [lh ]
680- )
681- except DivergedBranches :
682- if not force :
683- overwrite = (
684- on_diverged (
685- os .fsdecode (rh ),
686- os .fsdecode (fetch_result .refs [lh ]),
687- )
688- if on_diverged
689- else False
667+
668+ result = {}
669+
670+ for (lh , rh , _ ) in fetch_refs :
671+ refname = os .fsdecode (rh )
672+ if rh in self .repo .refs :
673+ if self .repo .refs [rh ] == fetch_result .refs [lh ]:
674+ result [refname ] = SyncStatus .UP_TO_DATE
675+ continue
676+ try :
677+ check_diverged (
678+ self .repo ,
679+ self .repo .refs [rh ],
680+ fetch_result .refs [lh ],
690681 )
691- if not overwrite :
692- result [refname ] = SyncStatus .DIVERGED
693- continue
682+ except DivergedBranches :
683+ if not force :
684+ overwrite = (
685+ on_diverged (
686+ os .fsdecode (rh ),
687+ os .fsdecode (fetch_result .refs [lh ]),
688+ )
689+ if on_diverged
690+ else False
691+ )
692+ if not overwrite :
693+ result [refname ] = SyncStatus .DIVERGED
694+ continue
694695
695- self .repo .refs [rh ] = fetch_result .refs [lh ]
696- result [refname ] = SyncStatus .SUCCESS
696+ self .repo .refs [rh ] = fetch_result .refs [lh ]
697+ result [refname ] = SyncStatus .SUCCESS
697698 return result
698699
699700 def _stash_iter (self , ref : str ):
0 commit comments