[PATCH] make clean: no delete mercurial/__version__.py in source release

J. Lewis Muir jlmuir at anl.gov
Wed Dec 8 12:01:26 CST 2010


# HG changeset patch
# User J. Lewis Muir <jlmuir at anl.gov>
# Date 1291826953 21600
# Node ID 870d0b9972a4ae8db37dc5e9f45bd2b731384a12
# Parent  c73745762f33cb19feb9dd6ddfc9962c459b9679
make clean: no delete mercurial/__version__.py in source release

The "clean" target in Makefile deletes mercurial/__version__.py.  In a
repository, this is OK since the version will be determined from the
repository.  But in an extracted .tar.gz source release, "make clean"
permanently removes the version information from the source release
which, after a "make local" or "make install", results in "hg --version"
reporting "version unknown" as follows:

  $ hg --version
  Mercurial Distributed SCM (version unknown)
  (see http://mercurial.selenic.com for more information)

  Copyright (C) 2005-2010 Matt Mackall and others
  This is free software; see the source for copying conditions. There is
  NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.

A discussion of this problem on the Mercurial mailing list is at

  http://www.selenic.com/pipermail/mercurial/2010-December/036239.html

Change "clean" target in Makefile to only delete
mercurial/__version__.py if .hg directory exists.  Since .hg is likely
not to exist in the extracted .tar.gz source release,
mercurial/__version__.py will not be deleted for a "make clean" in this
case, thus preserving the version information in the source release.

diff -r c73745762f33 -r 870d0b9972a4 Makefile
--- a/Makefile	Mon Dec 06 16:59:43 2010 -0600
+++ b/Makefile	Wed Dec 08 10:49:13 2010 -0600
@@ -45,7 +45,8 @@
 clean:
 	-$(PYTHON) setup.py clean --all # ignore errors from this command
 	find . \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
-	rm -f MANIFEST mercurial/__version__.py tests/*.err
+	rm -f MANIFEST tests/*.err
+	if test -d .hg; then rm -f mercurial/__version__.py; fi
 	rm -rf build mercurial/locale
 	$(MAKE) -C doc clean
 


More information about the Mercurial-devel mailing list