3 """git-dag: An advanced git DAG visualizer
6 from __future__
import division
, absolute_import
, unicode_literals
9 Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013
10 David Aguilar <davvid@gmail.com> and contributors
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License version 2 as
14 published by the Free Software Foundation.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
25 from argparse
import ArgumentParser
26 from os
.path
import abspath
27 from os
.path
import dirname
28 from os
.path
import join
29 from os
.path
import realpath
32 def setup_environment():
33 """Provides access to the cola modules"""
34 # Try to detect where it is run from and set prefix and the search path.
35 # It is assumed that the user installed Cola using the --prefix= option
36 python2
= sys
.version_info
[0] == 2
37 prefix
= dirname(dirname(realpath(abspath(__file__
))))
39 cola_mod
= join(prefix
, str('cola'), str('__init__.py'))
40 install_lib
= join(prefix
, str('share'), str('git-cola'), str('lib'))
42 # Look for modules in the source or install trees
43 cola_mod
= os
.path
.join(prefix
, 'cola', '__init__.py')
44 install_lib
= os
.path
.join(prefix
, 'share', 'git-cola', 'lib')
46 if os
.path
.exists(cola_mod
):
48 sys
.path
.insert(1, prefix
)
51 sys
.path
.insert(1, install_lib
)
55 from cola
.app
import add_common_arguments
56 from cola
.app
import application_init
57 from cola
.app
import application_start
58 from cola
.widgets
.dag
import git_dag
63 return args
.func(args
)
67 parser
= ArgumentParser()
68 parser
.set_defaults(func
=cmd_dag
)
70 add_common_arguments(parser
)
71 parser
.add_argument('-c', '--count', '--max-count', metavar
='<count>',
72 type=int, default
=1000,
73 help='number of commits to display')
74 parser
.add_argument('args', nargs
='*', metavar
='<args>',
75 help='git log arguments')
76 args
, rest
= parser
.parse_known_args()
78 # splice unknown arguments to the beginning ~
79 # these are forwarded to git-log(1).
85 context
= application_init(args
)
86 view
= git_dag(context
.model
, args
=args
, settings
=args
.settings
)
87 return application_start(context
, view
)
90 if __name__
== '__main__':