Ejemplo n.º 1
0
    def launch_unified_diff(self):
        """
        Launch diff as a unified diff in a text editor or .diff viewer
        
        """
        
        action = GitAction(
            self.git,
            notification=False,
            run_in_thread=False
        )

        diff_text = action.run_single(
            self.git.diff,
            self.path1,
            self.revision1,
            self.path2,
            self.revision2
        )
        if diff_text is None:
            diff_text = ""

        fh = tempfile.mkstemp("-rabbitvcs-" + str(self.revision1)[:5] + "-" + str(self.revision2)[:5] + ".diff")
        os.write(fh[0], diff_text)
        os.close(fh[0])
        rabbitvcs.util.helper.open_item(fh[1])
Ejemplo n.º 2
0
    def launch_unified_diff(self):
        """
        Launch diff as a unified diff in a text editor or .diff viewer
        
        """
        
        action = GitAction(
            self.git,
            notification=False,
            run_in_thread=False
        )

        diff_text = action.run_single(
            self.git.diff,
            self.path1,
            self.revision1,
            self.path2,
            self.revision2
        )
        if diff_text is None:
            diff_text = ""

        fh = tempfile.mkstemp("-rabbitvcs-" + str(self.revision1)[:5] + "-" + str(self.revision2)[:5] + ".diff")
        os.write(fh[0], diff_text)
        os.close(fh[0])
        rabbitvcs.util.helper.open_item(fh[1])
Ejemplo n.º 3
0
    def launch_sidebyside_diff(self):
        """
        Launch diff as a side-by-side comparison using our comparison tool
        
        """
        
        action = GitAction(
            self.git,
            notification=False,
            run_in_thread=False
        )
        
        if self.revision1.kind != "WORKING":
            dest1 = self._build_export_path(1, self.revision1, self.path1)
            self.save_diff_to_file(dest1, action.run_single(
                self.git.show, 
                self.path1,
                self.revision1
            ))
        else:
            dest1 = self.path1

        if self.revision2.kind != "WORKING":
            dest2 = self._build_export_path(2, self.revision2, self.path2)
            self.save_diff_to_file(dest2, action.run_single(
                self.git.show, 
                self.path2,
                self.revision2
            ))
        else:
            dest2 = self.path2

        rabbitvcs.util.helper.launch_diff_tool(dest1, dest2)
Ejemplo n.º 4
0
    def on_ok_clicked(self, widget):
        url = self.repositories.get_active_text()
        path = self._get_path()

        if not url or not path:
            MessageBox(
                _("The repository URL and destination path are both required fields."
                  ))
            return

        if url.startswith("file://"):
            url = self._parse_path(url)

        # Cannot do:
        # url = os.path.normpath(url)
        # ...in general, since it might be eg. an http URL. Doesn't seem to
        # affect pySvn though.

        path = os.path.normpath(path)
        revision = self.revision_selector.get_revision_object()

        self.hide()
        self.action = GitAction(self.git,
                                register_gtk_quit=self.gtk_quit_is_set())

        self.action.append(self.action.set_header, _("Export"))
        self.action.append(self.action.set_status,
                           _("Running Export Command..."))
        self.action.append(rabbitvcs.util.helper.save_repository_path, url)
        self.action.append(self.git.export, url, path, revision=revision)
        self.action.append(self.action.set_status, _("Completed Export"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 5
0
    def launch_sidebyside_diff(self):
        """
        Launch diff as a side-by-side comparison using our comparison tool
        
        """
        
        action = GitAction(
            self.git,
            notification=False,
            run_in_thread=False
        )
        
        if self.revision1.kind != "WORKING":
            dest1 = self._build_export_path(1, self.revision1, self.path1)
            self.save_diff_to_file(dest1, action.run_single(
                self.git.show, 
                self.path1,
                self.revision1
            ))
        else:
            dest1 = self.path1

        if self.revision2.kind != "WORKING":
            dest2 = self._build_export_path(2, self.revision2, self.path2)
            self.save_diff_to_file(dest2, action.run_single(
                self.git.show, 
                self.path2,
                self.revision2
            ))
        else:
            dest2 = self.path2

        rabbitvcs.util.helper.launch_diff_tool(dest1, dest2)
Ejemplo n.º 6
0
    def on_ok_clicked(self, widget, data=None):
        self.hide()
        merge = self.get_widget("merge").get_active()

        repository = self.repository_selector.repository_opt.get_active_text()
        branch = self.repository_selector.branch_opt.get_active_text()
        fetch_all = self.get_widget("all").get_active()
    
        self.action = GitAction(
            self.git,
            register_gtk_quit=self.gtk_quit_is_set()
        )
        self.action.append(self.action.set_header, _("Update"))
        self.action.append(self.action.set_status, _("Updating..."))
        if fetch_all:
            if merge:
                self.action.append(self.git.pull, "--all")
            else:   
                self.action.append(self.git.fetch, "--all")
        else: 
            if merge:
                self.action.append(self.git.pull, repository, branch)
            else:
                self.action.append(self.git.fetch, repository, branch)
                
        self.action.append(self.action.set_status, _("Completed Update"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 7
0
    def load(self):
        to_rev = self.git.revision(self.get_widget("to").get_text())

        self.action = GitAction(self.git, notification=False)

        self.action.append(self.git.annotate, self.path, to_rev)
        self.action.append(self.populate_table)
        self.action.append(self.enable_saveas)
        self.action.start()
Ejemplo n.º 8
0
 def pop(self):
     self.action = GitAction(self.git,
                             notification=self.show,
                             run_in_thread=False)
     self.action.append(self.git.stash, cmd="pop", num=None)
     if self.show:
         self.action.append(self.action.finish)
     self.action.schedule()
     self.action_refresh()
Ejemplo n.º 9
0
    def load(self):
        self.set_loading(True)

        # Load log.
        self.action = GitAction(self.git,
                                notification=False,
                                run_in_thread=True)

        self.action.append(self.refresh)
        self.action.schedule()
Ejemplo n.º 10
0
 def clear(self):
     self.selected_row = None
     self.action = GitAction(self.git,
                             notification=self.show,
                             run_in_thread=False)
     self.action.append(self.git.stash, cmd="clear", num=None)
     if self.show:
         self.action.append(self.action.finish)
     self.action.schedule()
     self.action_refresh()
Ejemplo n.º 11
0
    def __init__(self, path):
        self.vcs = rabbitvcs.vcs.VCS()
        self.git = self.vcs.git()
        self.path = path

        self.action = GitAction(self.git, register_gtk_quit=True)

        self.action.append(self.action.set_header, _("Initialize Repository"))
        self.action.append(self.action.set_status,
                           _("Setting up repository..."))
        self.action.append(self.git.initialize_repository, self.path)
        self.action.append(self.action.set_status,
                           _("Completed repository setup"))
        self.action.append(self.action.finish)
        self.action.schedule()
Ejemplo n.º 12
0
    def apply(self):
        if len(self.revisions_table.get_selected_rows()):
            selected_row = self.revisions_table.get_selected_rows()[0]
            self.selected_row = selected_row
        else:
            selected_row = None

        self.action = GitAction(self.git,
                                notification=self.show,
                                run_in_thread=False)
        self.action.append(self.git.stash, cmd="apply", num=selected_row)
        if self.show:
            self.action.append(self.action.finish)
        self.action.schedule()
        self.action_refresh()
Ejemplo n.º 13
0
    def stash(self):
        msg = self.message.get_text()
        if self.message.get_text() == "":
            msg = None
        self.action = GitAction(self.git,
                                notification=self.show,
                                run_in_thread=False)

        self.action.append(self.git.stash, cmd="save", msg=msg)

        if self.show:
            self.action.append(self.action.finish)
        self.action.schedule()
        self.action_refresh()
        self.message.set_text("")
Ejemplo n.º 14
0
    def load(self, revision):
        self.launch_loading()

        self.action = GitAction(self.git, notification=False)

        self.action.append(self.git.annotate, self.path,
                           self.git.revision(revision))

        if not self.log_by_order:
            self.action.append(self.git.log, self.path)
            self.action.append(self.set_log)

        self.action.append(self.populate_table)
        self.action.append(self.enable_saveas)
        self.action.schedule()
        self.kill_loading()
Ejemplo n.º 15
0
    def on_ok_clicked(self, widget, data=None):
        self.hide()

        rebase = self.get_widget("rebase").get_active()

        git_function_params = []

        apply_changes = self.get_widget("apply_changes").get_active()

        repository = self.repository_selector.repository_opt.get_active_text()
        branch = self.repository_selector.branch_opt.get_active_text()
        fetch_all = self.get_widget("all").get_active()

        self.action = GitAction(
            self.git,
            register_gtk_quit=self.gtk_quit_is_set()
        )
        self.action.append(self.action.set_header, _("Update"))
        self.action.append(self.action.set_status, _("Updating..."))

        if not apply_changes:
            if fetch_all:
                self.action.append(self.git.fetch, "--all")
            else:
                self.action.append(self.git.fetch, repository, branch)

        else:
            if rebase:
                git_function_params.append ("rebase")

            if fetch_all:
                git_function_params.append ("all")
                repository = ""
                branch = ""

            self.action.append(self.git.pull, repository, branch, git_function_params)

        self.action.append(self.action.set_status, _("Completed Update"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 16
0
    def __init__(self, paths):
        InterfaceView.__init__(self, "git-update", "Update")

        self.paths = paths
        self.vcs = rabbitvcs.vcs.VCS()
        self.git = self.vcs.git(paths[0])
        self.git_svn = self.git.client.git_svn

        if self.git_svn:
            self.hide()
            self.do_gtk_quit = True
            self.action = GitAction(self.git,
                                    register_gtk_quit=self.gtk_quit_is_set())
            self.action.append(self.action.set_header, _("Update"))
            self.action.append(self.action.set_status, _("Updating..."))
            self.action.append(self.git.git_svn_update)
            self.action.append(self.action.set_status, _("Completed Update"))
            self.action.append(self.action.finish)
            self.action.schedule()
        else:
            self.repository_selector = rabbitvcs.ui.widget.GitRepositorySelector(
                self.get_widget("repository_container"), self.git)
Ejemplo n.º 17
0
 def __init__(self, path):
     self.vcs = rabbitvcs.vcs.VCS()
     self.git = self.vcs.git()
     self.path = path
     
     self.action = GitAction(
         self.git,
         register_gtk_quit=True
     )
     
     self.action.append(self.action.set_header, _("Initialize Repository"))
     self.action.append(self.action.set_status, _("Setting up repository..."))
     self.action.append(self.git.initialize_repository, self.path)
     self.action.append(self.action.set_status, _("Completed repository setup"))
     self.action.append(self.action.finish)
     self.action.start()
Ejemplo n.º 18
0
    def load(self):
        to_rev = self.git.revision(self.get_widget("to").get_text())
        
        self.action = GitAction(
            self.git,
            notification=False
        )    

        self.action.append(
            self.git.annotate,
            self.path,
            to_rev
        )
        self.action.append(self.populate_table)
        self.action.append(self.enable_saveas)
        self.action.start()
Ejemplo n.º 19
0
    def on_ok_clicked(self, widget, data=None):
        self.hide()

        rebase = self.get_widget("rebase").get_active()

        git_function_params = []

        apply_changes = self.get_widget("apply_changes").get_active()

        repository = self.repository_selector.repository_opt.get_active_text()
        branch = self.repository_selector.branch_opt.get_active_text()
        fetch_all = self.get_widget("all").get_active()

        self.action = GitAction(
            self.git,
            register_gtk_quit=self.gtk_quit_is_set()
        )
        self.action.append(self.action.set_header, _("Update"))
        self.action.append(self.action.set_status, _("Updating..."))

        if not apply_changes:
            if fetch_all:
                self.action.append(self.git.fetch, "--all")
            else:
                self.action.append(self.git.fetch, repository, branch)

        else:
            if rebase:
                git_function_params.append ("rebase")

            if fetch_all:
                git_function_params.append ("all")
                repository = ""
                branch = ""

            self.action.append(self.git.pull, repository, branch, git_function_params)

        self.action.append(self.action.set_status, _("Completed Update"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 20
0
    def on_ok_clicked(self, widget):
        url = self.repositories.get_active_text()
        path = self._get_path()

        if not url or not path:
            MessageBox(_("The repository URL and destination path are both required fields."))
            return
        
        if url.startswith("file://"):
            url = self._parse_path(url)
        
        # Cannot do:
        # url = os.path.normpath(url)
        # ...in general, since it might be eg. an http URL. Doesn't seem to
        # affect pySvn though.
        
        path = os.path.normpath(path)        
        revision = self.revision_selector.get_revision_object()

        self.hide()
        self.action = GitAction(
            self.git,
            register_gtk_quit=self.gtk_quit_is_set()
        )
        
        self.action.append(self.action.set_header, _("Export"))
        self.action.append(self.action.set_status, _("Running Export Command..."))
        self.action.append(rabbitvcs.util.helper.save_repository_path, url)
        self.action.append(
            self.git.export,
            url,
            path,
            revision=revision
        )
        self.action.append(self.action.set_status, _("Completed Export"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 21
0
class GitExport(GitClone):
    def __init__(self, path=None, revision=None):

        self.vcs = rabbitvcs.vcs.VCS()
        self.git = None
        guess = rabbitvcs.vcs.guess(path)
        if guess["vcs"] == rabbitvcs.vcs.VCS_GIT:
            self.git = self.vcs.git(path)
            export_to = ""
            export_from = path
        else:
            export_to = path
            export_from = ""

        GitClone.__init__(self, export_to, export_from)

        self.get_widget("Checkout").set_title(_("Export - %s") % path)

        self.revision_selector = rabbitvcs.ui.widget.RevisionSelector(
            self.get_widget("revision_container"),
            self.git,
            revision=revision,
            url_combobox=self.repositories,
            expand=True
        )

        self.get_widget("revision_selector_box").show()

    def on_ok_clicked(self, widget):
        url = self.repositories.get_active_text()
        path = self._get_path()

        if not url or not path:
            MessageBox(_("The repository URL and destination path are both required fields."))
            return
        
        if url.startswith("file://"):
            url = self._parse_path(url)
        
        # Cannot do:
        # url = os.path.normpath(url)
        # ...in general, since it might be eg. an http URL. Doesn't seem to
        # affect pySvn though.
        
        path = os.path.normpath(path)        
        revision = self.revision_selector.get_revision_object()

        self.hide()
        self.action = GitAction(
            self.git,
            register_gtk_quit=self.gtk_quit_is_set()
        )
        
        self.action.append(self.action.set_header, _("Export"))
        self.action.append(self.action.set_status, _("Running Export Command..."))
        self.action.append(rabbitvcs.util.helper.save_repository_path, url)
        self.action.append(
            self.git.export,
            url,
            path,
            revision=revision
        )
        self.action.append(self.action.set_status, _("Completed Export"))
        self.action.append(self.action.finish)
        self.action.start()

    def on_repositories_changed(self, widget, data=None):
        # Do not use quoting for this bit
        url = self.repositories.get_active_text()
        tmp = url.replace("//", "/").split("/")[1:]
        append = ""
        prev = ""
        while len(tmp):
            prev = append
            append = tmp.pop()
            if append not in ("trunk", "branches", "tags"):
                break
                
            if append in ("http:", "https:", "file:", "svn:", "svn+ssh:"):
                append = ""
                break
        
        self.get_widget("destination").set_text(
            os.path.join(self.destination, append)
        )
        
        self.check_form()
Ejemplo n.º 22
0
class GitUpdate(InterfaceView):
    """
    This class provides an interface to generate an "update".
    Pass it a path and it will start an update, running the notification dialog.  
    There is no glade .
    
    """

    def __init__(self, paths):
        InterfaceView.__init__(self, "git-update", "Update")

        self.paths = paths
        self.vcs = rabbitvcs.vcs.VCS()
        self.git = self.vcs.git(paths[0])

        self.repository_selector = rabbitvcs.ui.widget.GitRepositorySelector(
            self.get_widget("repository_container"),
            self.git
        )
        
    def on_apply_changes_toggled(self, widget, data=None):
        self.get_widget("merge").set_sensitive(self.get_widget("apply_changes").get_active())
        self.get_widget("rebase").set_sensitive(self.get_widget("apply_changes").get_active())

    def on_ok_clicked(self, widget, data=None):
        self.hide()

        rebase = self.get_widget("rebase").get_active()

        git_function_params = []

        apply_changes = self.get_widget("apply_changes").get_active()

        repository = self.repository_selector.repository_opt.get_active_text()
        branch = self.repository_selector.branch_opt.get_active_text()
        fetch_all = self.get_widget("all").get_active()

        self.action = GitAction(
            self.git,
            register_gtk_quit=self.gtk_quit_is_set()
        )
        self.action.append(self.action.set_header, _("Update"))
        self.action.append(self.action.set_status, _("Updating..."))

        if not apply_changes:
            if fetch_all:
                self.action.append(self.git.fetch, "--all")
            else:
                self.action.append(self.git.fetch, repository, branch)

        else:
            if rebase:
                git_function_params.append ("rebase")

            if fetch_all:
                git_function_params.append ("all")
                repository = ""
                branch = ""

            self.action.append(self.git.pull, repository, branch, git_function_params)

        self.action.append(self.action.set_status, _("Completed Update"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 23
0
class GitStash(Stash):
    def __init__(self, path):
        Stash.__init__(self, path)

        self.git = self.vcs.git(path)
        self.git_svn = self.git.client.git_svn
        self.path = self.git.find_repository_path(path)

        self.revisions_table = rabbitvcs.ui.widget.Table(
            self.get_widget("revisions_table"),
            [GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING],
            [_("Num"), _("Revision"), _("Message")],
            filters=[{
                "callback": rabbitvcs.ui.widget.git_revision_filter,
                "user_data": {
                    "column": 0
                }
            }],
            callbacks={
                "mouse-event": self.on_revisions_table_mouse_event,
            })

        self.path_table = rabbitvcs.ui.widget.Table(
            self.get_widget("path_table"),
            [GObject.TYPE_STRING, GObject.TYPE_STRING],
            [_("Num"), _("File")],
            filters=[{
                "callback": rabbitvcs.ui.widget.git_revision_filter,
                "user_data": {
                    "column": 0
                }
            }])
        self.get_widget("root").set_markup("<i>- Base : {}</i>".format(
            self.path))

        self.message = rabbitvcs.ui.widget.TextView(
            self.get_widget("message"),
            self.SETTINGS.get_multiline("general", "default_commit_message"))

        self.items = []
        self.load()
        self.show = False
        self.selected_row = None
        self.total_row = 0

    def should_item_be_visible(self, item):
        show_unversioned = self.SHOW_UNVERSIONED

        if not show_unversioned:
            if not item.is_versioned():
                return False

        return True

    def set_item(self):
        self.path_table.clear()
        self.items = []
        for item in self.vcs.get_items([self.path],
                                       self.vcs.statuses_for_commit(
                                           [self.path])):
            if not self.should_item_be_visible(item):
                continue
            self.items.append(item.path)

        i = 1
        for item in self.items:
            idx = item.find(self.path) + len(self.path)
            self.path_table.append([i, item[idx + 1:]])
            i += 1

        if i > 2:
            self.get_widget("scrolledwindow2").set_property("vexpand", True)
        else:
            self.get_widget("scrolledwindow2").set_property("vexpand", False)

    def refresh(self):
        self.revisions_table.clear()
        stash_list = self.git.get_stash_list()

        self.total_row = 0
        for org_msg in stash_list:
            start_idx = org_msg.find("stash@{")
            end_idx = org_msg.find("}: ")
            revision = org_msg[:start_idx]
            num = org_msg[start_idx + len("stash@{"):end_idx]
            msg = org_msg[end_idx + len("}: "):]

            self.revisions_table.append([num, revision, msg])
            self.total_row += 1

        self.set_item()
        self.set_loading(False)

    def action_refresh(self):
        self.action = GitAction(self.git,
                                notification=False,
                                run_in_thread=True)
        self.action.append(self.refresh)
        self.action.schedule()

    def load(self):
        self.set_loading(True)

        # Load log.
        self.action = GitAction(self.git,
                                notification=False,
                                run_in_thread=True)

        self.action.append(self.refresh)
        self.action.schedule()

    def stash(self):
        msg = self.message.get_text()
        if self.message.get_text() == "":
            msg = None
        self.action = GitAction(self.git,
                                notification=self.show,
                                run_in_thread=False)

        self.action.append(self.git.stash, cmd="save", msg=msg)

        if self.show:
            self.action.append(self.action.finish)
        self.action.schedule()
        self.action_refresh()
        self.message.set_text("")

    def drop(self):
        if len(self.revisions_table.get_selected_rows()):
            selected_row = self.revisions_table.get_selected_rows()[0]
            self.selected_row = selected_row
        else:
            selected_row = 0
            self.selected_row = None
        self.action = GitAction(self.git,
                                notification=self.show,
                                run_in_thread=False)
        self.action.append(self.git.stash, cmd="drop", num=selected_row)
        if self.show:
            self.action.append(self.action.finish)
        self.action.schedule()
        self.action_refresh()

    def clear(self):
        self.selected_row = None
        self.action = GitAction(self.git,
                                notification=self.show,
                                run_in_thread=False)
        self.action.append(self.git.stash, cmd="clear", num=None)
        if self.show:
            self.action.append(self.action.finish)
        self.action.schedule()
        self.action_refresh()

    def apply(self):
        if len(self.revisions_table.get_selected_rows()):
            selected_row = self.revisions_table.get_selected_rows()[0]
            self.selected_row = selected_row
        else:
            selected_row = None

        self.action = GitAction(self.git,
                                notification=self.show,
                                run_in_thread=False)
        self.action.append(self.git.stash, cmd="apply", num=selected_row)
        if self.show:
            self.action.append(self.action.finish)
        self.action.schedule()
        self.action_refresh()

    def pop(self):
        self.action = GitAction(self.git,
                                notification=self.show,
                                run_in_thread=False)
        self.action.append(self.git.stash, cmd="pop", num=None)
        if self.show:
            self.action.append(self.action.finish)
        self.action.schedule()
        self.action_refresh()

    def on_stash_clicked(self, widget, data=None):
        self.stash()

    def on_drop_clicked(self, widget, data=None):
        if len(self.revisions_table.get_selected_rows()) == self.total_row:
            self.clear()
        else:
            self.drop()
            if self.selected_row:
                self.revisions_table.focus(self.selected_row, 0)
                if len(self.revisions_table.get_selected_rows()) == 0:
                    self.revisions_table.focus(self.selected_row - 1, 0)

    def on_apply_clicked(self, widget, data=None):
        self.apply()
        if self.selected_row:
            self.revisions_table.focus(self.selected_row, 0)

    def on_pop_clicked(self, widget, data=None):
        self.pop()

    def on_toggle_notify(self, widget, data=None):
        self.show = widget.get_active()
Ejemplo n.º 24
0
class GitCreate:
    # Also, might want to just launch a terminal window instead of this
    def __init__(self, path):
        self.vcs = rabbitvcs.vcs.VCS()
        self.git = self.vcs.git()
        self.path = path
        
        self.action = GitAction(
            self.git,
            register_gtk_quit=True
        )
        
        self.action.append(self.action.set_header, _("Initialize Repository"))
        self.action.append(self.action.set_status, _("Setting up repository..."))
        self.action.append(self.git.initialize_repository, self.path)
        self.action.append(self.action.set_status, _("Completed repository setup"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 25
0
class GitUpdate(InterfaceView):
    """
    This class provides an interface to generate an "update".
    Pass it a path and it will start an update, running the notification dialog.
    There is no glade .

    """
    def __init__(self, paths):
        InterfaceView.__init__(self, "git-update", "Update")

        self.paths = paths
        self.vcs = rabbitvcs.vcs.VCS()
        self.git = self.vcs.git(paths[0])

        self.repository_selector = rabbitvcs.ui.widget.GitRepositorySelector(
            self.get_widget("repository_container"), self.git)

    def on_apply_changes_toggled(self, widget, data=None):
        self.get_widget("merge").set_sensitive(
            self.get_widget("apply_changes").get_active())
        self.get_widget("rebase").set_sensitive(
            self.get_widget("apply_changes").get_active())

    def on_ok_clicked(self, widget, data=None):
        self.hide()

        rebase = self.get_widget("rebase").get_active()

        git_function_params = []

        apply_changes = self.get_widget("apply_changes").get_active()

        repository = self.repository_selector.repository_opt.get_active_text()
        branch = self.repository_selector.branch_opt.get_active_text()
        fetch_all = self.get_widget("all").get_active()

        self.action = GitAction(self.git,
                                register_gtk_quit=self.gtk_quit_is_set(),
                                run_in_thread=False)
        self.action.append(self.action.set_header, _("Update"))
        self.action.append(self.action.set_status, _("Updating..."))

        if apply_changes:
            if rebase:
                git_function_params.append("rebase")

            if fetch_all:
                git_function_params.append("all")
                repository = ""
                branch = ""

            self.action.append(self.git.pull, repository, branch,
                               git_function_params)
        else:
            if fetch_all:
                self.action.append(self.git.fetch_all)
            else:
                self.action.append(self.git.fetch, repository, branch)

        self.action.append(self.action.set_status, _("Completed Update"))
        self.action.append(self.action.finish)
        self.action.schedule()
Ejemplo n.º 26
0
 def action_refresh(self):
     self.action = GitAction(self.git,
                             notification=False,
                             run_in_thread=True)
     self.action.append(self.refresh)
     self.action.schedule()
Ejemplo n.º 27
0
class GitUpdate(InterfaceView):
    """
    This class provides an interface to generate an "update".
    Pass it a path and it will start an update, running the notification dialog.  
    There is no glade .
    
    """

    def __init__(self, paths):
        InterfaceView.__init__(self, "git-update", "Update")

        self.paths = paths
        self.vcs = rabbitvcs.vcs.VCS()
        self.git = self.vcs.git(paths[0])

        self.repository_selector = rabbitvcs.ui.widget.GitRepositorySelector(
            self.get_widget("repository_container"),
            self.git
        )

    def on_destroy(self, widget):
        self.destroy()
        
    def on_cancel_clicked(self, widget, data=None):
        self.close()

    def on_ok_clicked(self, widget, data=None):
        self.hide()
        merge = self.get_widget("merge").get_active()

        repository = self.repository_selector.repository_opt.get_active_text()
        branch = self.repository_selector.branch_opt.get_active_text()
    
        self.action = GitAction(
            self.git,
            register_gtk_quit=self.gtk_quit_is_set()
        )
        self.action.append(self.action.set_header, _("Update"))
        self.action.append(self.action.set_status, _("Updating..."))
        if merge:
            self.action.append(self.git.pull, repository, branch)
        else:
            self.action.append(self.git.fetch, repository, branch)
        self.action.append(self.action.set_status, _("Completed Update"))
        self.action.append(self.action.finish)
        self.action.start()
Ejemplo n.º 28
0
class GitAnnotate(Annotate):
    def __init__(self, path, revision=None):
        Annotate.__init__(self, path, revision)

        self.git = self.vcs.git(path)

        if revision is None:
            revision = "HEAD"
        
        self.path = path
        self.get_widget("from_revision_container").hide()
        self.get_widget("to_show_log").hide()
        self.get_widget("to").set_text(str(revision))

        self.table = rabbitvcs.ui.widget.Table(
            self.get_widget("table"),
            [gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, 
                gobject.TYPE_STRING, gobject.TYPE_STRING], 
            [_("Line"), _("Revision"), _("Author"), 
                _("Date"), _("Text")]
        )
        self.table.allow_multiple()
        
        self.load()

    #
    # Helper methods
    #
    
    def load(self):
        to_rev = self.git.revision(self.get_widget("to").get_text())
        
        self.action = GitAction(
            self.git,
            notification=False
        )    

        self.action.append(
            self.git.annotate,
            self.path,
            to_rev
        )
        self.action.append(self.populate_table)
        self.action.append(self.enable_saveas)
        self.action.start()

    @gtk_unsafe
    def populate_table(self):
        blamedict = self.action.get_result(0)

        self.table.clear()
        for item in blamedict:
            self.table.append([
                item["number"],
                item["revision"][:7],
                item["author"],
                rabbitvcs.util.helper.format_datetime(item["date"]),
                item["line"]
            ])
            
    def generate_string_from_result(self):
        blamedict = self.action.get_result(0)
        
        text = ""
        for item in blamedict:
            text += "%s\t%s\t%s\t%s\t%s\n" % (
                item["number"],
                item["revision"][:7],
                item["author"],
                rabbitvcs.util.helper.format_datetime(item["date"]),
                item["line"]
            )
        
        return text
Ejemplo n.º 29
0
class GitAnnotate(Annotate):
    def __init__(self, path, revision=None):
        Annotate.__init__(self, path, revision)

        self.git = self.vcs.git(path)

        if revision is None:
            revision = "HEAD"

        self.path = path
        self.get_widget("to").set_text(str(revision))

        self.table = rabbitvcs.ui.widget.Table(self.get_widget("table"), [
            GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING,
            GObject.TYPE_STRING, GObject.TYPE_STRING
        ], [_("Line"),
            _("Revision"),
            _("Author"),
            _("Date"),
            _("Text")])
        self.table.allow_multiple()

        self.load()

    #
    # Helper methods
    #

    def launch_loading(self):
        self.loading_dialog = Loading()
        GLib.idle_add(self.loading_dialog.run)

    def kill_loading(self):
        GLib.idle_add(self.loading_dialog.destroy)

    def load(self):
        to_rev = self.git.revision(self.get_widget("to").get_text())

        self.launch_loading()

        self.action = GitAction(self.git, notification=False)

        self.action.append(self.git.annotate, self.path, to_rev)
        self.action.append(self.populate_table)
        self.action.append(self.enable_saveas)
        self.action.schedule()
        self.kill_loading()

    @gtk_unsafe
    def populate_table(self):
        blamedict = self.action.get_result(0)

        self.table.clear()
        for item in blamedict:
            self.table.append([
                str(item["number"]), item["revision"][:7], item["author"],
                rabbitvcs.util.helper.format_datetime(item["date"]),
                item["line"]
            ])

    def generate_string_from_result(self):
        blamedict = self.action.get_result(0)

        text = ""
        for item in blamedict:
            text += "%s\t%s\t%s\t%s\t%s\n" % (
                str(item["number"]), item["revision"][:7], item["author"],
                rabbitvcs.util.helper.format_datetime(
                    item["date"]), item["line"])

        return text
Ejemplo n.º 30
0
class GitAnnotate(Annotate):
    def __init__(self, path, revision=None):
        Annotate.__init__(self, path, revision)
        self.git = self.vcs.git(path)
        self.path = path
        self.show_revision(forceload=True)

    #
    # Helper methods
    #

    def launch_loading(self):
        self.loading_dialog = Loading()
        GLib.idle_add(self.loading_dialog.run)

    def kill_loading(self):
        GLib.idle_add(self.loading_dialog.destroy)

    def load(self, revision):
        self.launch_loading()

        self.action = GitAction(self.git, notification=False)

        self.action.append(self.git.annotate, self.path,
                           self.git.revision(revision))

        if not self.log_by_order:
            self.action.append(self.git.log, self.path)
            self.action.append(self.set_log)

        self.action.append(self.populate_table)
        self.action.append(self.enable_saveas)
        self.action.schedule()
        self.kill_loading()

    def populate_table(self):
        blamedict = self.action.get_result(0)
        lines = highlight(self.path, [item["line"] for item in blamedict])

        self.table.clear()
        for i, item in enumerate(blamedict):
            revision = item["revision"][:7]
            author = S(item["author"].strip())
            author_color = self.author_background.get(author, "#FFFFFF")
            try:
                revision_color = self.log_by_revision[revision].background
            except KeyError:
                revision_color = "#FFFFFF"

            self.table.append([
                revision, author,
                helper.format_datetime(item["date"], self.datetime_format),
                str(item["number"]), lines[i], revision_color, author_color
            ])

    def generate_string_from_result(self):
        blamedict = self.action.get_result(0)

        text = ""
        for item in blamedict:
            text += "%s\t%s\t%s\t%s\t%s\n" % (
                str(item["number"]), item["revision"][:7], item["author"],
                helper.format_datetime(item["date"],
                                       self.datetime_format), item["line"])

        return text

    def short_revision(self, revision):
        revision = str(revision)[:7].lower()
        return revision if revision != "head" else "HEAD"
Ejemplo n.º 31
0
class GitCreate(object):
    # Also, might want to just launch a terminal window instead of this
    def __init__(self, path):
        self.vcs = rabbitvcs.vcs.VCS()
        self.git = self.vcs.git()
        self.path = path

        self.action = GitAction(
            self.git,
            register_gtk_quit=True
        )

        self.action.append(self.action.set_header, _("Initialize Repository"))
        self.action.append(self.action.set_status, _("Setting up repository..."))
        self.action.append(self.git.initialize_repository, self.path)
        self.action.append(self.action.set_status, _("Completed repository setup"))
        self.action.append(self.action.finish)
        self.action.schedule()