From 4f0957c819e115a1f3916f85361a0af1a209c203 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Tue, 6 Oct 2009 23:20:52 +0000 Subject: [PATCH] Bug #6255 - Update linked files with version control git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31546 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/images/vc-repo-synchro.png | Bin 0 -> 1618 bytes lib/ui/stdtoolbars.inc | 2 + src/FuncCode.h | 3 +- src/LyXAction.cpp | 10 +++++ src/LyXVC.cpp | 7 +++ src/LyXVC.h | 5 +++ src/VCBackend.cpp | 76 +++++++++++++++++++++++++++++++++ src/VCBackend.h | 16 +++++++ src/frontends/qt4/GuiView.cpp | 13 ++++++ 9 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 lib/images/vc-repo-synchro.png diff --git a/lib/images/vc-repo-synchro.png b/lib/images/vc-repo-synchro.png new file mode 100644 index 0000000000000000000000000000000000000000..a43da6bba2f9ff7c111e2a708826ef3abfc45cb3 GIT binary patch literal 1618 zcmV-Y2CeytP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L09bPX09bPY5mcKd00007bV*G`2iXb+ z5EB{}mAj$<00q)XL_t(I%axUDY+L0W#-I0G;`sO^PVA&k?6_&yG)YNJOIqWkr7c~7 zt)i5om5a#5McROAmonf3Y@eomS~qE|3?wL^B>_!n7bMUa71=11jzFNTle8)gxz;{O zoW$32eD3GvLjrV@7}_JfU!GV0pPpBG^!`a*Pn6|YdK+QL zn8>hr1VF9h;8)VXhs)RAv%ZdCPoUlzjC7dIhDyIw01h9OoRb z4;CM-u2N%~#387oW!>(GQUOK8h*K$NUegsH-rMV=|n3;htzC@ z<6CDFb%lO6pLPpeN6Wv{1Mi!`z9@+M%9Az> za-z&dF9?xF6cb6XTx;;XOqx^jDQ1ti+F&a}CiMpm!svEv`6_AQI$BOG51!Sl?%#dD z?~|BY2T8q?iY)GGq%;od`$wE1gaLSh~)0LWu0OK7hfUdg&M+0Ss3Kd8IP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C::lockingToggle() { LYXERR(Debug::LYXVC, "LyXVC: toggle locking property"); diff --git a/src/LyXVC.h b/src/LyXVC.h index 1d576f93d0..4285db7355 100644 --- a/src/LyXVC.h +++ b/src/LyXVC.h @@ -77,6 +77,11 @@ public: /// Does the current VC supports this operation? bool checkOutEnabled(); + /// Synchronize the whole archive with repository + std::string repoSynchro(); + /// Does the current VC supports this operation? + bool repoSynchroEnabled(); + /** * Toggle locking property of the edited file, * i.e. whether the file uses locking mechanism. diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index 421a748451..6f6b60590e 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -204,6 +204,20 @@ bool RCS::checkOutEnabled() return owner_ && owner_->isReadonly(); } + +string RCS::repoSynchro() +{ + lyxerr << "Sorry, not implemented." << endl; + return string(); +} + + +bool RCS::repoSynchroEnabled() +{ + return false; +} + + string RCS::lockingToggle() { lyxerr << "Sorry, not implemented." << endl; @@ -379,6 +393,19 @@ bool CVS::checkOutEnabled() } +string CVS::repoSynchro() +{ + lyxerr << "Sorry, not implemented." << endl; + return string(); +} + + +bool CVS::repoSynchroEnabled() +{ + return false; +} + + string CVS::lockingToggle() { lyxerr << "Sorry, not implemented." << endl; @@ -672,6 +699,55 @@ bool SVN::checkOutEnabled() } +string SVN::repoSynchro() +{ + FileName tmpf = FileName::tempName("lyxvcout"); + if (tmpf.empty()) { + LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf); + return N_("Error: Could not generate logfile."); + } + + doVCCommand("svn diff " + quoteName(owner_->filePath()) + + " > " + quoteName(tmpf.toFilesystemEncoding()), + FileName(owner_->filePath())); + docstring res = tmpf.fileContents("UTF-8"); + if (!res.empty()) { + LYXERR(Debug::LYXVC, "Diff detected:\n" << res); + docstring const file = from_utf8(owner_->filePath()); + docstring text = bformat(_("There were detected changes" + "in the working directory.\n" + "Synchronizing with repository will discard " + "any uncommitted changes in the directory:\n%1$s" + "\n\nContinue?"), file); + int const ret = frontend::Alert::prompt(_("Changes detected"), + text, 0, 1, _("&Yes"), _("&No")); + if (ret) { + tmpf.erase(); + return string(); + } + } + + doVCCommand("svn revert -R " + quoteName(owner_->filePath()) + + " > " + quoteName(tmpf.toFilesystemEncoding()), + FileName(owner_->filePath())); + res = "Revert log:\n" + tmpf.fileContents("UTF-8"); + doVCCommand("svn update " + quoteName(owner_->filePath()) + + " > " + quoteName(tmpf.toFilesystemEncoding()), + FileName(owner_->filePath())); + res += "Update log:\n" + tmpf.fileContents("UTF-8"); + + LYXERR(Debug::LYXVC, res); + tmpf.erase(); + return to_utf8(res); +} + + +bool SVN::repoSynchroEnabled() +{ + return true; +} + + string SVN::lockingToggle() { FileName tmpf = FileName::tempName("lyxvcout"); diff --git a/src/VCBackend.h b/src/VCBackend.h index 2a06631867..dc571d4aaf 100644 --- a/src/VCBackend.h +++ b/src/VCBackend.h @@ -43,6 +43,10 @@ public: virtual std::string checkOut() = 0; // can be this operation processed in the current RCS? virtual bool checkOutEnabled() = 0; + /// synchronize with repository, returns log + virtual std::string repoSynchro() = 0; + // can be this operation processed in the current RCS? + virtual bool repoSynchroEnabled() = 0; // toggle locking property of the file virtual std::string lockingToggle() = 0; // can be this operation processed in the current RCS? @@ -131,6 +135,10 @@ public: virtual bool checkOutEnabled(); + virtual std::string repoSynchro(); + + virtual bool repoSynchroEnabled(); + virtual std::string lockingToggle(); virtual bool lockingToggleEnabled(); @@ -174,6 +182,10 @@ public: virtual bool checkOutEnabled(); + virtual std::string repoSynchro(); + + virtual bool repoSynchroEnabled(); + virtual std::string lockingToggle(); virtual bool lockingToggleEnabled(); @@ -220,6 +232,10 @@ public: virtual bool checkOutEnabled(); + virtual std::string repoSynchro(); + + virtual bool repoSynchroEnabled(); + virtual std::string lockingToggle(); virtual bool lockingToggleEnabled(); diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 06d0ad1cca..02716fc4a6 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1414,6 +1414,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) case LFUN_VC_UNDO_LAST: enable = doc_buffer && doc_buffer->lyxvc().undoLastEnabled(); break; + case LFUN_VC_REPO_SYNCHRO: + enable = doc_buffer && doc_buffer->lyxvc().inUse(); + break; case LFUN_VC_COMMAND: { if (cmd.argument().empty()) enable = false; @@ -2334,6 +2337,15 @@ void GuiView::dispatchVC(FuncRequest const & cmd) reloadBuffer(); break; + case LFUN_VC_REPO_SYNCHRO: + LASSERT(buffer, return); + if (ensureBufferClean(buffer)) { + string res = buffer->lyxvc().repoSynchro(); + message(from_utf8(res)); + reloadBuffer(); + } + break; + case LFUN_VC_COMMAND: { string flag = cmd.getArg(0); if (buffer && contains(flag, 'R') && !ensureBufferClean(buffer)) @@ -2754,6 +2766,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) case LFUN_VC_REGISTER: case LFUN_VC_CHECK_IN: case LFUN_VC_CHECK_OUT: + case LFUN_VC_REPO_SYNCHRO: case LFUN_VC_LOCKING_TOGGLE: case LFUN_VC_REVERT: case LFUN_VC_UNDO_LAST: