MCPcopy Create free account
hub / github.com/numpy/numpy / _get_svn_revision

Method _get_svn_revision

numpy/distutils/misc_util.py:1884–1911  ·  view source on GitHub ↗

Return path's SVN revision number.

(self, path)

Source from the content-addressed store, hash-verified

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&#x27;s Mercurial revision number.

Callers 2

get_versionMethod · 0.95
make_svn_version_pyMethod · 0.95

Calls 5

njoinFunction · 0.85
openFunction · 0.85
check_outputMethod · 0.45
getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected