[PATCH stable] shrink-revlog: adjust sys.path before importing mercurial

Greg Ward greg-hg at gerg.ca
Thu Jan 7 08:36:49 CST 2010


# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1262874972 18000
# Branch stable
# Node ID a80f9801e730e29c69539a7aee6ddb3d28c1b61b
# Parent  a474f950357be8acb8704f46b4443872d0461feb
shrink-revlog: adjust sys.path before importing mercurial.

This assumes the script is still in the contrib/ directory of a source
tree.  It will make things more consistent and predictable in that case.

diff --git a/contrib/shrink-revlog.py b/contrib/shrink-revlog.py
--- a/contrib/shrink-revlog.py
+++ b/contrib/shrink-revlog.py
@@ -19,6 +19,12 @@
 
 import sys, os, tempfile
 import optparse
+
+# try to ensure that we use the mercurial libs from the same dir
+# as the script (assuming it's actually in contrib/ of a source dir)
+script = os.path.realpath(sys.argv[0])
+sys.path.insert(0, os.path.dirname(os.path.dirname(script)))
+
 from mercurial import ui as ui_, hg, revlog, transaction, node, util
 
 def toposort(rl):


More information about the Mercurial-devel mailing list