1 #ifndef _urepo_urepo_h_ 2 #define _urepo_urepo_h_ 3 4 #include <TextDiffCtrl/TextDiffCtrl.h> 5 6 namespace Upp { 7 8 #define LAYOUTFILE <urepo/urepo.lay> 9 #include <CtrlCore/lay.h> 10 11 class UrepoConsole : public WithUrepoConsoleLayout<TopWindow> { 12 typedef UrepoConsole CLASSNAME; 13 14 Font font; 15 void AddResult(const String& out); 16 bool withcancel = false; 17 bool canceled = false; 18 19 public: 20 int System(const char *s); 21 int CheckSystem(const char *s); 22 int Git(const char *dir, const char *command); 23 void Log(const Value& s, Color ink = SColorText()); Perform()24 void Perform() { exit.Show(); Execute(); } 25 void WithCancel(bool b = true) { withcancel = b; } Clear()26 void Clear() { list.Clear(); } 27 28 UrepoConsole(); 29 }; 30 31 String SvnCmd(const char *cmd); 32 33 enum { NOT_REPO_DIR = 0, SVN_DIR, GIT_DIR }; 34 35 int GetRepoKind(const String& p); 36 String GetSvnDir(const String& p); 37 38 String GitCmd(const char *dir, const char *command); 39 40 struct RepoSync : WithRepoSyncLayout<TopWindow> { 41 enum { 42 MODIFY, 43 CONFLICT, 44 ADD, 45 REMOVE, 46 REPLACE, 47 48 REPOSITORY, 49 MESSAGE, 50 51 SVN_IGNORE = -1, 52 DELETEC = -2, 53 SVN_ACTION = -3, 54 }; 55 56 Array<Switch> revert; 57 Array<DocEdit> message; 58 Array<Button> diff; 59 ArrayMap<String, String> msgmap; 60 61 Index<String> svndir; 62 VectorMap<String, Tuple<String, String>> svn_credentials; 63 bool remember_credentials = true; 64 65 struct SvnOptions : WithSvnOptionsLayout<ParentCtrl> { SvnOptionsRepoSync::SvnOptions66 SvnOptions() { CtrlLayout(*this); } 67 }; 68 69 struct GitOptions : WithGitOptionsLayout<ParentCtrl> { GitOptionsRepoSync::GitOptions70 GitOptions() { CtrlLayout(*this); } 71 }; 72 73 struct Work { 74 int kind; 75 String dir; 76 }; 77 78 Array<Work> work; 79 80 String SvnCmd(const char *cmd, const String& dir); 81 bool ListGit(const String& path); 82 bool ListSvn(const String& path); 83 bool GitFile(UrepoConsole& sys, int action, const String& path, bool revert); 84 bool SvnFile(UrepoConsole& sys, String& filelist, int action, const String& path, bool revert); 85 void SyncCommits(); 86 void SyncList(); 87 void DoDiff(int ii); 88 void Serialize(Stream& s); 89 90 typedef RepoSync CLASSNAME; 91 92 public: 93 void SetMsgs(const String& s); 94 String GetMsgs(); 95 96 void Dir(const char *dir, int kind); 97 void Dir(const char *dir); 98 void DoSync(); 99 100 RepoSync(); 101 }; 102 103 104 void EditCredentials(RepoSync& rs); 105 106 void RunRepoDiff(const String& filepath); 107 108 }; 109 110 #endif 111