Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
importosimportwin32apiimportwin32confromwin32com.shellimportshell,shellconimport_winregfrommercurialimportuifromthgutilimportpaths,shlibimportsysimporttimeimportQueueimportthreadingimportwin32eventimportwin32pipeimportwin32fileimportpywintypesimportwinerrorPIPENAME=r"\\.\pipe\TortoiseHgRpcServer-bc0c27107423"PIPEBUFSIZE=4096defupdate_batch(batch):'''updates thgstatus for all paths in batch'''roots=set()notifypaths=set()forpathinbatch:r=paths.find_root(path)ifrisNone:forninos.listdir(path):r=paths.find_root(os.path.join(path,n))if(risnotNone):roots.add(r)notifypaths.add(r)else:roots.add(r);notifypaths.add(path)ifroots:_ui=ui.ui();forrinsorted(roots):shlib.update_thgstatus(_ui,r,wait=False)print"updated repo %s"%rifnotifypaths:time.sleep(2)shlib.shell_notify(list(notifypaths))print"shell notified"requests=Queue.Queue(0)_abort_request=r';:;:; Quit ;:;:;'# any invalid path would doclassUpdater(threading.Thread):defrun(self):n=0whileTrue:batch=[]r=requests.get()ifr==_abort_request:print'Updater thread quiting'returnprint"got request %s (first in batch)"%rbatch.append(r)print"wait a bit for additional requests..."time.sleep(0.2)try:whileTrue:r=requests.get_nowait()print"got request %s"%rbatch.append(r)exceptQueue.Empty:passn+=1msg="--- processing batch %i with %i requests ---"printmsg%(n,len(batch))update_batch(batch)Updater().start()classPipeServer:def__init__(self):# Create an event which we will use to wait on.# The "service stop" request will set this event.self.hWaitStop=win32event.CreateEvent(None,0,0,None)# We need to use overlapped IO for this, so we dont block when# waiting for a client to connect. This is the only effective way# to handle either a client connection, or a service stop request.self.overlapped=pywintypes.OVERLAPPED()# And create an event to be used in the OVERLAPPED object.self.overlapped.hEvent=win32event.CreateEvent(None,0,0,None)defSvcStop(self):print'PipeServer thread quiting'win32event.SetEvent(self.hWaitStop)requests.put(_abort_request)defSvcDoRun(self):# We create our named pipe.pipeName=PIPENAMEopenMode=win32pipe.PIPE_ACCESS_DUPLEX|win32file.FILE_FLAG_OVERLAPPEDpipeMode=win32pipe.PIPE_TYPE_MESSAGE# When running as a service, we must use special security for the pipesa=pywintypes.SECURITY_ATTRIBUTES()# Say we do have a DACL, and it is empty# (ie, allow full access!)sa.SetSecurityDescriptorDacl(1,None,0)pipeHandle=win32pipe.CreateNamedPipe(pipeName,openMode,pipeMode,win32pipe.PIPE_UNLIMITED_INSTANCES,0,0,6000,# default buffers, and 6 second timeout.sa)# Loop accepting and processing connectionswhileTrue:try:hr=win32pipe.ConnectNamedPipe(pipeHandle,self.overlapped)exceptpywintypes.error,inst:print"Error connecting pipe: ",instpipeHandle.Close()breakifhr==winerror.ERROR_PIPE_CONNECTED:# Client is fast, and already connected - signal eventwin32event.SetEvent(self.overlapped.hEvent)# Wait for either a connection, or a service stop request.timeout=win32event.INFINITEwaitHandles=self.hWaitStop,self.overlapped.hEventrc=win32event.WaitForMultipleObjects(waitHandles,0,timeout)ifrc==win32event.WAIT_OBJECT_0:# Stop eventreturnelse:# read pipe and process requesttry:hr,data=win32file.ReadFile(pipeHandle,PIPEBUFSIZE)ifnotdata:raiseSystemExit# signal by dispatch terminatewin32pipe.DisconnectNamedPipe(pipeHandle)exceptwin32file.error:# Client disconnected without sending data# or before reading the response.# Thats OK - just get the next connectioncontinuetry:requests.put(data)exceptSystemExit:raiseSystemExit# interrupted by thread2.terminate()except:importtracebackprint"WARNING: something went wrong in requests.put"printtraceback.format_exc() status = "ERROR"
# Clean up when we exit
self.SvcStop()
--if __name__ == '__main__':- import sys- if '--server' in sys.argv:- svc = PipeServer()- svc.SvcDoRun()- elif '--client' in sys.argv:- for x in sys.argv[1:]:- if x.startswith('-'):- continue- path = os.path.abspath(x)- try:- status = win32pipe.CallNamedPipe(PIPENAME, path, PIPEBUFSIZE, 0)- except pywintypes.error, inst:- print "can't access named pipe '%s'" % PIPENAME- sys.exit()- print "%s = %s" % (path, status)- else:- print "usage:\n%s [--server|--client]" % sys.argv[0]-
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.