mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
ide: U++ svn checkout feature
git-svn-id: svn://ultimatepp.org/upp/trunk@12274 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3b8b6ec7aa
commit
e432be354a
17 changed files with 209 additions and 29 deletions
|
|
@ -1,5 +1,4 @@
|
|||
topic "File path utilities";
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$2,0#27521748481378242620020725143825:desc]
|
||||
[0 $$3,0#96390100711032703541132217272105:end]
|
||||
|
|
@ -9,6 +8,7 @@ topic "File path utilities";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}
|
||||
[s0;%% [*@3;4 File path utilities]&]
|
||||
[s3; &]
|
||||
|
|
@ -228,7 +228,8 @@ st]_[@(0.0.255) char]_`*[*@3 oldpath], [@(0.0.255) const]_[@(0.0.255) char]_`*[*
|
|||
st]_[@(0.0.255) char]_`*[*@3 oldpath], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 newpath])
|
||||
&]
|
||||
[s2;%% Moves a file at [%-*@3 oldpath] to a new file at [%-*@3 newpath]
|
||||
(if already exists, overwrites it). Returns true on success.&]
|
||||
(if already exists, overwrites it). Returns true on success.
|
||||
Works on directories too.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FileDelete`(const char`*`): [@(0.0.255) bool]_[* FileDelete]([@(0.0.255) const]_[@(0.0.255) c
|
||||
|
|
@ -326,4 +327,4 @@ nst]_[@(0.0.255) char]_`*[*@3 prefix]_`=_NULL)&]
|
|||
[s2;%% Returns a unique path of temporary file. If [%-*@3 prefix ]is
|
||||
not NULL, it is prepended to the filename.&]
|
||||
[s3;%% &]
|
||||
[s0; ]
|
||||
[s0; ]]
|
||||
|
|
@ -390,8 +390,14 @@ void FileSelButton::OnAction()
|
|||
Ctrl *owner = button.GetParent();
|
||||
ASSERT(owner);
|
||||
String old = ~*owner;
|
||||
if(mode == MODE_DIR)
|
||||
if(mode == MODE_DIR) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(DirectoryExists(old))
|
||||
break;
|
||||
old = GetFileFolder(old);
|
||||
}
|
||||
ActiveDir(old);
|
||||
}
|
||||
else
|
||||
Set(old);
|
||||
if(mode == MODE_OPEN ? ExecuteOpen(title) : mode == MODE_SAVE ? ExecuteSaveAs(title) : ExecuteSelectDir(title))
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ public:
|
|||
|
||||
void Clear();
|
||||
void Add(const Value& data);
|
||||
int Find(const Value& data) const { return list.Find(data); }
|
||||
void FindAdd(const Value& data);
|
||||
void Set(int i, const Value& data) { list.Set(i, 0, data); }
|
||||
void Remove(int i);
|
||||
|
|
@ -245,6 +246,7 @@ public:
|
|||
void ClearList() { select.Clear(); }
|
||||
void AddList(const Value& data) { select.Add(data); }
|
||||
void FindAddList(const Value& data) { select.FindAdd(data); }
|
||||
int Find(const Value& data) const { return select.Find(data); }
|
||||
void Set(int i, const Value& data) { select.Set(i, data); }
|
||||
void Remove(int i) { select.Remove(i); }
|
||||
void SerializeList(Stream& s) { select.SerializeList(s); }
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ indAddList]([@(0.0.255) const]_[_^Upp`:`:Value^ Value][@(0.0.255) `&]_[*@3 data]
|
|||
already there.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:WithDropChoice`:`:Find`(const Upp`:`:Value`&`)const: [@(0.0.255) int]_[* Find
|
||||
]([@(0.0.255) const]_[_^Upp`:`:Value^ Value][@(0.0.255) `&]_[*@3 data])_[@(0.0.255) const]&]
|
||||
[s2;%% Finds the index of first list entry equal to [%-*@3 data].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:WithDropChoice`:`:Set`(int`,const Upp`:`:Value`&`): [@(0.0.255) void]_[* Set](
|
||||
[@(0.0.255) int]_[*@3 i], [@(0.0.255) const]_[_^Upp`:`:Value^ Value][@(0.0.255) `&]_[*@3 data
|
||||
])&]
|
||||
|
|
|
|||
|
|
@ -98,7 +98,10 @@ void StoreToWorkspace(T& x, const char *name)
|
|||
void SerializeWorkspaceConfigs(Stream& s);
|
||||
|
||||
extern bool IdeExit;
|
||||
extern bool IdeAgain; // Used to restart theide after checking out SVN (SetupSVNTrunk)
|
||||
|
||||
bool CopyFolder(const char *dst, const char *src, Progress *pi = NULL);
|
||||
|
||||
bool HasSvn();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ INITBLOCK {
|
|||
}
|
||||
|
||||
bool IdeExit;
|
||||
bool IdeAgain;
|
||||
|
||||
bool CopyFolder(const char *dst, const char *src, Progress *pi)
|
||||
{
|
||||
|
|
@ -243,3 +244,10 @@ bool CopyFolder(const char *dst, const char *src, Progress *pi)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HasSvn()
|
||||
{
|
||||
String dummy;
|
||||
static bool b = Sys("svn", dummy) >= 0;
|
||||
return b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,6 +343,14 @@ void SelectPackageDlg::ToolBase(Bar& bar)
|
|||
bar.Add("Synchronize " + d[i], IdeImg::svn_dir(), THISBACK1(SyncSvnDir, d[i]));
|
||||
bar.Add("Synchronize everything..", IdeImg::svn(), THISBACK(SyncSvnDirs));
|
||||
}
|
||||
if(HasSvn()) {
|
||||
bar.Separator();
|
||||
bar.Add("Checkout and setup U++ SVN trunk sources..", [=] {
|
||||
String vars = base.Get(0);
|
||||
SetupSVNTrunk();
|
||||
SyncBase(vars);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void SelectPackageDlg::OnBaseAdd()
|
||||
|
|
|
|||
108
uppsrc/ide/SetupSVN.cpp
Normal file
108
uppsrc/ide/SetupSVN.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
#include "ide.h"
|
||||
|
||||
void SetupSVNTrunk()
|
||||
{
|
||||
WithSetupSVNLayout<TopWindow> dlg;
|
||||
CtrlLayoutOKCancel(dlg, "Checkout U++ trunk");
|
||||
SelectDirButton dir_browse("Run in folder");
|
||||
dir_browse.Attach(dlg.dir);
|
||||
#ifdef PLATFORM_WIN32
|
||||
dlg.dir <<= GetExeDirFile("upp.src");
|
||||
#else
|
||||
dlg.dir <<= GetHomeDirFile("upp.src");
|
||||
#endif
|
||||
static MapConvert revcv;
|
||||
ONCELOCK {
|
||||
revcv.Add(11873, "2018.1 (rev 11873) (Mar 2018)");
|
||||
revcv.Add(11540, "2017.2 (rev 11540) (Dec 2017)");
|
||||
revcv.Add(10804, "2017.1 (rev 10804) (Jan 2017)");
|
||||
revcv.Add(9251, "2015.2 (rev 9251) (Dec 2015)");
|
||||
revcv.Add(8227, "2015.1 (rev 8227) (Mar 2015)");
|
||||
}
|
||||
dlg.revision.SetConvert(revcv);
|
||||
dlg.revision.DropWidthZ(200);
|
||||
for(int i = 0; i < revcv.GetCount(); i++)
|
||||
dlg.revision.AddList(revcv.GetKey(i));
|
||||
dlg.revision.NullText("HEAD");
|
||||
dlg.revision << [&] {
|
||||
String r = ~~dlg.revision;
|
||||
dlg.postfix <<= r.GetCount() ? '.' + r : String();
|
||||
};
|
||||
|
||||
UrepoConsole console;
|
||||
console.WithCancel();
|
||||
String dir, tempdir;
|
||||
for(;;) {
|
||||
if(dlg.Run() != IDOK)
|
||||
return;
|
||||
console.Clear();
|
||||
dir = ~dlg.dir;
|
||||
tempdir = AppendFileName(GetFileFolder(dir), "temp");
|
||||
if(DirectoryExists(tempdir))
|
||||
tempdir = AppendFileName(GetFileFolder(dir), AsString(Uuid::Create()));
|
||||
String revision = IsNull(dlg.revision) ? String() : "@" + ~~dlg.revision;
|
||||
bool direxists = DirectoryExists(dir);
|
||||
bool fileexists = FileExists(dir);
|
||||
if((direxists || fileexists) && !PromptYesNo("Target path already exists, overwrite?"))
|
||||
continue;
|
||||
int exitcode = 0;
|
||||
#ifdef _DEBUG
|
||||
for(auto nest : { "uppsrc", "examples" })
|
||||
#else
|
||||
for(auto nest : { "uppsrc", "reference", "examples", "tutorial", "bazaar" })
|
||||
#endif
|
||||
{
|
||||
static String svn = "svn checkout svn://www.ultimatepp.org/upp/trunk";
|
||||
if(dlg.all) {
|
||||
exitcode = console.System(svn + revision + ' ' + tempdir);
|
||||
break;
|
||||
}
|
||||
exitcode = console.System(svn + '/' + nest + revision + ' ' + tempdir + '/' + nest);
|
||||
if(exitcode)
|
||||
break;
|
||||
}
|
||||
if(exitcode == 0)
|
||||
break;
|
||||
console.Perform();
|
||||
DeleteFolderDeep(tempdir);
|
||||
}
|
||||
|
||||
FileDelete(dir);
|
||||
DeleteFolderDeep(dir);
|
||||
FileMove(tempdir, dir);
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
String out = GetExeDirFile("out");
|
||||
String ass = GetExeFolder();
|
||||
String myapps = GetExeDirFile("MyApps");
|
||||
#else
|
||||
String out = GetHomeDirectoryFile("out");
|
||||
String ass = GetConfigFolder();
|
||||
String myapps = GetExeDirFile("MyApps");
|
||||
#endif
|
||||
RealizeDirectory(out);
|
||||
|
||||
String uppsrc = AppendFileName(dir, "uppsrc");
|
||||
|
||||
auto MakeAssembly = [&](String b, String name = Null) {
|
||||
name = Nvl(name, GetFileTitle(b));
|
||||
String a = ass + '/' + ~~dlg.prefix + name + ~~dlg.postfix + ".var";
|
||||
if(name != "uppsrc")
|
||||
b << ';' << uppsrc;
|
||||
console.Log("Creating assembly " + a);
|
||||
SaveFile(a,
|
||||
"UPP = " + AsCString(b) + ";\r\n"
|
||||
"OUTPUT = " + AsCString(out) + ";\r\n"
|
||||
);
|
||||
};
|
||||
|
||||
for(FindFile ff(dir + "/*"); ff; ff.Next())
|
||||
if(ff.IsFolder())
|
||||
MakeAssembly(ff.GetPath());
|
||||
|
||||
MakeAssembly(myapps);
|
||||
uppsrc = AppendFileName(dir, "bazaar") + ';' + uppsrc;
|
||||
MakeAssembly(myapps, "MyApps-bazaar");
|
||||
|
||||
console.Perform();
|
||||
}
|
||||
|
|
@ -6,12 +6,6 @@
|
|||
|
||||
bool LoadVarFile(const char *name, VectorMap<String, String>& _var);
|
||||
|
||||
bool HasSvn()
|
||||
{
|
||||
String tmp;
|
||||
return Sys("svn",tmp)>=0;
|
||||
}
|
||||
|
||||
InstallWizard::InstallWizard()
|
||||
{
|
||||
Title("TheIDE - Initial setting wizard");
|
||||
|
|
|
|||
|
|
@ -1193,4 +1193,6 @@ inline void ShowConsole() { if(TheIde()) ((Ide *)TheIde())->ShowConsole(); }
|
|||
|
||||
void InstantSetup();
|
||||
|
||||
void SetupSVNTrunk();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -821,3 +821,17 @@ LAYOUT(NestEditorLayout, 420, 388)
|
|||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(SetupSVNLayout, 536, 112)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Target directory")).LeftPosZ(4, 160).TopPosZ(4, 19))
|
||||
ITEM(EditString, dir, LeftPosZ(164, 364).TopPosZ(4, 19))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(8, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24))
|
||||
ITEM(Option, all, SetLabel(t_("Also checkout development and auxiliary packages")).LeftPosZ(4, 296).TopPosZ(28, 20))
|
||||
ITEM(Label, dv___5, SetLabel(t_("Add prefix to assembly names")).LeftPosZ(4, 160).TopPosZ(52, 19))
|
||||
ITEM(Label, dv___6, SetLabel(t_("Add postfix to assembly names")).LeftPosZ(304, 160).TopPosZ(52, 19))
|
||||
ITEM(EditString, prefix, LeftPosZ(164, 64).TopPosZ(52, 19))
|
||||
ITEM(EditString, postfix, LeftPosZ(464, 64).TopPosZ(52, 19))
|
||||
ITEM(WithDropChoice<EditInt>, revision, LeftPosZ(464, 64).TopPosZ(28, 19))
|
||||
ITEM(Label, dv___10, SetLabel(t_("Revision to checkout")).LeftPosZ(304, 160).TopPosZ(28, 19))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ file
|
|||
Json.cpp,
|
||||
MacroManager.cpp,
|
||||
Update.cpp,
|
||||
SetupSVN.cpp,
|
||||
Compile readonly separator,
|
||||
MethodsCtrls.h,
|
||||
MethodsCtrls.cpp,
|
||||
|
|
|
|||
|
|
@ -391,10 +391,15 @@ void Ide::Setup(Bar& menu)
|
|||
// menu.Add("Legacy compilers automatic setup..", THISBACK(AutoSetup))
|
||||
// .Help("Automatic setup of build methods for legacy compilers..");
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
menu.Add("Source managment..", THISBACK(AutoSetup))
|
||||
.Help("Source code updater settings..");
|
||||
#endif
|
||||
//#ifdef PLATFORM_POSIX
|
||||
// menu.Add("Source managment..", THISBACK(AutoSetup))
|
||||
// .Help("Source code updater settings..");
|
||||
//#endif
|
||||
menu.Add("Checkout and setup U++ SVN trunk sources..", [=] {
|
||||
SetupSVNTrunk();
|
||||
IdeAgain = true;
|
||||
Break();
|
||||
});
|
||||
if(menu.IsMenuBar())
|
||||
SetupMobilePlatforms(menu);
|
||||
#ifdef PLATFORM_POSIX
|
||||
|
|
|
|||
|
|
@ -291,6 +291,8 @@ void AppMain___()
|
|||
SetPPDefs(LoadFile(ppdefs));
|
||||
|
||||
ide.LoadLastMain();
|
||||
do {
|
||||
IdeAgain = false;
|
||||
if(clset || ide.OpenMainPackage()) {
|
||||
ide.SaveLastMain();
|
||||
ide.isscanning++;
|
||||
|
|
@ -304,7 +306,10 @@ void AppMain___()
|
|||
ide.Run();
|
||||
ide.SaveConfigOnTime();
|
||||
ide.SaveLastMain();
|
||||
ide.Close();
|
||||
}
|
||||
}
|
||||
while(IdeAgain);
|
||||
#ifdef PLATFORM_POSIX
|
||||
StoreAsXMLFile(UpdaterCfg(),"SourceUpdater",ConfigFile("updates.xml"));
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ UrepoConsole::UrepoConsole()
|
|||
font = Courier(Ctrl::VertLayoutZoom(12));
|
||||
list.SetLineCy(font.Info().GetHeight());
|
||||
exit.Hide();
|
||||
cancel.Hide();
|
||||
cancel << [=] { canceled = true; };
|
||||
}
|
||||
|
||||
void UrepoConsole::AddResult(const String& out)
|
||||
|
|
@ -19,6 +21,11 @@ void UrepoConsole::AddResult(const String& out)
|
|||
list.GoEnd();
|
||||
}
|
||||
|
||||
void UrepoConsole::Log(const Value& s, Color ink)
|
||||
{
|
||||
list.Add(AttrText(s).SetFont(font).NormalInk(ink), s);
|
||||
}
|
||||
|
||||
int UrepoConsole::System(const char *cmd)
|
||||
{
|
||||
// LOG(cmd);
|
||||
|
|
@ -31,7 +38,9 @@ int UrepoConsole::System(const char *cmd)
|
|||
if(!p.Start(cmd))
|
||||
return -1;
|
||||
String out;
|
||||
while(p.IsRunning()) {
|
||||
canceled = false;
|
||||
cancel.Show(withcancel);
|
||||
while(p.IsRunning() && IsOpen()) {
|
||||
String h = p.Get();
|
||||
out.Cat(h);
|
||||
int lf = out.ReverseFind('\n');
|
||||
|
|
@ -41,11 +50,14 @@ int UrepoConsole::System(const char *cmd)
|
|||
}
|
||||
ProcessEvents();
|
||||
Sleep(h.GetCount() == 0); // p.Wait would be much better here!
|
||||
if(canceled)
|
||||
break;
|
||||
}
|
||||
cancel.Hide();
|
||||
out.Cat(p.Get());
|
||||
AddResult(out);
|
||||
ProcessEvents();
|
||||
int code = p.GetExitCode();
|
||||
int code = canceled ? -1 : p.GetExitCode();
|
||||
if(code)
|
||||
while(ii < list.GetCount()) {
|
||||
list.Set(ii, 0, AttrText((String)list.Get(ii, 1)).SetFont(font).Ink(LtRed));
|
||||
|
|
|
|||
|
|
@ -13,12 +13,17 @@ class UrepoConsole : public WithUrepoConsoleLayout<TopWindow> {
|
|||
|
||||
Font font;
|
||||
void AddResult(const String& out);
|
||||
bool withcancel = false;
|
||||
bool canceled = false;
|
||||
|
||||
public:
|
||||
int System(const char *s);
|
||||
int CheckSystem(const char *s);
|
||||
int Git(const char *dir, const char *command);
|
||||
void Log(const Value& s, Color ink = SColorText());
|
||||
void Perform() { exit.Show(); Execute(); }
|
||||
void WithCancel(bool b = true) { withcancel = b; }
|
||||
void Clear() { list.Clear(); }
|
||||
|
||||
UrepoConsole();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ END_LAYOUT
|
|||
LAYOUT(UrepoConsoleLayout, 680, 660)
|
||||
ITEM(ArrayCtrl, list, HSizePosZ(4, 4).VSizePosZ(4, 40))
|
||||
ITEM(Button, exit, SetLabel(t_("Close")).RightPosZ(4, 64).BottomPosZ(8, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(612, 64).BottomPosZ(8, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(SvnOptionsLayout, 140, 16)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue