# HG changeset patch # User Goffi # Date 1439883445 -7200 # Node ID 934e402c90bf67cc300bc273db9ab5d00afce486 # Parent 8bfbf5cb0e28e3feabf78c8b7a04c66924f8bbb9 core: tools.utils.getRepositoryData now return "hg log -r -1" and short form of node + fixed crash if mercurial is not present: short form is now returned in string version for better readability. Even if a collision is possible, it's not a big deal as it is used mainly in about dialog to help identify a version in case of e.g. bug. diff -r 8bfbf5cb0e28 -r 934e402c90bf src/tools/utils.py --- a/src/tools/utils.py Tue Aug 18 09:01:18 2015 +0200 +++ b/src/tools/utils.py Tue Aug 18 09:37:25 2015 +0200 @@ -51,14 +51,14 @@ """ from distutils.spawn import find_executable import subprocess - KEYS=("node", "branch", "date", "tag") + KEYS=("node", "node_short", "branch", "date", "tag") repos_root = os.path.dirname(module.__file__) hg_path = find_executable('hg') if hg_path is not None: os.chdir(repos_root) try: - hg_data_raw = subprocess.check_output(["hg","parents","--template","{node}\n{branch}\n{date|isodate}\n{latesttag}"]) + hg_data_raw = subprocess.check_output(["hg","log", "-r", "-1", "--template","{node}\n{node|short}\n{branch}\n{date|isodate}\n{latesttag}"]) except subprocess.CalledProcessError: hg_data = {} else: @@ -67,6 +67,8 @@ hg_data['modified'] = '+' in subprocess.check_output(["hg","id","-i"]) except subprocess.CalledProcessError: pass + else: + hg_data = {} if not hg_data: log.debug(u"Mercurial not available or working, trying to get data from dirstate") @@ -74,13 +76,14 @@ try: with open('.hg/dirstate') as hg_dirstate: hg_data['node'] = hg_dirstate.read(20).encode('hex') + hg_data['node_short'] = hg_data['node'][:12] except IOError: log.warning(u"Can't access repository data") if as_string: if not hg_data: return u'repository data unknown' - strings = [u'rev', hg_data['node']] + strings = [u'rev', hg_data['node_short']] try: if hg_data['modified']: strings.append(u"[M]")