Mercurial > hg
comparison setup.py @ 33110:6fdc1518983e
setup: fail if we cannot determine the version number
If running hg fails, exit the setup script unsuccessfully, rather than
proceeding to use a bogus version of "+0-". Using an invalid version number
causes various tests to fail later. Failing early makes it easier to identify
the source of the problem.
It is currently easy for setup.py to fail this way since it sets HGRCPTH to the
empty string before running "hg", which may often disable extensions necessary
to interact with the local repository.
author | Adam Simpkins <simpkins@fb.com> |
---|---|
date | Mon, 26 Jun 2017 11:31:30 -0700 |
parents | db8531c45953 |
children | 87ee783f7299 |
comparison
equal
deleted
inserted
replaced
33109:247bae545061 | 33110:6fdc1518983e |
---|---|
182 | 182 |
183 if os.path.isdir('.hg'): | 183 if os.path.isdir('.hg'): |
184 cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n'] | 184 cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n'] |
185 numerictags = [t for t in runhg(cmd, env).split() if t[0:1].isdigit()] | 185 numerictags = [t for t in runhg(cmd, env).split() if t[0:1].isdigit()] |
186 hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip() | 186 hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip() |
187 if not hgid: | |
188 # Bail out if hg is having problems interacting with this repository, | |
189 # rather than falling through and producing a bogus version number. | |
190 # Continuing with an invalid version number will break extensions | |
191 # that define minimumhgversion. | |
192 raise SystemExit('Unable to determine hg version from local repository') | |
187 if numerictags: # tag(s) found | 193 if numerictags: # tag(s) found |
188 version = numerictags[-1] | 194 version = numerictags[-1] |
189 if hgid.endswith('+'): # propagate the dirty status to the tag | 195 if hgid.endswith('+'): # propagate the dirty status to the tag |
190 version += '+' | 196 version += '+' |
191 else: # no tag found | 197 else: # no tag found |