def HgSync(repo, frame, rev=None, insecure=True, do_pull=True): status = repo.Local repo.SwitchToRemote() if repo.User == '': dlg = UserPassDlg(frame) dlg.DlgLabel = _("Code repository account:") if dlg.ShowModal() == wx.ID_OK: repo.User = dlg.txtUname.GetValue() repo.Password = dlg.txtPassword.GetValue() Profile_Set('HG_USER', repo.User) Profile_Set('HG_PASSWD', repo.Password) repo.reopen() dlg.Destroy() # and now - time to pull remote_repo = Profile_Get('HG_REPOSITORY') if remote_repo is None: remote_repo = repo.Repo.paths().get('default') if remote_repo is None: remote_repo = repo.Repo.paths().get('default-push') if remote_repo is None: dlg = wx.TextEntryDialog(frame, _("Code repository URL:"), _('Push')) if dlg.ShowModal() == wx.ID_OK and dlg.GetValue() != '': remote_repo = dlg.GetValue() Profile_Set('HG_REPOSITORY', remote_repo) dlg.Destroy() if remote_repo is not None: repo.sync(remote_repo, rev=rev, insecure=insecure, do_pull=do_pull) if status: repo.SwitchToLocal()
def OnOK(self, event): data = self.txtURL.GetValue() Profile_Set('HG_REPOSITORY', data) data = self.txtUname.GetValue() Profile_Set('HG_USER', data) data = self.txtPasswd.GetValue() Profile_Set('HG_PASSWD', data) event.Skip()
def SetShellTheme(self, style): """Set the color scheme used by the shell @param style: style sheet name (string) """ self._shell_style = style Profile_Set(PYSHELL_STYLE, style) self.UpdateAllStyles(style)
def ClosePage(self, idx): """ClosePage(self, idx) Closes notebook page by index. May be used in user scripts. """ pg = self.nbook.GetPage(idx) if pg.Tag == 'Console': self.nbook.RemovePage(idx) self.shell.Hide() Profile_Set('SHOW_CONSOLE', False) else: self.nbook.DeletePage(idx)
def OnContextMenu(self, event): upd = False if event.GetId() == self.ID_ViewExplorer: upd = True p = self._mgr.GetPane('explorer') if p.IsShown(): self._mgr.ClosePane(p) else: p.Show() elif event.GetId() == self.ID_ViewProps: upd = True p = self._mgr.GetPane('props') if p.IsShown(): self._mgr.ClosePane(p) else: p.Show() elif event.GetId() == self.ID_ViewLogger: upd = True p = self._mgr.GetPane('logger') if p.IsShown(): self._mgr.ClosePane(p) else: p.Show() elif event.GetId() == self.ID_ViewConsole: present = False for idx in range(self.nbook.GetPageCount()): pg = self.nbook.GetPage(idx) if pg.Tag == 'Console': self.ClosePage(idx) Profile_Set('SHOW_CONSOLE', False) present = True break self.nbook.Update() if not present and Profile_Get('ALLOW_CONSOLE', 'bool', True): self.shell.Show() self.AddTab(self.shell, self.shell.Title) Profile_Set('SHOW_CONSOLE', True) if upd: self._mgr.Update()
def DoSaveWorld(self, event): if event.GetId() == self.ID_SaveWorldAs: dlg = wx.FileDialog(self, wildcard="DECA files|*.deca|All files|*.*", style=wx.FD_SAVE) if dlg.ShowModal() == wx.ID_OK: fname = dlg.Path if os.path.splitext(fname)[1].lower() != '.deca': fname += '.deca' dlg.Destroy() else: dlg.Destroy() return else: fname = None if Deca.world.Initial: # request filename dlg = wx.FileDialog(self, wildcard="DECA files|*.deca|All files|*.*", style=wx.FD_SAVE) if dlg.ShowModal() == wx.ID_OK: fname = dlg.Path if os.path.splitext(fname)[1].lower() != '.deca': fname += '.deca' dlg.Destroy() else: dlg.Destroy() return profiler.TheProfile.Write(Profile_Get('MYPROFILE')) # save window position Profile_Set('WINDOW_POS', self.GetPositionTuple()) Profile_Set('WINDOW_SIZE', self.GetSizeTuple()) Profile_Set('WINDOW_STATE', self.IsMaximized()) Profile_Set('WINDOW_LAYOUT', self._mgr.SavePerspective()) Profile_Set('HG_USER', Deca.world.HgRepository.User) Profile_Set('HG_PASSWD', Deca.world.HgRepository.Password) Profile_Set('HG_AUTOFILES', Deca.world.HgRepository.AddRemove) # save open tabs pg_list = [] active_idx = self.nbook.GetSelection() for idx in range(self.nbook.GetPageCount()): pg = self.nbook.GetPage(idx) if pg.Tag != "Console": pg_list.append((pg.Tag, pg.GetParams(), idx == active_idx)) Profile_Set('VIEW_PAGES', pg_list) Deca.world.Save(fname) self.SetTitle( _('[%s] - Sampo Framework') % os.path.basename(Deca.world.Filename))
def OnCommit(self, event): event.GetId() if not Deca.world.HgRepository.IsWdChanged: return if Deca.world.HgRepository.User == '': dlg = UserPassDlg(self) dlg.Label = _("Code repository account:") if dlg.ShowModal() == wx.ID_OK: Deca.world.HgRepository.User = dlg.txtUname.GetValue() Deca.world.HgRepository.Password = dlg.txtPassword.GetValue() Profile_Set('HG_USER', Deca.world.HgRepository.User) Profile_Set('HG_PASSWD', Deca.world.HgRepository.Password) Deca.world.HgRepository.reopen() dlg = wx.TextEntryDialog(self, _("Describe revision:"),_('Commit')) dlg.SetValue("Auto-commit") if dlg.ShowModal() == wx.ID_OK and dlg.GetValue() != '': try: Deca.world.HgRepository.commit(dlg.GetValue()) except Exception as cond: wx.GetApp().log("[SourceControl] err: %s" % cond) # committed self.FillRepoView()
def HgPush(repo, frame, force=False, insecure=True): status = repo.Local repo.SwitchToLocal() message = '' if repo.User == '': dlg = UserPassDlg(frame) dlg.DlgLabel = _("Code repository account:") if dlg.ShowModal() == wx.ID_OK: repo.User = dlg.txtUname.GetValue() repo.Password = dlg.txtPassword.GetValue() Profile_Set('HG_USER', repo.User) Profile_Set('HG_PASSWD', repo.Password) repo.reopen() dlg.Destroy() if repo.IsWdChanged: dlg = wx.TextEntryDialog(frame, _("Describe revision:"), _('Commit')) dlg.SetValue("Auto-commit") if dlg.ShowModal() == wx.ID_OK and dlg.GetValue() != '': message = dlg.GetValue() try: repo.commit(message) except Exception as cond: wx.GetApp().log("[SourceControl] err: %s" % cond) # committed dlg.Destroy() else: dlg.Destroy() if not status: repo.SwitchToRemote() return repo.SwitchToRemote() if repo.IsWdChanged: if message == '': dlg = wx.TextEntryDialog(frame, _("Describe revision:"), _('Commit')) dlg.SetValue("Auto-commit") if dlg.ShowModal() == wx.ID_OK and dlg.GetValue() != '': message = dlg.GetValue() dlg.Destroy() else: if status: repo.SwitchToLocal() dlg.Destroy() return try: repo.commit(message) except Exception as cond: wx.GetApp().log("[SourceControl] err: %s" % cond) # committed # and now - time to push remote_repo = Profile_Get('HG_REPOSITORY') if remote_repo is None: remote_repo = repo.Repo.paths().get('default') if remote_repo is None: remote_repo = repo.Repo.paths().get('default-push') if remote_repo is None: dlg = wx.TextEntryDialog(frame, _("Code repository URL:"), _('Push')) if dlg.ShowModal() == wx.ID_OK and dlg.GetValue() != '': remote_repo = dlg.GetValue() Profile_Set('HG_REPOSITORY', remote_repo) dlg.Destroy() if remote_repo is not None: repo.push(remote_repo, force=force, insecure=insecure) if status: repo.SwitchToLocal()