1756 if not fileName: |
1756 if not fileName: |
1757 return |
1757 return |
1758 |
1758 |
1759 with contextlib.suppress(OSError): |
1759 with contextlib.suppress(OSError): |
1760 os.rename(fileName, fileName + ".orig") |
1760 os.rename(fileName, fileName + ".orig") |
1761 try: |
1761 if sys.platform.startswith(("win", "cygwin")): |
1762 hgOut = subprocess.check_output(["hg", "identify", "-i"]) # secok |
1762 localHg = os.path.join(sys.exec_prefix, "Scripts", "hg.exe") |
1763 hgOut = hgOut.decode() |
1763 else: |
1764 except (OSError, subprocess.CalledProcessError): |
1764 localHg = os.path.join(sys.exec_prefix, "bin", "hg") |
|
1765 for hg in (localHg, "hg"): |
|
1766 with contextlib.suppress(OSError, subprocess.CalledProcessError): |
|
1767 hgOut = subprocess.check_output(["hg", "identify", "-i"]) # secok |
|
1768 hgOut = hgOut.decode() |
|
1769 if hgOut: |
|
1770 break |
|
1771 else: |
1765 hgOut = "" |
1772 hgOut = "" |
1766 if hgOut: |
1773 if hgOut: |
1767 hgOut = hgOut.strip() |
1774 hgOut = hgOut.strip() |
1768 if hgOut.endswith("+"): |
1775 if hgOut.endswith("+"): |
1769 hgOut = hgOut[:-1] |
1776 hgOut = hgOut[:-1] |