[Python-checkins] distutils2: Use Mercurial command-line API instead of Python internals.
tarek.ziade
python-checkins at python.org
Wed Jun 2 01:18:23 CEST 2010
tarek.ziade pushed 0e17b47e7ab2 to distutils2:
http://hg.python.org/distutils2/rev/0e17b47e7ab2
changeset: 193:0e17b47e7ab2
user: ?ric Araujo <merwok at netwok.org>
date: Tue Jun 01 15:12:25 2010 +0200
summary: Use Mercurial command-line API instead of Python internals.
files: src/setup.py
diff --git a/src/setup.py b/src/setup.py
--- a/src/setup.py
+++ b/src/setup.py
@@ -17,19 +17,17 @@
f.close()
def get_tip_revision(path=os.getcwd()):
+ from subprocess import Popen, PIPE
try:
- from mercurial.hg import repository
- from mercurial.ui import ui
- from mercurial import node
- from mercurial.error import RepoError
- except ImportError:
+ cmd = Popen(['hg', 'tip', '--template', '{rev}', '-R', path],
+ stdout=PIPE, stderr=PIPE)
+ except OSError:
return 0
- try:
- repo = repository(ui(), path)
- tip = repo.changelog.tip()
- return repo.changelog.rev(tip)
- except RepoError:
+ rev = cmd.stdout.read()
+ if rev == '':
+ # there has been an error in the command
return 0
+ return int(rev)
DEV_SUFFIX = '.dev%d' % get_tip_revision('..')
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list