Ejemplo n.º 1
0
    def _update_callback(self):
        """Update the title with the current branch and directory name."""
        branch = self.model.currentbranch
        curdir = core.decode(os.getcwd())
        msg = 'Repository: %s\nBranch: %s' % (curdir, branch)
        self.commitdockwidget.setToolTip(msg)

        title = '%s [%s]' % (self.model.project, branch)
        if self.mode in (self.model.mode_diff, self.model.mode_diff_expr):
            title += ' *** diff mode***'
        elif self.mode == self.model.mode_review:
            title += ' *** review mode***'
        elif self.mode == self.model.mode_amend:
            title += ' *** amending ***'
        self.setWindowTitle(title)

        if self.mode != self.model.mode_amend:
            self.amend_checkbox.blockSignals(True)
            self.amend_checkbox.setChecked(False)
            self.amend_checkbox.blockSignals(False)

        if not self.model.read_only() and self.mode != self.model.mode_amend:
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(core.decode(merge_msg_path))
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cola.notifier().broadcast(signals.load_commit_message,
                                      core.decode(merge_msg_path))
Ejemplo n.º 2
0
    def _update_callback(self):
        """Update the title with the current branch and directory name."""
        branch = self.model.currentbranch
        curdir = core.decode(os.getcwd())
        msg = N_('Repository: %s') % curdir
        msg += '\n'
        msg += N_('Branch: %s') % branch
        self.commitdockwidget.setToolTip(msg)

        title = '%s: %s (%s)' % (self.model.project, branch, self.model.git.worktree())
        if self.mode == self.model.mode_amend:
            title += ' (%s)' %  N_('Amending')
        self.setWindowTitle(title)

        self.commitmsgeditor.set_mode(self.mode)

        if not self.model.amending():
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(core.decode(merge_msg_path))
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cmds.do(cmds.LoadCommitMessage, core.decode(merge_msg_path))
Ejemplo n.º 3
0
    def _update_callback(self):
        """Update the title with the current branch and directory name."""
        branch = self.model.currentbranch
        curdir = core.decode(os.getcwd())
        msg = N_('Repository: %s') % curdir
        msg += '\n'
        msg += N_('Branch: %s') % branch
        self.commitdockwidget.setToolTip(msg)

        title = '%s: %s (%s)' % (self.model.project, branch, self.model.git.worktree())
        if self.mode == self.model.mode_amend:
            title += ' (%s)' %  N_('Amending')
        self.setWindowTitle(title)

        self.commitmsgeditor.set_mode(self.mode)

        if not self.model.amending():
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(core.decode(merge_msg_path))
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cmds.do(cmds.LoadCommitMessage, core.decode(merge_msg_path))
Ejemplo n.º 4
0
    def _update_callback(self):
        """Update the title with the current branch and directory name."""
        branch = self.model.currentbranch
        curdir = core.decode(os.getcwd())
        msg = 'Repository: %s\nBranch: %s' % (curdir, branch)
        self.commitdockwidget.setToolTip(msg)

        title = '%s: %s' % (self.model.project, branch)
        if self.mode == self.model.mode_amend:
            title += ' ** amending **'
        self.setWindowTitle(title)

        self.commitmsgeditor.set_mode(self.mode)

        if not self.model.amending():
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(core.decode(merge_msg_path))
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cola.notifier().broadcast(signals.load_commit_message,
                                      core.decode(merge_msg_path))
Ejemplo n.º 5
0
    def _update_view(self):
        """Update the title with the current branch and directory name."""
        title = '%s [%s]' % (self.model.project,
                             self.model.currentbranch)
        if self.mode in (self.model.mode_diff, self.model.mode_diff_expr):
            title += ' *** diff mode***'
        elif self.mode == self.model.mode_review:
            title += ' *** review mode***'
        elif self.mode == self.model.mode_amend:
            title += ' *** amending ***'
        self.setWindowTitle(title)

        if self.mode != self.model.mode_amend:
            self.amend_checkbox.blockSignals(True)
            self.amend_checkbox.setChecked(False)
            self.amend_checkbox.blockSignals(False)

        if not self.model.read_only() and self.mode != self.model.mode_amend:
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(merge_msg_path)
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cola.notifier().broadcast(signals.load_commit_message,
                                      merge_msg_path)
Ejemplo n.º 6
0
Archivo: main.py Proyecto: pwr/git-cola
    def _update_callback(self):
        """Update the title with the current branch and directory name."""
        alerts = []
        branch = self.model.currentbranch
        curdir = core.getcwd()
        is_merging = self.model.is_merging
        is_rebasing = self.model.is_rebasing

        msg = N_("Repository: %s") % curdir
        msg += "\n"
        msg += N_("Branch: %s") % branch

        if is_rebasing:
            msg += "\n\n"
            msg += N_(
                "This repository is currently being rebased.\n"
                "Resolve conflicts, commit changes, and run:\n"
                "    Rebase > Continue"
            )
            alerts.append(N_("Rebasing"))

        elif is_merging:
            msg += "\n\n"
            msg += N_("This repository is in the middle of a merge.\n" "Resolve conflicts and commit changes.")
            alerts.append(N_("Merging"))

        if self.mode == self.model.mode_amend:
            alerts.append(N_("Amending"))

        l = unichr(0xAB)
        r = unichr(0xBB)
        title = "%s: %s %s%s" % (
            self.model.project,
            branch,
            alerts and ((r + " %s " + l + " ") % ", ".join(alerts)) or "",
            self.model.git.worktree(),
        )

        self.setWindowTitle(title)
        self.commitdockwidget.setToolTip(msg)
        self.commitmsgeditor.set_mode(self.mode)
        self.update_actions()

        if not self.model.amending():
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(merge_msg_path)
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cmds.do(cmds.LoadCommitMessageFromFile, merge_msg_path)
Ejemplo n.º 7
0
    def _update_callback(self):
        """Update the title with the current branch and directory name."""
        alerts = []
        branch = self.model.currentbranch
        curdir = core.getcwd()
        is_merging = self.model.is_merging
        is_rebasing = self.model.is_rebasing

        msg = N_('Repository: %s') % curdir
        msg += '\n'
        msg += N_('Branch: %s') % branch

        if is_rebasing:
            msg += '\n\n'
            msg += N_('This repository is currently being rebased.\n'
                      'Resolve conflicts, commit changes, and run:\n'
                      '    Rebase > Continue')
            alerts.append(N_('Rebasing'))

        elif is_merging:
            msg += '\n\n'
            msg += N_('This repository is in the middle of a merge.\n'
                      'Resolve conflicts and commit changes.')
            alerts.append(N_('Merging'))

        if self.mode == self.model.mode_amend:
            alerts.append(N_('Amending'))

        l = unichr(0xab)
        r = unichr(0xbb)
        title = ('%s: %s %s%s' % (
                    self.model.project,
                    branch,
                    alerts and ((r+' %s '+l+' ') % ', '.join(alerts)) or '',
                    self.model.git.worktree()))

        self.setWindowTitle(title)
        self.commitdockwidget.setToolTip(msg)
        self.commitmsgeditor.set_mode(self.mode)
        self.update_actions()

        if not self.model.amending():
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(merge_msg_path)
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cmds.do(cmds.LoadCommitMessageFromFile, merge_msg_path)
Ejemplo n.º 8
0
 def test_merge_message_path(self):
     """Test merge_message_path()."""
     self.shell("touch .git/SQUASH_MSG")
     self.assertEqual(gitcmds.merge_message_path(), os.path.abspath(".git/SQUASH_MSG"))
     self.shell("touch .git/MERGE_MSG")
     self.assertEqual(gitcmds.merge_message_path(), os.path.abspath(".git/MERGE_MSG"))
     os.unlink(gitcmds.merge_message_path())
     self.assertEqual(gitcmds.merge_message_path(), os.path.abspath(".git/SQUASH_MSG"))
     os.unlink(gitcmds.merge_message_path())
     self.assertEqual(gitcmds.merge_message_path(), None)
Ejemplo n.º 9
0
    def _update_commitmsg(self):
        """Check for git merge message files, or clear it when the merge completes"""
        if self.amending():
            return
        # Check if there's a message file in .git/
        merge_msg_path = gitcmds.merge_message_path()
        if merge_msg_path:
            msg = core.read(merge_msg_path)
            if msg != self._auto_commitmsg:
                self._auto_commitmsg = msg
                self._prev_commitmsg = self.commitmsg
                self.set_commitmsg(msg)

        elif self._auto_commitmsg and self._auto_commitmsg == self.commitmsg:
            self._auto_commitmsg = ''
            self.set_commitmsg(self._prev_commitmsg)
Ejemplo n.º 10
0
    def _update_commitmsg(self):
        """Check for git merge message files, or clear it when the merge completes"""
        if self.amending():
            return
        # Check if there's a message file in .git/
        merge_msg_path = gitcmds.merge_message_path()
        if merge_msg_path:
            msg = core.read(merge_msg_path)
            if msg != self._auto_commitmsg:
                self._auto_commitmsg = msg
                self._prev_commitmsg = self.commitmsg
                self.set_commitmsg(msg)

        elif self._auto_commitmsg and self._auto_commitmsg == self.commitmsg:
            self._auto_commitmsg = ''
            self.set_commitmsg(self._prev_commitmsg)
Ejemplo n.º 11
0
def test_merge_message_path(app_context):
    """Test merge_message_path()."""
    helper.touch('.git/SQUASH_MSG')
    assert gitcmds.merge_message_path(app_context) == os.path.abspath(
        '.git/SQUASH_MSG')
    helper.touch('.git/MERGE_MSG')
    assert gitcmds.merge_message_path(app_context) == os.path.abspath(
        '.git/MERGE_MSG')
    os.unlink(gitcmds.merge_message_path(app_context))
    assert gitcmds.merge_message_path(app_context) == os.path.abspath(
        '.git/SQUASH_MSG')
    os.unlink(gitcmds.merge_message_path(app_context))
    assert gitcmds.merge_message_path(app_context) is None
Ejemplo n.º 12
0
 def test_merge_message_path(self):
     """Test merge_message_path()."""
     self.touch('.git/SQUASH_MSG')
     self.assertEqual(gitcmds.merge_message_path(),
                      os.path.abspath('.git/SQUASH_MSG'))
     self.touch('.git/MERGE_MSG')
     self.assertEqual(gitcmds.merge_message_path(),
                      os.path.abspath('.git/MERGE_MSG'))
     os.unlink(gitcmds.merge_message_path())
     self.assertEqual(gitcmds.merge_message_path(),
                      os.path.abspath('.git/SQUASH_MSG'))
     os.unlink(gitcmds.merge_message_path())
     self.assertEqual(gitcmds.merge_message_path(), None)
Ejemplo n.º 13
0
    def _update_callback(self):
        """Update the title with the current branch and directory name."""
        branch = self.model.currentbranch
        curdir = core.getcwd()
        is_rebasing = self.model.is_rebasing

        msg = N_('Repository: %s') % curdir
        msg += '\n'
        msg += N_('Branch: %s') % branch
        if is_rebasing:
            msg += '\n\n'
            msg += N_('This repository is currently being rebased.\n'
                      'Resolve conflicts, commit changes, and run:\n'
                      '    Rebase > Continue')
        self.commitdockwidget.setToolTip(msg)

        alerts = []
        if is_rebasing:
            alerts.append(N_('Rebasing').upper())
        if self.mode == self.model.mode_amend:
            alerts.append(N_('Amending').upper())

        l = unichr(0xab)
        r = unichr(0xbb)
        title = ('%s: %s %s%s' % (
                    self.model.project,
                    branch,
                    alerts and ((r+' %s '+l+' ') % ', '.join(alerts)) or '',
                    self.model.git.worktree()))
        self.setWindowTitle(title)
        self.commitmsgeditor.set_mode(self.mode)
        self.update_rebase_actions(is_rebasing)

        if not self.model.amending():
            # Check if there's a message file in .git/
            merge_msg_path = gitcmds.merge_message_path()
            if merge_msg_path is None:
                return
            merge_msg_hash = utils.checksum(merge_msg_path)
            if merge_msg_hash == self.merge_message_hash:
                return
            self.merge_message_hash = merge_msg_hash
            cmds.do(cmds.LoadCommitMessageFromFile, merge_msg_path)
Ejemplo n.º 14
0
 def test_merge_message_path(self):
     """Test merge_message_path()."""
     context = self.context
     self.touch('.git/SQUASH_MSG')
     self.assertEqual(gitcmds.merge_message_path(context),
                      os.path.abspath('.git/SQUASH_MSG'))
     self.touch('.git/MERGE_MSG')
     self.assertEqual(gitcmds.merge_message_path(context),
                      os.path.abspath('.git/MERGE_MSG'))
     os.unlink(gitcmds.merge_message_path(context))
     self.assertEqual(gitcmds.merge_message_path(context),
                      os.path.abspath('.git/SQUASH_MSG'))
     os.unlink(gitcmds.merge_message_path(context))
     self.assertEqual(gitcmds.merge_message_path(context), None)