def main(context): """Parses the command-line arguments and starts git-cola """ setup_environment() opts, args, context = parse_args(context) repo = process_args(opts, args) # Allow Ctrl-C to exit signal.signal(signal.SIGINT, signal.SIG_DFL) # Initialize the app app = ColaApplication(sys.argv) # Ensure that we're working in a valid git repository. # If not, try to find one. When found, chdir there. model = cola.model() valid = model.set_worktree(repo) and not opts.prompt while not valid: startup_dlg = startup.StartupDialog(app.activeWindow()) gitdir = startup_dlg.find_git_repo() if not gitdir: sys.exit(-1) valid = model.set_worktree(gitdir) # Finally, go to the root of the git repo os.chdir(model.git.worktree()) # Show the GUI if context == 'archive': from cola.widgets.archive import GitArchiveDialog model.update_status() view = GitArchiveDialog(model.currentbranch) elif context == 'branch': from cola.widgets.createbranch import create_new_branch view = create_new_branch() elif context in ('git-dag', 'dag'): from cola.dag import git_dag view = git_dag(model, opts=opts, args=args) elif context in ('classic', 'browse'): from cola.classic import cola_classic view = cola_classic(update=False) elif context == 'config': from cola.prefs import preferences view = preferences() elif context == 'diff': from cola.difftool import diff_expression while args and args[0] == '--': args.pop(0) expr = subprocess.list2cmdline(map(core.decode, args)) view = diff_expression(None, expr, create_widget=True) elif context == 'fetch': # TODO: the calls to update_status() can be done asynchronously # by hooking into the message_updated notification. from cola.widgets import remote model.update_status() view = remote.fetch() elif context == 'grep': from cola.widgets import grep view = grep.run_grep(parent=None) elif context == 'merge': from cola.merge import view model.update_status() view = view.MergeView(model, parent=None) elif context == 'pull': from cola.widgets import remote model.update_status() view = remote.pull() elif context == 'push': from cola.widgets import remote model.update_status() view = remote.push() elif context == 'remote': from cola.widgets import editremotes view = editremotes.edit() elif context == 'search': from cola.widgets.search import search view = search() elif context == 'stash': from cola.stash import stash model.update_status() view = stash() elif context == 'tag': from cola.widgets.createtag import create_tag view = create_tag() else: view = MainView(model, qtutils.active_window()) # Make sure that we start out on top view.show() view.raise_() # Scan for the first time task = _start_update_thread(model) # Start the inotify thread inotify.start() msg_timer = QtCore.QTimer() msg_timer.setSingleShot(True) msg_timer.connect(msg_timer, SIGNAL('timeout()'), _send_msg) msg_timer.start(0) # Start the event loop result = app.exec_() # All done, cleanup inotify.stop() QtCore.QThreadPool.globalInstance().waitForDone() pattern = utils.tmp_file_pattern() for filename in glob.glob(pattern): os.unlink(filename) sys.exit(result) return view, task
def main(context): """Parses the command-line arguments and starts git-cola """ setup_environment() opts, args, context = parse_args(context) repo = process_args(opts, args) # Allow Ctrl-C to exit signal.signal(signal.SIGINT, signal.SIG_DFL) # Initialize the app app = ColaApplication(sys.argv) # Ensure that we're working in a valid git repository. # If not, try to find one. When found, chdir there. model = cola.model() valid = model.set_worktree(repo) and not opts.prompt while not valid: startup_dlg = startup.StartupDialog(app.activeWindow()) gitdir = startup_dlg.find_git_repo() if not gitdir: sys.exit(-1) valid = model.set_worktree(gitdir) # Finally, go to the root of the git repo os.chdir(model.git.worktree()) # Show the GUI if context == "archive": from cola.widgets.archive import GitArchiveDialog model.update_status() view = GitArchiveDialog(model.currentbranch) elif context == "branch": from cola.widgets.createbranch import create_new_branch view = create_new_branch() elif context in ("git-dag", "dag"): from cola.dag import git_dag ctl = git_dag(model, opts=opts, args=args) view = ctl.view elif context in ("classic", "browse"): from cola.classic import cola_classic view = cola_classic(update=False) elif context == "config": from cola.prefs import preferences ctl = preferences() view = ctl.view elif context == "fetch": # TODO: the calls to update_status() can be done asynchronously # by hooking into the message_updated notification. from cola.widgets import remote model.update_status() view = remote.fetch() elif context == "grep": from cola.widgets import grep view = grep.run_grep(parent=None) elif context == "pull": from cola.widgets import remote model.update_status() view = remote.pull() elif context == "push": from cola.widgets import remote model.update_status() view = remote.push() elif context == "remote": from cola.widgets import editremotes view = editremotes.edit() elif context == "search": from cola.widgets.search import search view = search() elif context == "stash": from cola.stash import stash model.update_status() view = stash().view elif context == "tag": from cola.widgets.createtag import create_tag view = create_tag() else: view = MainView(model, qtutils.active_window()) ctl = MainController(model, view) # Install UI wrappers for command objects cfgactions.install_command_wrapper() guicmds.install_command_wrapper() # Make sure that we start out on top view.show() view.raise_() # Scan for the first time task = _start_update_thread(model) # Start the inotify thread inotify.start() msg_timer = QtCore.QTimer() msg_timer.setSingleShot(True) msg_timer.connect(msg_timer, SIGNAL("timeout()"), _send_msg) msg_timer.start(0) # Start the event loop result = app.exec_() # All done, cleanup inotify.stop() QtCore.QThreadPool.globalInstance().waitForDone() pattern = utils.tmp_file_pattern() for filename in glob.glob(pattern): os.unlink(filename) sys.exit(result) return ctl, task
def main(context): """Parses the command-line arguments and starts git-cola """ setup_environment() opts, args = parse_args(context) repo = process_args(opts, args) # Allow Ctrl-C to exit signal.signal(signal.SIGINT, signal.SIG_DFL) # Initialize the app app = ColaApplication(sys.argv) # Ensure that we're working in a valid git repository. # If not, try to find one. When found, chdir there. model = cola.model() valid = model.use_worktree(repo) and not opts.prompt while not valid: startup_dlg = startup.StartupDialog(app.activeWindow()) gitdir = startup_dlg.find_git_repo() if not gitdir: sys.exit(-1) valid = model.use_worktree(gitdir) # Finally, go to the root of the git repo os.chdir(model.git.worktree()) # Show the GUI if opts.classic: view = cola_classic(update=False) elif context == 'git-cola': view = MainView(model, qtutils.active_window()) ctl = MainController(model, view) elif context == 'git-dag': ctl = git_dag(model, opts=opts, args=args) view = ctl.view # Install UI wrappers for command objects cfgactions.install_command_wrapper() guicmds.install_command_wrapper() # Show the view and start the main event loop view.show() # Make sure that we start out on top view.raise_() # Scan for the first time task = _start_update_thread(model) # Start the inotify thread inotify.start() msg_timer = QtCore.QTimer() msg_timer.setSingleShot(True) msg_timer.connect(msg_timer, SIGNAL('timeout()'), _send_msg) msg_timer.start(0) # Start the event loop result = app.exec_() # All done, cleanup inotify.stop() QtCore.QThreadPool.globalInstance().waitForDone() pattern = cola.model().tmp_file_pattern() for filename in glob.glob(pattern): os.unlink(filename) sys.exit(result) return ctl, task