Staging
v0.8.1
v0.8.1
https://foss.heptapod.net/mercurial/hgview
Tip revision: bee41ce72b90e18f0788035f0beba7d1e381744b authored by Graziella Toutoungis on 14 November 2008, 16:02:27 UTC
prepare 0.9.1 version
prepare 0.9.1 version
Tip revision: bee41ce
hgview
#!/usr/bin/env python
import sys, os
import os.path as pos
use_gtk=False
use_qt = False
if '--gtk' in sys.argv:
use_gtk = True
sys.argv.remove('--gtk')
if '--qt' in sys.argv:
use_qt = True
sys.argv.remove('--qt')
if use_gtk and use_qt:
print "Cannot use both gtk and Qt!"
sys.exit(1)
if not (use_gtk or use_qt):
if pos.isfile(pos.join(os.environ['HOME'], '.hgviewrc')):
try:
d = open(pos.join(os.environ['HOME'], '.hgviewrc')).readlines()
except:
print "Can't access to your .hgviewrc file! "
print "Check permissions or specify your desired backend with '--gtk' or '--qt'"
sys.exit(1)
else:
for l in d:
if l.startswith('backend'):
backend = l.split('=')[1].strip()
use_gtk = 'gtk' in backend
use_qt = 'qt' in backend
if not (use_gtk or use_qt): # still ...
use_gtk = True
try:
import hgview
# print hgview.__file__
except ImportError:
import stat
exec_path = pos.abspath(__file__)
# Resolve symbolic links
statinfo = os.lstat(exec_path)
if stat.S_ISLNK(statinfo.st_mode):
exec_path = pos.abspath(pos.join(pos.dirname(exec_path),
os.readlink(exec_path)))
py_path = pos.abspath(pos.join(pos.dirname(exec_path), ".."))
#print "Inserting:", py_path
sys.path.append(py_path)
if use_qt:
from hgview.qt4 import hgview_qt4 as hgview
elif use_gtk:
from hgview.gtk import hgview_gtk as hgview
hgview.main()