ide: developing git support

git-svn-id: svn://ultimatepp.org/upp/trunk@15590 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-12-14 08:38:37 +00:00
parent cececa665c
commit 6626d00851
7 changed files with 29 additions and 14 deletions

View file

@ -2,7 +2,7 @@ enum { REMOTE_TIMEOUT = 2000 };
extern String HostConsole;
struct Host : LocalProcess {
struct Host {
struct FileInfo : Time, Moveable<FileInfo> {
int length;
};

View file

@ -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;
}

View file

@ -58,7 +58,7 @@ bool IsConflictFile(String path)
bool RepoSync::ListSvn(const String& path)
{
Vector<String> ln = Split(Sys("svn status " + path), CharFilterCrLf);
Vector<String> 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<String> ln = Split(Sys("svn status \"" + path + "\""), CharFilterCrLf);
Vector<String> ln = Split(RepoSys("svn status \"" + path + "\""), CharFilterCrLf);
for(int l = 0; l < ln.GetCount(); l++) {
String h = ln[l];
if(h.GetCount() > 7) {

View file

@ -477,7 +477,7 @@ void RepoSyncDirs(const Vector<String>& 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)

View file

@ -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

View file

@ -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 };

View file

@ -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