Return path's SVN revision number.
(self, path)
| 1882 | extlib.include_dirs.extend(self.include_dirs) |
| 1883 | |
| 1884 | def _get_svn_revision(self, path): |
| 1885 | """Return path's SVN revision number. |
| 1886 | """ |
| 1887 | try: |
| 1888 | output = subprocess.check_output(['svnversion'], cwd=path) |
| 1889 | except (subprocess.CalledProcessError, OSError): |
| 1890 | pass |
| 1891 | else: |
| 1892 | m = re.match(rb'(?P<revision>\d+)', output) |
| 1893 | if m: |
| 1894 | return int(m.group('revision')) |
| 1895 | |
| 1896 | if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK', None): |
| 1897 | entries = njoin(path, '_svn', 'entries') |
| 1898 | else: |
| 1899 | entries = njoin(path, '.svn', 'entries') |
| 1900 | if os.path.isfile(entries): |
| 1901 | with open(entries) as f: |
| 1902 | fstr = f.read() |
| 1903 | if fstr[:5] == '<?xml': # pre 1.4 |
| 1904 | m = re.search(r'revision="(?P<revision>\d+)"', fstr) |
| 1905 | if m: |
| 1906 | return int(m.group('revision')) |
| 1907 | else: # non-xml entries file --- check to be sure that |
| 1908 | m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr) |
| 1909 | if m: |
| 1910 | return int(m.group('revision')) |
| 1911 | return None |
| 1912 | |
| 1913 | def _get_hg_revision(self, path): |
| 1914 | """Return path's Mercurial revision number. |
no test coverage detected