changeset 9999:f91e5630ce7e

setup: install translation files as package data Remove the `install_package_data' subclass of `install_data' and use the `package_data' functionality provided by distutils instead. As package data must be located within the package directory, the data files are now generated in the build directory. To simplify the functionality of this change, the top-level `doc' and `templates' directories have been moved into the `mercurial' package directory.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Tue, 01 Dec 2009 16:06:10 +0100
parents 4a3c388f8c69
children 16f49d671c7f
files help/config.txt help/dates.txt help/diffs.txt help/environment.txt help/extensions.txt help/multirevs.txt help/patterns.txt help/revisions.txt help/templates.txt help/urls.txt mercurial/help/config.txt mercurial/help/dates.txt mercurial/help/diffs.txt mercurial/help/environment.txt mercurial/help/extensions.txt mercurial/help/multirevs.txt mercurial/help/patterns.txt mercurial/help/revisions.txt mercurial/help/templates.txt mercurial/help/urls.txt mercurial/templates/atom/changelog.tmpl mercurial/templates/atom/changelogentry.tmpl mercurial/templates/atom/error.tmpl mercurial/templates/atom/filelog.tmpl mercurial/templates/atom/header.tmpl mercurial/templates/atom/map mercurial/templates/atom/tagentry.tmpl mercurial/templates/atom/tags.tmpl mercurial/templates/coal/header.tmpl mercurial/templates/coal/map mercurial/templates/gitweb/branches.tmpl mercurial/templates/gitweb/changelog.tmpl mercurial/templates/gitweb/changelogentry.tmpl mercurial/templates/gitweb/changeset.tmpl mercurial/templates/gitweb/error.tmpl mercurial/templates/gitweb/fileannotate.tmpl mercurial/templates/gitweb/filediff.tmpl mercurial/templates/gitweb/filelog.tmpl mercurial/templates/gitweb/filerevision.tmpl mercurial/templates/gitweb/footer.tmpl mercurial/templates/gitweb/graph.tmpl mercurial/templates/gitweb/header.tmpl mercurial/templates/gitweb/index.tmpl mercurial/templates/gitweb/manifest.tmpl mercurial/templates/gitweb/map mercurial/templates/gitweb/notfound.tmpl mercurial/templates/gitweb/search.tmpl mercurial/templates/gitweb/shortlog.tmpl mercurial/templates/gitweb/summary.tmpl mercurial/templates/gitweb/tags.tmpl mercurial/templates/map-cmdline.changelog mercurial/templates/map-cmdline.compact mercurial/templates/map-cmdline.default mercurial/templates/monoblue/branches.tmpl mercurial/templates/monoblue/changelog.tmpl mercurial/templates/monoblue/changelogentry.tmpl mercurial/templates/monoblue/changeset.tmpl mercurial/templates/monoblue/error.tmpl mercurial/templates/monoblue/fileannotate.tmpl mercurial/templates/monoblue/filediff.tmpl mercurial/templates/monoblue/filelog.tmpl mercurial/templates/monoblue/filerevision.tmpl mercurial/templates/monoblue/footer.tmpl mercurial/templates/monoblue/graph.tmpl mercurial/templates/monoblue/header.tmpl mercurial/templates/monoblue/index.tmpl mercurial/templates/monoblue/manifest.tmpl mercurial/templates/monoblue/map mercurial/templates/monoblue/notfound.tmpl mercurial/templates/monoblue/search.tmpl mercurial/templates/monoblue/shortlog.tmpl mercurial/templates/monoblue/summary.tmpl mercurial/templates/monoblue/tags.tmpl mercurial/templates/paper/branches.tmpl mercurial/templates/paper/changeset.tmpl mercurial/templates/paper/error.tmpl mercurial/templates/paper/fileannotate.tmpl mercurial/templates/paper/filediff.tmpl mercurial/templates/paper/filelog.tmpl mercurial/templates/paper/filelogentry.tmpl mercurial/templates/paper/filerevision.tmpl mercurial/templates/paper/footer.tmpl mercurial/templates/paper/graph.tmpl mercurial/templates/paper/header.tmpl mercurial/templates/paper/index.tmpl mercurial/templates/paper/manifest.tmpl mercurial/templates/paper/map mercurial/templates/paper/notfound.tmpl mercurial/templates/paper/search.tmpl mercurial/templates/paper/shortlog.tmpl mercurial/templates/paper/shortlogentry.tmpl mercurial/templates/paper/tags.tmpl mercurial/templates/raw/changeset.tmpl mercurial/templates/raw/error.tmpl mercurial/templates/raw/fileannotate.tmpl mercurial/templates/raw/filediff.tmpl mercurial/templates/raw/index.tmpl mercurial/templates/raw/manifest.tmpl mercurial/templates/raw/map mercurial/templates/raw/notfound.tmpl mercurial/templates/rss/changelog.tmpl mercurial/templates/rss/changelogentry.tmpl mercurial/templates/rss/error.tmpl mercurial/templates/rss/filelog.tmpl mercurial/templates/rss/filelogentry.tmpl mercurial/templates/rss/header.tmpl mercurial/templates/rss/map mercurial/templates/rss/tagentry.tmpl mercurial/templates/rss/tags.tmpl mercurial/templates/spartan/branches.tmpl mercurial/templates/spartan/changelog.tmpl mercurial/templates/spartan/changelogentry.tmpl mercurial/templates/spartan/changeset.tmpl mercurial/templates/spartan/error.tmpl mercurial/templates/spartan/fileannotate.tmpl mercurial/templates/spartan/filediff.tmpl mercurial/templates/spartan/filelog.tmpl mercurial/templates/spartan/filelogentry.tmpl mercurial/templates/spartan/filerevision.tmpl mercurial/templates/spartan/footer.tmpl mercurial/templates/spartan/graph.tmpl mercurial/templates/spartan/header.tmpl mercurial/templates/spartan/index.tmpl mercurial/templates/spartan/manifest.tmpl mercurial/templates/spartan/map mercurial/templates/spartan/notfound.tmpl mercurial/templates/spartan/search.tmpl mercurial/templates/spartan/shortlog.tmpl mercurial/templates/spartan/shortlogentry.tmpl mercurial/templates/spartan/tags.tmpl mercurial/templates/static/background.png mercurial/templates/static/coal-file.png mercurial/templates/static/coal-folder.png mercurial/templates/static/excanvas.js mercurial/templates/static/graph.js mercurial/templates/static/hgicon.png mercurial/templates/static/hglogo.png mercurial/templates/static/style-coal.css mercurial/templates/static/style-gitweb.css mercurial/templates/static/style-monoblue.css mercurial/templates/static/style-paper.css mercurial/templates/static/style.css mercurial/templates/template-vars.txt setup.py templates/atom/changelog.tmpl templates/atom/changelogentry.tmpl templates/atom/error.tmpl templates/atom/filelog.tmpl templates/atom/header.tmpl templates/atom/map templates/atom/tagentry.tmpl templates/atom/tags.tmpl templates/coal/header.tmpl templates/coal/map templates/gitweb/branches.tmpl templates/gitweb/changelog.tmpl templates/gitweb/changelogentry.tmpl templates/gitweb/changeset.tmpl templates/gitweb/error.tmpl templates/gitweb/fileannotate.tmpl templates/gitweb/filediff.tmpl templates/gitweb/filelog.tmpl templates/gitweb/filerevision.tmpl templates/gitweb/footer.tmpl templates/gitweb/graph.tmpl templates/gitweb/header.tmpl templates/gitweb/index.tmpl templates/gitweb/manifest.tmpl templates/gitweb/map templates/gitweb/notfound.tmpl templates/gitweb/search.tmpl templates/gitweb/shortlog.tmpl templates/gitweb/summary.tmpl templates/gitweb/tags.tmpl templates/map-cmdline.changelog templates/map-cmdline.compact templates/map-cmdline.default templates/monoblue/branches.tmpl templates/monoblue/changelog.tmpl templates/monoblue/changelogentry.tmpl templates/monoblue/changeset.tmpl templates/monoblue/error.tmpl templates/monoblue/fileannotate.tmpl templates/monoblue/filediff.tmpl templates/monoblue/filelog.tmpl templates/monoblue/filerevision.tmpl templates/monoblue/footer.tmpl templates/monoblue/graph.tmpl templates/monoblue/header.tmpl templates/monoblue/index.tmpl templates/monoblue/manifest.tmpl templates/monoblue/map templates/monoblue/notfound.tmpl templates/monoblue/search.tmpl templates/monoblue/shortlog.tmpl templates/monoblue/summary.tmpl templates/monoblue/tags.tmpl templates/paper/branches.tmpl templates/paper/changeset.tmpl templates/paper/error.tmpl templates/paper/fileannotate.tmpl templates/paper/filediff.tmpl templates/paper/filelog.tmpl templates/paper/filelogentry.tmpl templates/paper/filerevision.tmpl templates/paper/footer.tmpl templates/paper/graph.tmpl templates/paper/header.tmpl templates/paper/index.tmpl templates/paper/manifest.tmpl templates/paper/map templates/paper/notfound.tmpl templates/paper/search.tmpl templates/paper/shortlog.tmpl templates/paper/shortlogentry.tmpl templates/paper/tags.tmpl templates/raw/changeset.tmpl templates/raw/error.tmpl templates/raw/fileannotate.tmpl templates/raw/filediff.tmpl templates/raw/index.tmpl templates/raw/manifest.tmpl templates/raw/map templates/raw/notfound.tmpl templates/rss/changelog.tmpl templates/rss/changelogentry.tmpl templates/rss/error.tmpl templates/rss/filelog.tmpl templates/rss/filelogentry.tmpl templates/rss/header.tmpl templates/rss/map templates/rss/tagentry.tmpl templates/rss/tags.tmpl templates/spartan/branches.tmpl templates/spartan/changelog.tmpl templates/spartan/changelogentry.tmpl templates/spartan/changeset.tmpl templates/spartan/error.tmpl templates/spartan/fileannotate.tmpl templates/spartan/filediff.tmpl templates/spartan/filelog.tmpl templates/spartan/filelogentry.tmpl templates/spartan/filerevision.tmpl templates/spartan/footer.tmpl templates/spartan/graph.tmpl templates/spartan/header.tmpl templates/spartan/index.tmpl templates/spartan/manifest.tmpl templates/spartan/map templates/spartan/notfound.tmpl templates/spartan/search.tmpl templates/spartan/shortlog.tmpl templates/spartan/shortlogentry.tmpl templates/spartan/tags.tmpl templates/static/background.png templates/static/coal-file.png templates/static/coal-folder.png templates/static/excanvas.js templates/static/graph.js templates/static/hgicon.png templates/static/hglogo.png templates/static/style-coal.css templates/static/style-gitweb.css templates/static/style-monoblue.css templates/static/style-paper.css templates/static/style.css templates/template-vars.txt
diffstat 134 files changed, 23 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
rename from help/config.txt
rename to mercurial/help/config.txt
rename from help/dates.txt
rename to mercurial/help/dates.txt
rename from help/diffs.txt
rename to mercurial/help/diffs.txt
rename from help/environment.txt
rename to mercurial/help/environment.txt
rename from help/extensions.txt
rename to mercurial/help/extensions.txt
rename from help/multirevs.txt
rename to mercurial/help/multirevs.txt
rename from help/patterns.txt
rename to mercurial/help/patterns.txt
rename from help/revisions.txt
rename to mercurial/help/revisions.txt
rename from help/templates.txt
rename to mercurial/help/templates.txt
rename from help/urls.txt
rename to mercurial/help/urls.txt
rename from templates/atom/changelog.tmpl
rename to mercurial/templates/atom/changelog.tmpl
rename from templates/atom/changelogentry.tmpl
rename to mercurial/templates/atom/changelogentry.tmpl
rename from templates/atom/error.tmpl
rename to mercurial/templates/atom/error.tmpl
rename from templates/atom/filelog.tmpl
rename to mercurial/templates/atom/filelog.tmpl
rename from templates/atom/header.tmpl
rename to mercurial/templates/atom/header.tmpl
rename from templates/atom/map
rename to mercurial/templates/atom/map
rename from templates/atom/tagentry.tmpl
rename to mercurial/templates/atom/tagentry.tmpl
rename from templates/atom/tags.tmpl
rename to mercurial/templates/atom/tags.tmpl
rename from templates/coal/header.tmpl
rename to mercurial/templates/coal/header.tmpl
rename from templates/coal/map
rename to mercurial/templates/coal/map
rename from templates/gitweb/branches.tmpl
rename to mercurial/templates/gitweb/branches.tmpl
rename from templates/gitweb/changelog.tmpl
rename to mercurial/templates/gitweb/changelog.tmpl
rename from templates/gitweb/changelogentry.tmpl
rename to mercurial/templates/gitweb/changelogentry.tmpl
rename from templates/gitweb/changeset.tmpl
rename to mercurial/templates/gitweb/changeset.tmpl
rename from templates/gitweb/error.tmpl
rename to mercurial/templates/gitweb/error.tmpl
rename from templates/gitweb/fileannotate.tmpl
rename to mercurial/templates/gitweb/fileannotate.tmpl
rename from templates/gitweb/filediff.tmpl
rename to mercurial/templates/gitweb/filediff.tmpl
rename from templates/gitweb/filelog.tmpl
rename to mercurial/templates/gitweb/filelog.tmpl
rename from templates/gitweb/filerevision.tmpl
rename to mercurial/templates/gitweb/filerevision.tmpl
rename from templates/gitweb/footer.tmpl
rename to mercurial/templates/gitweb/footer.tmpl
rename from templates/gitweb/graph.tmpl
rename to mercurial/templates/gitweb/graph.tmpl
rename from templates/gitweb/header.tmpl
rename to mercurial/templates/gitweb/header.tmpl
rename from templates/gitweb/index.tmpl
rename to mercurial/templates/gitweb/index.tmpl
rename from templates/gitweb/manifest.tmpl
rename to mercurial/templates/gitweb/manifest.tmpl
rename from templates/gitweb/map
rename to mercurial/templates/gitweb/map
rename from templates/gitweb/notfound.tmpl
rename to mercurial/templates/gitweb/notfound.tmpl
rename from templates/gitweb/search.tmpl
rename to mercurial/templates/gitweb/search.tmpl
rename from templates/gitweb/shortlog.tmpl
rename to mercurial/templates/gitweb/shortlog.tmpl
rename from templates/gitweb/summary.tmpl
rename to mercurial/templates/gitweb/summary.tmpl
rename from templates/gitweb/tags.tmpl
rename to mercurial/templates/gitweb/tags.tmpl
rename from templates/map-cmdline.changelog
rename to mercurial/templates/map-cmdline.changelog
rename from templates/map-cmdline.compact
rename to mercurial/templates/map-cmdline.compact
rename from templates/map-cmdline.default
rename to mercurial/templates/map-cmdline.default
rename from templates/monoblue/branches.tmpl
rename to mercurial/templates/monoblue/branches.tmpl
rename from templates/monoblue/changelog.tmpl
rename to mercurial/templates/monoblue/changelog.tmpl
rename from templates/monoblue/changelogentry.tmpl
rename to mercurial/templates/monoblue/changelogentry.tmpl
rename from templates/monoblue/changeset.tmpl
rename to mercurial/templates/monoblue/changeset.tmpl
rename from templates/monoblue/error.tmpl
rename to mercurial/templates/monoblue/error.tmpl
rename from templates/monoblue/fileannotate.tmpl
rename to mercurial/templates/monoblue/fileannotate.tmpl
rename from templates/monoblue/filediff.tmpl
rename to mercurial/templates/monoblue/filediff.tmpl
rename from templates/monoblue/filelog.tmpl
rename to mercurial/templates/monoblue/filelog.tmpl
rename from templates/monoblue/filerevision.tmpl
rename to mercurial/templates/monoblue/filerevision.tmpl
rename from templates/monoblue/footer.tmpl
rename to mercurial/templates/monoblue/footer.tmpl
rename from templates/monoblue/graph.tmpl
rename to mercurial/templates/monoblue/graph.tmpl
rename from templates/monoblue/header.tmpl
rename to mercurial/templates/monoblue/header.tmpl
rename from templates/monoblue/index.tmpl
rename to mercurial/templates/monoblue/index.tmpl
rename from templates/monoblue/manifest.tmpl
rename to mercurial/templates/monoblue/manifest.tmpl
rename from templates/monoblue/map
rename to mercurial/templates/monoblue/map
rename from templates/monoblue/notfound.tmpl
rename to mercurial/templates/monoblue/notfound.tmpl
rename from templates/monoblue/search.tmpl
rename to mercurial/templates/monoblue/search.tmpl
rename from templates/monoblue/shortlog.tmpl
rename to mercurial/templates/monoblue/shortlog.tmpl
rename from templates/monoblue/summary.tmpl
rename to mercurial/templates/monoblue/summary.tmpl
rename from templates/monoblue/tags.tmpl
rename to mercurial/templates/monoblue/tags.tmpl
rename from templates/paper/branches.tmpl
rename to mercurial/templates/paper/branches.tmpl
rename from templates/paper/changeset.tmpl
rename to mercurial/templates/paper/changeset.tmpl
rename from templates/paper/error.tmpl
rename to mercurial/templates/paper/error.tmpl
rename from templates/paper/fileannotate.tmpl
rename to mercurial/templates/paper/fileannotate.tmpl
rename from templates/paper/filediff.tmpl
rename to mercurial/templates/paper/filediff.tmpl
rename from templates/paper/filelog.tmpl
rename to mercurial/templates/paper/filelog.tmpl
rename from templates/paper/filelogentry.tmpl
rename to mercurial/templates/paper/filelogentry.tmpl
rename from templates/paper/filerevision.tmpl
rename to mercurial/templates/paper/filerevision.tmpl
rename from templates/paper/footer.tmpl
rename to mercurial/templates/paper/footer.tmpl
rename from templates/paper/graph.tmpl
rename to mercurial/templates/paper/graph.tmpl
rename from templates/paper/header.tmpl
rename to mercurial/templates/paper/header.tmpl
rename from templates/paper/index.tmpl
rename to mercurial/templates/paper/index.tmpl
rename from templates/paper/manifest.tmpl
rename to mercurial/templates/paper/manifest.tmpl
rename from templates/paper/map
rename to mercurial/templates/paper/map
rename from templates/paper/notfound.tmpl
rename to mercurial/templates/paper/notfound.tmpl
rename from templates/paper/search.tmpl
rename to mercurial/templates/paper/search.tmpl
rename from templates/paper/shortlog.tmpl
rename to mercurial/templates/paper/shortlog.tmpl
rename from templates/paper/shortlogentry.tmpl
rename to mercurial/templates/paper/shortlogentry.tmpl
rename from templates/paper/tags.tmpl
rename to mercurial/templates/paper/tags.tmpl
rename from templates/raw/changeset.tmpl
rename to mercurial/templates/raw/changeset.tmpl
rename from templates/raw/error.tmpl
rename to mercurial/templates/raw/error.tmpl
rename from templates/raw/fileannotate.tmpl
rename to mercurial/templates/raw/fileannotate.tmpl
rename from templates/raw/filediff.tmpl
rename to mercurial/templates/raw/filediff.tmpl
rename from templates/raw/index.tmpl
rename to mercurial/templates/raw/index.tmpl
rename from templates/raw/manifest.tmpl
rename to mercurial/templates/raw/manifest.tmpl
rename from templates/raw/map
rename to mercurial/templates/raw/map
rename from templates/raw/notfound.tmpl
rename to mercurial/templates/raw/notfound.tmpl
rename from templates/rss/changelog.tmpl
rename to mercurial/templates/rss/changelog.tmpl
rename from templates/rss/changelogentry.tmpl
rename to mercurial/templates/rss/changelogentry.tmpl
rename from templates/rss/error.tmpl
rename to mercurial/templates/rss/error.tmpl
rename from templates/rss/filelog.tmpl
rename to mercurial/templates/rss/filelog.tmpl
rename from templates/rss/filelogentry.tmpl
rename to mercurial/templates/rss/filelogentry.tmpl
rename from templates/rss/header.tmpl
rename to mercurial/templates/rss/header.tmpl
rename from templates/rss/map
rename to mercurial/templates/rss/map
rename from templates/rss/tagentry.tmpl
rename to mercurial/templates/rss/tagentry.tmpl
rename from templates/rss/tags.tmpl
rename to mercurial/templates/rss/tags.tmpl
rename from templates/spartan/branches.tmpl
rename to mercurial/templates/spartan/branches.tmpl
rename from templates/spartan/changelog.tmpl
rename to mercurial/templates/spartan/changelog.tmpl
rename from templates/spartan/changelogentry.tmpl
rename to mercurial/templates/spartan/changelogentry.tmpl
rename from templates/spartan/changeset.tmpl
rename to mercurial/templates/spartan/changeset.tmpl
rename from templates/spartan/error.tmpl
rename to mercurial/templates/spartan/error.tmpl
rename from templates/spartan/fileannotate.tmpl
rename to mercurial/templates/spartan/fileannotate.tmpl
rename from templates/spartan/filediff.tmpl
rename to mercurial/templates/spartan/filediff.tmpl
rename from templates/spartan/filelog.tmpl
rename to mercurial/templates/spartan/filelog.tmpl
rename from templates/spartan/filelogentry.tmpl
rename to mercurial/templates/spartan/filelogentry.tmpl
rename from templates/spartan/filerevision.tmpl
rename to mercurial/templates/spartan/filerevision.tmpl
rename from templates/spartan/footer.tmpl
rename to mercurial/templates/spartan/footer.tmpl
rename from templates/spartan/graph.tmpl
rename to mercurial/templates/spartan/graph.tmpl
rename from templates/spartan/header.tmpl
rename to mercurial/templates/spartan/header.tmpl
rename from templates/spartan/index.tmpl
rename to mercurial/templates/spartan/index.tmpl
rename from templates/spartan/manifest.tmpl
rename to mercurial/templates/spartan/manifest.tmpl
rename from templates/spartan/map
rename to mercurial/templates/spartan/map
rename from templates/spartan/notfound.tmpl
rename to mercurial/templates/spartan/notfound.tmpl
rename from templates/spartan/search.tmpl
rename to mercurial/templates/spartan/search.tmpl
rename from templates/spartan/shortlog.tmpl
rename to mercurial/templates/spartan/shortlog.tmpl
rename from templates/spartan/shortlogentry.tmpl
rename to mercurial/templates/spartan/shortlogentry.tmpl
rename from templates/spartan/tags.tmpl
rename to mercurial/templates/spartan/tags.tmpl
rename from templates/static/background.png
rename to mercurial/templates/static/background.png
rename from templates/static/coal-file.png
rename to mercurial/templates/static/coal-file.png
rename from templates/static/coal-folder.png
rename to mercurial/templates/static/coal-folder.png
rename from templates/static/excanvas.js
rename to mercurial/templates/static/excanvas.js
rename from templates/static/graph.js
rename to mercurial/templates/static/graph.js
rename from templates/static/hgicon.png
rename to mercurial/templates/static/hgicon.png
rename from templates/static/hglogo.png
rename to mercurial/templates/static/hglogo.png
rename from templates/static/style-coal.css
rename to mercurial/templates/static/style-coal.css
rename from templates/static/style-gitweb.css
rename to mercurial/templates/static/style-gitweb.css
rename from templates/static/style-monoblue.css
rename to mercurial/templates/static/style-monoblue.css
rename from templates/static/style-paper.css
rename to mercurial/templates/static/style-paper.css
rename from templates/static/style.css
rename to mercurial/templates/static/style.css
rename from templates/template-vars.txt
rename to mercurial/templates/template-vars.txt
--- a/setup.py
+++ b/setup.py
@@ -165,12 +165,6 @@
 except ImportError:
     version = 'unknown'
 
-class install_package_data(install_data):
-    def finalize_options(self):
-        self.set_undefined_options('install',
-                                   ('install_lib', 'install_dir'))
-        install_data.finalize_options(self)
-
 class build_mo(build):
 
     description = "build translations (.mo files)"
@@ -193,16 +187,17 @@
             pofile = join(podir, po)
             modir = join('locale', po[:-3], 'LC_MESSAGES')
             mofile = join(modir, 'hg.mo')
-            cmd = ['msgfmt', '-v', '-o', mofile, pofile]
+            mobuildfile = join('mercurial', mofile)
+            cmd = ['msgfmt', '-v', '-o', mobuildfile, pofile]
             if sys.platform != 'sunos5':
                 # msgfmt on Solaris does not know about -c
                 cmd.append('-c')
-            self.mkpath(modir)
-            self.make_file([pofile], mofile, spawn, (cmd,))
-            self.distribution.data_files.append((join('mercurial', modir),
-                                                 [mofile]))
+            self.mkpath(join('mercurial', modir))
+            self.make_file([pofile], mobuildfile, spawn, (cmd,))
 
-build.sub_commands.append(('build_mo', None))
+# Insert build_mo first so that files in mercurial/locale/ are found
+# when build_py is run next.
+build.sub_commands.insert(0, ('build_mo', None))
 
 Distribution.pure = 0
 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
@@ -230,8 +225,7 @@
             else:
                 yield module
 
-cmdclass = {'install_data': install_package_data,
-            'build_mo': build_mo,
+cmdclass = {'build_mo': build_mo,
             'build_py': hg_build_py}
 
 ext_modules=[
@@ -255,13 +249,21 @@
                                      ['hgext/inotify/linux/_inotify.c']))
         packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
 
+packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
+                             'help/*.txt']}
+
+def ordinarypath(p):
+    return p and p[0] != '.' and p[-1] != '~'
+
+for root in ('templates', ):
+    for curdir, dirs, files in os.walk(os.path.join('mercurial', root)):
+        curdir = curdir.split(os.sep, 1)[1]
+        dirs[:] = filter(ordinarypath, dirs)
+        for f in filter(ordinarypath, files):
+            f = os.path.join(curdir, f)
+            packagedata['mercurial'].append(f)
+
 datafiles = []
-for root in ('templates', 'help'):
-    for dir, dirs, files in os.walk(root):
-        dirs[:] = [x for x in dirs if not x.startswith('.')]
-        files = [x for x in files if not x.startswith('.')]
-        datafiles.append((os.path.join('mercurial', dir),
-                          [os.path.join(dir, file_) for file_ in files]))
 
 setup(name='mercurial',
       version=version,
@@ -274,6 +276,7 @@
       packages=packages,
       ext_modules=ext_modules,
       data_files=datafiles,
+      package_data=packagedata,
       cmdclass=cmdclass,
       options=dict(py2exe=dict(packages=['hgext', 'email']),
                    bdist_mpkg=dict(zipdist=True,