Ejemplo n.º 1
0
 def setUp(self, commit=True):
     TmpPathTestCase.setUp(self)
     self.initialize_repo()
     if commit:
         self.commit_files()
     git.instance().set_worktree(os.getcwd())
     gitcfg.instance().reset()
     gitcmds.clear_cache()
Ejemplo n.º 2
0
    def __init__(self, cwd=None):
        """Reads git repository settings and sets several methods
        so that they refer to the git module.  This object
        encapsulates cola's interaction with git."""
        Observable.__init__(self)

        # Initialize the git command object
        self.git = git.instance()

        self.head = 'HEAD'
        self.diff_text = ''
        self.mode = self.mode_none
        self.filename = None
        self.currentbranch = ''
        self.directory = ''
        self.project = ''
        self.remotes = []

        self.commitmsg = ''
        self.modified = []
        self.staged = []
        self.untracked = []
        self.unmerged = []
        self.upstream_changed = []
        self.submodules = set()

        self.local_branches = []
        self.remote_branches = []
        self.tags = []
        if cwd:
            self.set_worktree(cwd)
Ejemplo n.º 3
0
    def __init__(self, cwd=None):
        """Reads git repository settings and sets several methods
        so that they refer to the git module.  This object
        encapsulates cola's interaction with git."""
        Observable.__init__(self)

        # Initialize the git command object
        self.git = git.instance()

        self.head = 'HEAD'
        self.diff_text = ''
        self.mode = self.mode_none
        self.filename = None
        self.currentbranch = ''
        self.directory = ''
        self.project = ''
        self.remotes = []

        self.commitmsg = ''
        self.modified = []
        self.staged = []
        self.untracked = []
        self.unmerged = []
        self.upstream_changed = []
        self.submodules = set()

        self.local_branches = []
        self.remote_branches = []
        self.tags = []
        if cwd:
            self.set_worktree(cwd)
Ejemplo n.º 4
0
 def __init__(self):
     self.git = git.instance()
     self._system = {}
     self._user = {}
     self._repo = {}
     self._all = {}
     self._cache_key = None
     self._configs = []
     self._config_files = {}
     self._find_config_files()
Ejemplo n.º 5
0
def _cache_key():
    # Try /etc/gitconfig as a fallback for the system config
    paths = ("/etc/gitconfig", _USER_XDG_CONFIG, _USER_CONFIG, git.instance().git_path("config"))
    mtimes = []
    for path in paths:
        try:
            mtimes.append(core.stat(path).st_mtime)
        except OSError:
            continue
    return mtimes
Ejemplo n.º 6
0
def _cache_key():
    # Try /etc/gitconfig as a fallback for the system config
    paths = ('/etc/gitconfig', _USER_XDG_CONFIG, _USER_CONFIG,
             git.instance().git_path('config'))
    mtimes = []
    for path in paths:
        try:
            mtimes.append(core.stat(path).st_mtime)
        except OSError:
            continue
    return mtimes
Ejemplo n.º 7
0
def _cache_key():
    # Try /etc/gitconfig as a fallback for the system config
    userconfig = os.path.expanduser(os.path.join("~", ".gitconfig"))
    paths = ("/etc/gitconfig", userconfig, git.instance().git_path("config"))
    mtimes = []
    for path in paths:
        try:
            mtimes.append(os.stat(path).st_mtime)
        except OSError:
            continue
    return mtimes
Ejemplo n.º 8
0
def rebase():
    """Rebase onto a branch."""
    branch = choose_from_combo('Rebase Branch',
                               cola.model().all_branches())
    if not branch:
        return
    #TODO cmd
    status, output = git.instance().rebase(branch,
                                           with_stderr=True,
                                           with_status=True)
    qtutils.log(status, output)
Ejemplo n.º 9
0
 def __init__(self):
     observable.ObservableModel.__init__(self)
     self.git = git.instance()
     self.descriptions_start = []
     self.descriptions_end = []
     self.revisions_start = []
     self.revisions_end = []
     self.revision_start = ''
     self.revision_end = ''
     self.compare_files = []
     self.num_results = 100
     self.show_versions=False
Ejemplo n.º 10
0
def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    paths = (('system', '/etc/gitconfig'), ('user', _USER_XDG_CONFIG),
             ('user', _USER_CONFIG), ('repo',
                                      git.instance().git_path('config')))
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, core.stat(path).st_mtime))
        except OSError:
            continue
    return statinfo
Ejemplo n.º 11
0
    def __init__(self, cwd=None):
        """Reads git repository settings and sets several methods
        so that they refer to the git module.  This object
        encapsulates cola's interaction with git."""
        ObservableModel.__init__(self)

        # Initialize the git command object
        self.git = git.instance()

        #####################################################
        self.head = 'HEAD'
        self.mode = self.mode_none
        self.diff_text = ''
        self.filename = None
        self.currentbranch = ''
        self.trackedbranch = ''
        self.directory = ''
        self.git_version = self.git.version()
        self.remotes = []
        self.remotename = ''
        self.local_branch = ''
        self.remote_branch = ''

        #####################################################
        # Status info
        self.commitmsg = ''
        self.modified = []
        self.staged = []
        self.untracked = []
        self.unmerged = []
        self.upstream_changed = []
        self.submodules = set()

        #####################################################
        # Refs
        self.revision = ''
        self.local_branches = []
        self.remote_branches = []
        self.tags = []
        self.revisions = []
        self.summaries = []

        self.fetch_helper = None
        self.push_helper = None
        self.pull_helper = None
        self.generate_remote_helpers()
        if cwd:
            self.use_worktree(cwd)

        #####################################################
        # Dag
        self._commits = []
Ejemplo n.º 12
0
def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    userconfig = os.path.expanduser(os.path.join('~', '.gitconfig'))
    paths = (('system', '/etc/gitconfig'),
             ('user', core.decode(userconfig)),
             ('repo', core.decode(git.instance().git_path('config'))))
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, os.stat(path).st_mtime))
        except OSError:
            continue
    return statinfo
Ejemplo n.º 13
0
def _cache_key():
    # Try /etc/gitconfig as a fallback for the system config
    userconfig = os.path.expanduser(os.path.join('~', '.gitconfig'))
    paths = ('/etc/gitconfig',
             userconfig,
             git.instance().git_path('config'))
    mtimes = []
    for path in paths:
        try:
            mtimes.append(os.stat(path).st_mtime)
        except OSError:
            continue
    return mtimes
Ejemplo n.º 14
0
def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    userconfig = os.path.expanduser(os.path.join('~', '.gitconfig'))
    paths = (('system', '/etc/gitconfig'),
             ('user', core.decode(userconfig)),
             ('repo', core.decode(git.instance().git_path('config'))))
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, os.stat(path).st_mtime))
        except OSError:
            continue
    return statinfo
Ejemplo n.º 15
0
def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    paths = (('system', '/etc/gitconfig'),
             ('user', _USER_XDG_CONFIG),
             ('user', _USER_CONFIG),
             ('repo', git.instance().git_path('config')))
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, core.stat(path).st_mtime))
        except OSError:
            continue
    return statinfo
Ejemplo n.º 16
0
 def __init__(self):
     observable.Observable.__init__(self)
     self.git = git.instance()
     self._map = {}
     self._system = {}
     self._user = {}
     self._repo = {}
     self._all = {}
     self._cache_key = None
     self._configs = []
     self._config_files = {}
     self._value_cache = {}
     self._attr_cache = {}
     self._find_config_files()
Ejemplo n.º 17
0
 def __init__(self):
     observable.Observable.__init__(self)
     self.git = git.instance()
     self._map = {}
     self._system = {}
     self._user = {}
     self._repo = {}
     self._all = {}
     self._cache_key = None
     self._configs = []
     self._config_files = {}
     self._value_cache = {}
     self._attr_cache = {}
     self._find_config_files()
Ejemplo n.º 18
0
def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    paths = (
        ("system", "/etc/gitconfig"),
        ("user", _USER_XDG_CONFIG),
        ("user", _USER_CONFIG),
        ("repo", git.instance().git_path("config")),
    )
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, core.stat(path).st_mtime))
        except OSError:
            continue
    return statinfo
Ejemplo n.º 19
0
def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    userconfig = os.path.expanduser(os.path.join("~", ".gitconfig"))
    paths = (
        ("system", "/etc/gitconfig"),
        ("user", core.decode(userconfig)),
        ("repo", core.decode(git.instance().git_path("config"))),
    )
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, os.stat(path).st_mtime))
        except OSError:
            continue
    return statinfo
Ejemplo n.º 20
0
def diff_branch():
    """Launches a diff against a branch."""
    branch = choose_from_combo('Select Branch, Tag, or Commit-ish',
                               ['HEAD^'] +
                               cola.model().all_branches() +
                               cola.model().tags)
    if not branch:
        return
    zfiles_str = git.instance().diff(branch, name_only=True,
                                     no_color=True,
                                     z=True).rstrip('\0')
    files = zfiles_str.split('\0')
    filename = choose_from_list('Select File', files)
    if not filename:
        return
    cola.notifier().broadcast(signals.branch_mode, branch, filename)
Ejemplo n.º 21
0
 def __init__(self):
     observable.ObservableModel.__init__(self)
     self.git = git.instance()
     self.remote_branches = gitcmds.branch_list(remote=True)
     self.local_branches = gitcmds.branch_list(remote=False)
     self.left_combo = ['Local', 'Remote']
     self.right_combo = ['Local', 'Remote']
     self.left_combo_index = 0
     self.right_combo_index = 1
     self.left_list = []
     self.right_list = []
     self.left_list_index = -1
     self.right_list_index = -1
     self.left_list_selected = False
     self.right_list_selected = False
     self.diff_files = []
Ejemplo n.º 22
0
def git_version():
    """Returns the current GIT version"""
    return git.instance().version().split()[-1]
Ejemplo n.º 23
0

import os

from PyQt4 import QtGui

from cola import git
from cola import gitcmds
from cola import utils
from cola import resources
from cola import qtutils
from cola.models import browser
from cola.views.selectcommits import SelectCommitsView
from cola.qobserver import QObserver

git = git.instance()


def select_file_from_repo():
    """Launch a dialog for selecting a filename from a branch."""
    # Clone the model to allow opening multiple browsers
    # with different sets of data
    model = browser.BrowserModel(gitcmds.current_branch())
    parent = QtGui.QApplication.instance().activeWindow()
    view = SelectCommitsView(parent, syntax=False)
    controller = RepoBrowserController(model, view,
                                       title='Select File',
                                       get_file=True)
    view.show()
    if view.exec_() == QtGui.QDialog.Accepted:
        return controller.filename