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()