# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# class StatusSpinner(object):
# 
#     SIZE = 10  # 10 equal signs
#     TIME = 50  # 50 ms delay
# 
#     def __init__(self, thread, msg):
#         self.counter = 0
#         self.direction = 1
#         self.msg = msg
#         self.thread = thread
# 
#     def progress(self):
#         if not self.thread.is_alive():
#             sublime.status_message('')
#             return
# 
#         left, right = self.counter, (self.SIZE - 1 - self.counter)
#         self.counter += self.direction
#         if self.counter in (0, self.SIZE - 1):
#             self.direction *= -1
# 
#         status = "[%s=%s] %s" % (' ' * left, ' ' * right, self.msg)
# 
#         sublime.status_message(status)
#         sublime.set_timeout(self.progress, self.TIME)
# 
#     def start(self):
#         self.thread.start()
#         sublime.set_timeout(self.progress, 0)
# 
# Path: sgit/cmd.py
# class LegitCmd(GitRepoHelper, Cmd):
#     executable = 'legit'
#     bin = ['legit']
# 
#     def legit(self, cmd, *args, **kwargs):
#         return self.cmd(cmd, *args, **kwargs)
# 
#     def legit_string(self, cmd, *args, **kwargs):
#         return self._string(cmd, *args, **kwargs)
# 
#     def legit_lines(self, cmd, *args, **kwargs):
#         return self._lines(cmd, *args, **kwargs)
# 
#     def legit_exit_code(self, cmd, *args, **kwargs):
#         return self._exit_code(cmd, *args, **kwargs)
# 
#     def legit_async(self, cmd, *args, **kwargs):
#         return self.cmd_async(cmd, *args, **kwargs)


from functools import partial
from sublime_plugin import WindowCommand
from ..util import noop, StatusSpinner
from ..cmd import LegitCmd
import sublime
        lines = self.legit_lines(['branches'], cwd=repo)
        branches, choices = [], []
        for l in lines:
            if not l:
                continue
            current = l[0:2]
            name, pub = l[2:].split(None, 1)
            pub = pub.strip(' \t()')
            if not pub in filter:
                continue
            choices.append(['%s%s' % (current, name.strip()), '  %s' % pub])
            branches.append(name)
        return branches, choices

    def show_branches_panel(self, repo, on_selection, *args, **kwargs):
        branches, choices = self.get_branch_choices(repo, *args, **kwargs)

        def on_done(idx):
            if idx != -1:
                branch = branches[idx]
                on_selection(branch)

        self.window.show_quick_panel(choices, on_done, sublime.MONOSPACE_FONT)

    def run_async_legit_with_panel(self, repo, cmd, progress, panel_name):
        self.panel = self.window.get_output_panel(panel_name)
        self.panel_name = panel_name
        self.panel_shown = False

        thread = self.legit_async(cmd, cwd=repo, on_data=self.on_data)

# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# class StatusSpinner(object):
# 
#     SIZE = 10  # 10 equal signs
#     TIME = 50  # 50 ms delay
# 
#     def __init__(self, thread, msg):
#         self.counter = 0
#         self.direction = 1
#         self.msg = msg
#         self.thread = thread
# 
#     def progress(self):
#         if not self.thread.is_alive():
#             sublime.status_message('')
#             return
# 
#         left, right = self.counter, (self.SIZE - 1 - self.counter)
#         self.counter += self.direction
#         if self.counter in (0, self.SIZE - 1):
#             self.direction *= -1
# 
#         status = "[%s=%s] %s" % (' ' * left, ' ' * right, self.msg)
# 
#         sublime.status_message(status)
#         sublime.set_timeout(self.progress, self.TIME)
# 
#     def start(self):
#         self.thread.start()
#         sublime.set_timeout(self.progress, 0)
# 
# Path: sgit/cmd.py
# class LegitCmd(GitRepoHelper, Cmd):
#     executable = 'legit'
#     bin = ['legit']
# 
#     def legit(self, cmd, *args, **kwargs):
#         return self.cmd(cmd, *args, **kwargs)
# 
#     def legit_string(self, cmd, *args, **kwargs):
#         return self._string(cmd, *args, **kwargs)
# 
#     def legit_lines(self, cmd, *args, **kwargs):
#         return self._lines(cmd, *args, **kwargs)
# 
#     def legit_exit_code(self, cmd, *args, **kwargs):
#         return self._exit_code(cmd, *args, **kwargs)
# 
#     def legit_async(self, cmd, *args, **kwargs):
#         return self.cmd_async(cmd, *args, **kwargs)


# Path: sgit/git_extensions/legit.py
from functools import partial
from sublime_plugin import WindowCommand
from ..util import noop, StatusSpinner
from ..cmd import LegitCmd
import sublime

        lines = self.legit_lines(['branches'], cwd=repo)
        branches, choices = [], []
        for l in lines:
            if not l:
                continue
            current = l[0:2]
            name, pub = l[2:].split(None, 1)
            pub = pub.strip(' \t()')
            if not pub in filter:
                continue
            choices.append(['%s%s' % (current, name.strip()), '  %s' % pub])
            branches.append(name)
        return branches, choices

    def show_branches_panel(self, repo, on_selection, *args, **kwargs):
        branches, choices = self.get_branch_choices(repo, *args, **kwargs)

        def on_done(idx):
            if idx != -1:
                branch = branches[idx]
                on_selection(branch)

        self.window.show_quick_panel(choices, on_done, sublime.MONOSPACE_FONT)

    def run_async_legit_with_panel(self, repo, cmd, progress, panel_name):
        self.panel = self.window.get_output_panel(panel_name)
        self.panel_name = panel_name
        self.panel_shown = False

        thread = self.legit_async(cmd, cwd=repo, on_data=self.on_data)

        runner = StatusSpinner(thread, progress)