Mercurial > hg > mercurial-crew-with-dirclash
view tests/hghave @ 5081:167c422c745f
httprepo: quote the path part of the URL
This should fix a 'hg clone "http://hg.example.org/path with spaces/"'
The code tries to do the right thing when the user passes a path that's
already escaped in part (e.g. "http://hg.example.org/path%20with spaces/").
If we're redirected, urllib2 will happily follow the URL it's given
without escaping anything. I'm not sure what we would have to hook
to work around that.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 06 Aug 2007 00:35:06 -0300 |
parents | c51c9bc4579d |
children | 4cf6f8dbd1b4 |
line wrap: on
line source
#!/usr/bin/env python """Test the running system for features availability. Exit with zero if all features are there, non-zero otherwise. """ import optparse import os import sys def has_symlink(): return hasattr(os, "symlink") checks = { "symlink": (has_symlink, "symbolic links"), } def list_features(): for name, feature in checks.iteritems(): desc = feature[1] print name + ':', desc parser = optparse.OptionParser("%prog [options] [features]") parser.add_option("--list-features", action="store_true", help="list available features") parser.add_option("-q", "--quiet", action="store_true", help="check features silently") if __name__ == '__main__': options, args = parser.parse_args() if options.list_features: list_features() sys.exit(0) quiet = options.quiet failures = 0 def error(msg): global failures if not quiet: sys.stderr.write(msg + '\n') failures += 1 for feature in args: if feature not in checks: error('hghave: unknown feature: ' + feature) continue check, desc = checks[feature] if not check(): error('hghave: missing feature: ' + desc) if failures != 0: sys.exit(1)