513 self.close() |
513 self.close() |
514 raise IOError(errno.EPIPE, 'Broken pipe') |
514 raise IOError(errno.EPIPE, 'Broken pipe') |
515 |
515 |
516 sys.stdout = winstdout(sys.stdout) |
516 sys.stdout = winstdout(sys.stdout) |
517 |
517 |
|
518 def system_rcpath(): |
|
519 return [r'c:\mercurial\mercurial.ini'] |
|
520 |
518 def os_rcpath(): |
521 def os_rcpath(): |
519 '''return default os-specific hgrc search path''' |
522 '''return default os-specific hgrc search path''' |
520 try: |
523 return system_rcpath() + [os.path.join(os.path.expanduser('~'), |
521 import win32api, win32process |
524 'mercurial.ini')] |
522 proc = win32api.GetCurrentProcess() |
|
523 filename = win32process.GetModuleFileNameEx(proc, 0) |
|
524 systemrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') |
|
525 except ImportError: |
|
526 systemrc = r'c:\mercurial\mercurial.ini' |
|
527 |
|
528 return [systemrc, |
|
529 os.path.join(os.path.expanduser('~'), 'mercurial.ini')] |
|
530 |
525 |
531 def parse_patch_output(output_line): |
526 def parse_patch_output(output_line): |
532 """parses the output produced by patch and returns the file name""" |
527 """parses the output produced by patch and returns the file name""" |
533 pf = output_line[14:] |
528 pf = output_line[14:] |
534 if pf[0] == '`': |
529 if pf[0] == '`': |
535 pf = pf[1:-1] # Remove the quotes |
530 pf = pf[1:-1] # Remove the quotes |
536 return pf |
531 return pf |
537 |
532 |
538 try: # Mark Hammond's win32all package allows better functionality on Windows |
533 def testpid(pid): |
539 import win32api, win32con, win32file, pywintypes |
534 '''return False if pid dead, True if running or not known''' |
540 |
535 return True |
541 # create hard links using win32file module |
|
542 def os_link(src, dst): # NB will only succeed on NTFS |
|
543 win32file.CreateHardLink(dst, src) |
|
544 |
|
545 def nlinks(pathname): |
|
546 """Return number of hardlinks for the given file.""" |
|
547 try: |
|
548 fh = win32file.CreateFile(pathname, |
|
549 win32file.GENERIC_READ, win32file.FILE_SHARE_READ, |
|
550 None, win32file.OPEN_EXISTING, 0, None) |
|
551 res = win32file.GetFileInformationByHandle(fh) |
|
552 fh.Close() |
|
553 return res[7] |
|
554 except: |
|
555 return os.stat(pathname).st_nlink |
|
556 |
|
557 def testpid(pid): |
|
558 '''return True if pid is still running or unable to |
|
559 determine, False otherwise''' |
|
560 try: |
|
561 import win32process, winerror |
|
562 handle = win32api.OpenProcess( |
|
563 win32con.PROCESS_QUERY_INFORMATION, False, pid) |
|
564 if handle: |
|
565 status = win32process.GetExitCodeProcess(handle) |
|
566 return status == win32con.STILL_ACTIVE |
|
567 except pywintypes.error, details: |
|
568 return details[0] != winerror.ERROR_INVALID_PARAMETER |
|
569 return True |
|
570 |
|
571 except ImportError: |
|
572 def testpid(pid): |
|
573 '''return False if pid dead, True if running or not known''' |
|
574 return True |
|
575 |
536 |
576 def is_exec(f, last): |
537 def is_exec(f, last): |
577 return last |
538 return last |
578 |
539 |
579 def set_exec(f, mode): |
540 def set_exec(f, mode): |