From 6626d008515856239ccfb0ce82b1ecf8b07d207b Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 14 Dec 2020 08:38:37 +0000 Subject: [PATCH] ide: developing git support git-svn-id: svn://ultimatepp.org/upp/trunk@15590 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Core/Host.h | 2 +- uppsrc/ide/RepoConsole.cpp | 16 ++++++++-------- uppsrc/ide/RepoSync.cpp | 6 +++--- uppsrc/ide/idetool.cpp | 2 +- uppsrc/ide/main.cpp | 13 +++++++++++++ uppsrc/ide/urepo.h | 2 ++ uppsrc/ide/urepo.lay | 2 +- 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/uppsrc/ide/Core/Host.h b/uppsrc/ide/Core/Host.h index c119ab4fe..cb5b8bd82 100644 --- a/uppsrc/ide/Core/Host.h +++ b/uppsrc/ide/Core/Host.h @@ -2,7 +2,7 @@ enum { REMOTE_TIMEOUT = 2000 }; extern String HostConsole; -struct Host : LocalProcess { +struct Host { struct FileInfo : Time, Moveable { int length; }; diff --git a/uppsrc/ide/RepoConsole.cpp b/uppsrc/ide/RepoConsole.cpp index 7a251afb3..98646c1f3 100644 --- a/uppsrc/ide/RepoConsole.cpp +++ b/uppsrc/ide/RepoConsole.cpp @@ -1,16 +1,15 @@ #include "ide.h" -int RepoSys(const char *cmd, String& out, bool convertcharset) +String RepoSys(const char *cmd) { - LocalProcess p; // TODO: CreateHost global Ide *ide = (Ide *)TheIde(); if(!ide) - return -1; + return String::GetVoid(); Host host; ide->CreateHost(host, false, false); - if(!p.Start(cmd)) - return -1; - return p.Finish(out); + LocalProcess p; + String out; + return host.StartProcess(p, cmd) && p.Finish(out) == 0 ? out : String::GetVoid(); } UrepoConsole::UrepoConsole() @@ -45,13 +44,14 @@ int UrepoConsole::System(const char *cmd) Open(); list.Add(AttrText(cmd).SetFont(font().Bold()).Ink(SLtBlue())); int ii = list.GetCount(); - LocalProcess p; Ide *ide = (Ide *)TheIde(); if(!ide) return -1; Host host; ide->CreateHost(host, false, false); - if(!p.Start(cmd)) { +// host.AddEnvironment("ASK_PASS", GetExeFilePath() + " #git_ask_pass"); + LocalProcess p; + if(!host.StartProcess(p, cmd)) { list.Add(AttrText("Failed to start the executable").SetFont(font().Bold()).Ink(SLtRed())); return -1; } diff --git a/uppsrc/ide/RepoSync.cpp b/uppsrc/ide/RepoSync.cpp index c23afc178..d24f5cec2 100644 --- a/uppsrc/ide/RepoSync.cpp +++ b/uppsrc/ide/RepoSync.cpp @@ -58,7 +58,7 @@ bool IsConflictFile(String path) bool RepoSync::ListSvn(const String& path) { - Vector ln = Split(Sys("svn status " + path), CharFilterCrLf); + Vector ln = Split(RepoSys("svn status " + path), CharFilterCrLf); bool actions = false; for(int pass = 0; pass < 2; pass++) for(int i = 0; i < ln.GetCount(); i++) { @@ -128,7 +128,7 @@ String GitCmd(const char *dir, const char *command) LOG("GitCmd " << dir << ", " << command); String h = GetCurrentDirectory(); SetCurrentDirectory(dir); - String r = Sys(String() << "git " << command); + String r = RepoSys(String() << "git " << command); SetCurrentDirectory(h); return r; } @@ -461,7 +461,7 @@ bool RepoSync::SvnFile(UrepoConsole& sys, String& filelist, int action, const St RepoMoveSvn(path, tp); sRepoDeleteFolderDeep(path); FileMove(tp, path); - Vector ln = Split(Sys("svn status \"" + path + "\""), CharFilterCrLf); + Vector ln = Split(RepoSys("svn status \"" + path + "\""), CharFilterCrLf); for(int l = 0; l < ln.GetCount(); l++) { String h = ln[l]; if(h.GetCount() > 7) { diff --git a/uppsrc/ide/idetool.cpp b/uppsrc/ide/idetool.cpp index 5ab1783ea..b6829b532 100644 --- a/uppsrc/ide/idetool.cpp +++ b/uppsrc/ide/idetool.cpp @@ -477,7 +477,7 @@ void RepoSyncDirs(const Vector& working) String repocfg = ConfigFile("repo.cfg"); repo.SetMsgs(LoadFile(repocfg)); for(String d : working) - repo.Dir(InUppHub(d), d); + repo.Dir(false && InUppHub(d), d); repo.DoSync(); SaveFile(repocfg, repo.GetMsgs()); if(f) diff --git a/uppsrc/ide/main.cpp b/uppsrc/ide/main.cpp index e123a025a..2641f2269 100644 --- a/uppsrc/ide/main.cpp +++ b/uppsrc/ide/main.cpp @@ -224,6 +224,19 @@ void AppMain___() return; } #endif + /* + if(arg[i] == "#git_ask_pass") { + String s; + for(;;) { + int c = getchar(); + if(c == EOF) + break; + s.Cat(c); + } + PromptOK("ASK_PASS:&\1" + s); + return; + } + */ } #ifdef _DEBUG0 diff --git a/uppsrc/ide/urepo.h b/uppsrc/ide/urepo.h index ba9917a35..73f78f6f7 100644 --- a/uppsrc/ide/urepo.h +++ b/uppsrc/ide/urepo.h @@ -19,6 +19,8 @@ public: UrepoConsole(); }; +String RepoSys(const char *cmd); + String SvnCmd(const char *cmd); enum { NOT_REPO_DIR = 0, SVN_DIR, GIT_DIR }; diff --git a/uppsrc/ide/urepo.lay b/uppsrc/ide/urepo.lay index 308e6d0f0..b68c0876e 100644 --- a/uppsrc/ide/urepo.lay +++ b/uppsrc/ide/urepo.lay @@ -1,7 +1,7 @@ LAYOUT(RepoSyncLayout, 680, 400) ITEM(Upp::ArrayCtrl, list, AutoHideSb(true).HSizePosZ(4, 4).VSizePosZ(4, 36)) ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(4, 64).BottomPosZ(4, 24)) - ITEM(Upp::Button, credentials, SetLabel(t_("Credentials..")).RightPosZ(96, 84).BottomPosZ(4, 24)) + ITEM(Upp::Button, credentials, SetLabel(t_("SVN Credentials..")).RightPosZ(92, 104).BottomPosZ(4, 24)) ITEM(Upp::Button, ok, SetLabel(t_("Synchronize!")).RightPosZ(4, 84).BottomPosZ(4, 24)) END_LAYOUT