Mercurial > libervia-backend
diff src/tools/utils.py @ 1376:28fd9e838f8f
core: getRepositoryData now get the module in argument
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 19 Mar 2015 20:40:10 +0100 |
parents | 3a20312d4012 |
children | 069ad98b360d |
line wrap: on
line diff
--- a/src/tools/utils.py Thu Mar 19 19:47:01 2015 +0100 +++ b/src/tools/utils.py Thu Mar 19 20:40:10 2015 +0100 @@ -36,9 +36,10 @@ yield char return ''.join(valid_chars(ustr)) -def getRepositoryData(as_string=True): +def getRepositoryData(module, as_string=True): """Retrieve info on current mecurial repository + @param module: module to look for (e.g. sat, libervia) @param as_string(bool): if True return a string, else return a dictionary @return (unicode, dictionary): retrieved info in a nice string, or a dictionary with retrieved data (key is not present if data is not found), @@ -50,13 +51,12 @@ """ from distutils.spawn import find_executable import subprocess - import sat KEYS=("node", "branch", "date", "tag") - sat_root = os.path.dirname(sat.__file__) + repos_root = os.path.dirname(module.__file__) hg_path = find_executable('hg') if hg_path is not None: - os.chdir(sat_root) + os.chdir(repos_root) try: hg_data_raw = subprocess.check_output(["hg","parents","--template","{node}\n{branch}\n{date|isodate}\n{latesttag}"]) except subprocess.CalledProcessError: @@ -70,7 +70,7 @@ if not hg_data: log.debug(u"Mercurial not available or working, trying to get data from dirstate") - os.chdir(os.path.relpath('..', sat_root)) + os.chdir(os.path.relpath('..', repos_root)) try: with open('.hg/dirstate') as hg_dirstate: hg_data['node'] = hg_dirstate.read(20).encode('hex')