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