added code back which should not be removed in this proposal

This commit is contained in:
Andreas Preikschat 2013-04-16 17:55:23 +02:00
parent 8d5aaa927d
commit 140178a674

View File

@ -102,24 +102,45 @@ def get_application_version():
return APPLICATION_VERSION return APPLICATION_VERSION
if u'--dev-version' in sys.argv or u'-d' in sys.argv: if u'--dev-version' in sys.argv or u'-d' in sys.argv:
# If we're running the dev version, let's use bzr to get the version. # If we're running the dev version, let's use bzr to get the version.
bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE) try:
output, error = bzr.communicate() # If bzrlib is available, use it.
code = bzr.wait() from bzrlib.branch import Branch
if code != 0: b = Branch.open_containing('.')[0]
raise Exception(u'Error running bzr tags') b.lock_read()
lines = output.splitlines() try:
if not lines: # Get the branch's latest revision number.
tag = u'0.0.0' revno = b.revno()
revision = u'0' # Convert said revision number into a bzr revision id.
else: revision_id = b.dotted_revno_to_revision_id((revno,))
tag, revision = lines[-1].split() # Get a dict of tags, with the revision id as the key.
bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE) tags = b.tags.get_reverse_tag_dict()
output, error = bzr.communicate() # Check if the latest
code = bzr.wait() if revision_id in tags:
if code != 0: full_version = u'%s' % tags[revision_id][0]
raise Exception(u'Error running bzr log') else:
latest = output.split(u':')[0] full_version = '%s-bzr%s' % (sorted(b.tags.get_tag_dict().keys())[-1], revno)
full_version = latest == revision and tag or u'%s-bzr%s' % (tag, latest) finally:
b.unlock()
except:
# Otherwise run the command line bzr client.
bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE)
output, error = bzr.communicate()
code = bzr.wait()
if code != 0:
raise Exception(u'Error running bzr tags')
lines = output.splitlines()
if not lines:
tag = u'0.0.0'
revision = u'0'
else:
tag, revision = lines[-1].split()
bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE)
output, error = bzr.communicate()
code = bzr.wait()
if code != 0:
raise Exception(u'Error running bzr log')
latest = output.split(u':')[0]
full_version = latest == revision and tag or u'%s-bzr%s' % (tag, latest)
else: else:
# We're not running the development version, let's use the file. # We're not running the development version, let's use the file.
filepath = AppLocation.get_directory(AppLocation.VersionDir) filepath = AppLocation.get_directory(AppLocation.VersionDir)
@ -385,7 +406,7 @@ def get_natural_key(string):
key = [int(part) if part.isdigit() else get_locale_key(part) for part in key] key = [int(part) if part.isdigit() else get_locale_key(part) for part in key]
# Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str and int. # Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str and int.
#if string[0].isdigit(): #if string[0].isdigit():
# return [''] + key # return [''] + key
return key return key