Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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()