diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1660,13 +1660,7 @@ b.reverse() return pycompat.ossep.join((['..'] * len(a)) + b) or '.' -# the location of data files matching the source code -if procutil.mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': - # executable version (py2exe) doesn't support __file__ - datapath = os.path.dirname(pycompat.sysexecutable) -else: - datapath = os.path.dirname(pycompat.fsencode(__file__)) - +datapath = procutil.datapath() i18n.setdatapath(datapath) def checksignature(func): diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -535,3 +535,12 @@ # mission accomplished, this child needs to exit and not # continue the hg process here. os._exit(returncode) + +def datapath(): + """Return location of data/resource files that are part of the source.""" + if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': + # executable version (py2exe) doesn't support __file__ + return os.path.dirname(pycompat.sysexecutable) + else: + return os.path.dirname( + os.path.dirname(pycompat.fsencode(__file__)))