@@ -473,106 +473,103 @@ def dirfilter(path):
473473 normalize = None
474474
475475 # step 2: query Watchman
476- with progress .spinner (self ._ui , "watchman query" ):
477- try :
478- # Use the user-configured timeout for the query.
479- # Add a little slack over the top of the user query to allow for
480- # overheads while transferring the data
481- excludes = ["anyof" , ["dirname" , ".hg" ], ["name" , ".hg" , "wholename" ]]
482- # Exclude submodules.
483- if git .isgitformat (self ._repo ):
484- submods = git .parsesubmodules (self ._repo [None ])
485- excludes += [["dirname" , s .path ] for s in submods ]
486- self ._watchmanclient .settimeout (state .timeout + 0.1 )
487- result = self ._watchmanclient .command (
488- "query" ,
489- {
490- "fields" : ["mode" , "mtime" , "size" , "exists" , "name" ],
491- "since" : clock ,
492- "expression" : ["not" , excludes ],
493- "sync_timeout" : int (state .timeout * 1000 ),
494- "empty_on_fresh_instance" : state .walk_on_invalidate ,
495- },
496- )
497- except Exception as ex :
498- event ["is_error" ] = True
499- span .record (error = ex )
500- _handleunavailable (self ._ui , state , ex )
501- self ._watchmanclient .clearconnection ()
502- # XXX: Legacy scuba logging. Remove this once the source of truth
503- # is moved to the Rust Event.
504- self ._ui .log ("fsmonitor_status" , fsmonitor_status = "exception" )
505- if self ._ui .configbool ("fsmonitor" , "fallback-on-watchman-exception" ):
506- raise fsmonitorfallback ("exception during run" )
507- else :
508- raise ex
476+ try :
477+ # Use the user-configured timeout for the query.
478+ # Add a little slack over the top of the user query to allow for
479+ # overheads while transferring the data
480+ excludes = ["anyof" , ["dirname" , ".hg" ], ["name" , ".hg" , "wholename" ]]
481+ # Exclude submodules.
482+ if git .isgitformat (self ._repo ):
483+ submods = git .parsesubmodules (self ._repo [None ])
484+ excludes += [["dirname" , s .path ] for s in submods ]
485+ self ._watchmanclient .settimeout (state .timeout + 0.1 )
486+ result = self ._watchmanclient .command (
487+ "query" ,
488+ {
489+ "fields" : ["mode" , "mtime" , "size" , "exists" , "name" ],
490+ "since" : clock ,
491+ "expression" : ["not" , excludes ],
492+ "sync_timeout" : int (state .timeout * 1000 ),
493+ "empty_on_fresh_instance" : state .walk_on_invalidate ,
494+ },
495+ )
496+ except Exception as ex :
497+ event ["is_error" ] = True
498+ span .record (error = ex )
499+ _handleunavailable (self ._ui , state , ex )
500+ self ._watchmanclient .clearconnection ()
501+ # XXX: Legacy scuba logging. Remove this once the source of truth
502+ # is moved to the Rust Event.
503+ self ._ui .log ("fsmonitor_status" , fsmonitor_status = "exception" )
504+ if self ._ui .configbool ("fsmonitor" , "fallback-on-watchman-exception" ):
505+ raise fsmonitorfallback ("exception during run" )
509506 else :
510- # We need to propagate the last observed clock up so that we
511- # can use it for our next query
512- event [ "new_clock" ] = result [ " clock" ]
513- event [ "is_fresh" ] = result [ "is_fresh_instance" ]
514- span . record ( newclock = result [ "clock" ], isfresh = result ["is_fresh_instance" ])
515- state . setlastclock ( result ["clock" ])
516- state . setlastisfresh ( result ["is_fresh_instance" ])
517-
518- files = list (
519- filter ( lambda x : _isutf8 ( self . _ui , x [ "name" ]), result [ "files" ])
520- )
521-
522- self ._ui .metrics .gauge ("watchmanfilecount" , len (files ))
523- # Ideally we'd just track a bool for fresh_instance or not, but there
524- # could be multiple queries during a command, so let's use a counter.
525- self ._ui .metrics .gauge (
526- "watchmanfreshinstances" ,
527- 1 if result ["is_fresh_instance" ] else 0 ,
528- )
507+ raise ex
508+ else :
509+ # We need to propagate the last observed clock up so that we
510+ # can use it for our next query
511+ event [ "new_clock" ] = result ["clock" ]
512+ event [ "is_fresh" ] = result ["is_fresh_instance" ]
513+ span . record ( newclock = result [ "clock" ], isfresh = result ["is_fresh_instance" ])
514+ state . setlastclock ( result [ "clock" ])
515+ state . setlastisfresh ( result [ "is_fresh_instance" ])
516+
517+ files = list ( filter ( lambda x : _isutf8 ( self . _ui , x [ "name" ]), result [ "files" ]) )
518+
519+ self ._ui .metrics .gauge ("watchmanfilecount" , len (files ))
520+ # Ideally we'd just track a bool for fresh_instance or not, but there
521+ # could be multiple queries during a command, so let's use a counter.
522+ self ._ui .metrics .gauge (
523+ "watchmanfreshinstances" ,
524+ 1 if result ["is_fresh_instance" ] else 0 ,
525+ )
529526
530- if result ["is_fresh_instance" ]:
531- if not self ._ui .plain () and self ._ui .configbool (
532- "fsmonitor" , "warn-fresh-instance"
533- ):
534- oldpid = _watchmanpid (event ["old_clock" ])
535- newpid = _watchmanpid (event ["new_clock" ])
536- if oldpid is not None and newpid is not None and oldpid != newpid :
537- self ._ui .warn (
538- _ (
539- "warning: watchman has recently restarted (old pid %s, new pid %s) - operation will be slower than usual\n "
540- )
541- % (oldpid , newpid )
527+ if result ["is_fresh_instance" ]:
528+ if not self ._ui .plain () and self ._ui .configbool (
529+ "fsmonitor" , "warn-fresh-instance"
530+ ):
531+ oldpid = _watchmanpid (event ["old_clock" ])
532+ newpid = _watchmanpid (event ["new_clock" ])
533+ if oldpid is not None and newpid is not None and oldpid != newpid :
534+ self ._ui .warn (
535+ _ (
536+ "warning: watchman has recently restarted (old pid %s, new pid %s) - operation will be slower than usual\n "
542537 )
543- elif oldpid is None and newpid is not None :
544- self . _ui . warn (
545- _ (
546- "warning: watchman has recently started (pid %s) - operation will be slower than usual \n "
547- )
548- % ( newpid ,)
538+ % ( oldpid , newpid )
539+ )
540+ elif oldpid is None and newpid is not None :
541+ self . _ui . warn (
542+ _ (
543+ "warning: watchman has recently started (pid %s) - operation will be slower than usual \n "
549544 )
550- else :
551- self ._ui .warn (
552- _ (
553- "warning: watchman failed to catch up with file change events and requires a full scan - operation will be slower than usual\n "
554- )
545+ % (newpid ,)
546+ )
547+ else :
548+ self ._ui .warn (
549+ _ (
550+ "warning: watchman failed to catch up with file change events and requires a full scan - operation will be slower than usual\n "
555551 )
552+ )
556553
557- if state .walk_on_invalidate :
558- state .invalidate (reason = "fresh_instance" )
559- raise fsmonitorfallback ("fresh instance" )
560- fresh_instance = True
561- # Ignore any prior noteable files from the state info
562- notefiles = []
563- else :
564- count = len (files )
565- state .setwatchmanchangedfilecount (count )
566- event ["new_files" ] = blackbox .shortlist (
567- sorted (e ["name" ] for e in files ), count
568- )
569- span .record (newfileslen = len (files ))
570- # XXX: Legacy scuba logging. Remove this once the source of truth
571- # is moved to the Rust Event.
572- if event ["is_fresh" ]:
573- self ._ui .log ("fsmonitor_status" , fsmonitor_status = "fresh" )
574- else :
575- self ._ui .log ("fsmonitor_status" , fsmonitor_status = "normal" )
554+ if state .walk_on_invalidate :
555+ state .invalidate (reason = "fresh_instance" )
556+ raise fsmonitorfallback ("fresh instance" )
557+ fresh_instance = True
558+ # Ignore any prior noteable files from the state info
559+ notefiles = []
560+ else :
561+ count = len (files )
562+ state .setwatchmanchangedfilecount (count )
563+ event ["new_files" ] = blackbox .shortlist (
564+ sorted (e ["name" ] for e in files ), count
565+ )
566+ span .record (newfileslen = len (files ))
567+ # XXX: Legacy scuba logging. Remove this once the source of truth
568+ # is moved to the Rust Event.
569+ if event ["is_fresh" ]:
570+ self ._ui .log ("fsmonitor_status" , fsmonitor_status = "fresh" )
571+ else :
572+ self ._ui .log ("fsmonitor_status" , fsmonitor_status = "normal" )
576573
577574 results = {}
578575
0 commit comments