diff --git a/lib/images/vc-repo-synchro.png b/lib/images/vc-repo-synchro.png new file mode 100644 index 0000000000..a43da6bba2 Binary files /dev/null and b/lib/images/vc-repo-synchro.png differ diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc index 5f419edb15..5a1c1b897b 100644 --- a/lib/ui/stdtoolbars.inc +++ b/lib/ui/stdtoolbars.inc @@ -257,6 +257,8 @@ ToolbarSet Item "Revert changes" "vc-revert" Separator Item "Use SVN file locking property" "vc-locking-toggle" + Separator + Item "Synchronize local directory with repository" "vc-repo-synchro" End Toolbar "math_panels" "Math Panels" diff --git a/src/FuncCode.h b/src/FuncCode.h index 2a1b7677d0..0f2859348e 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -228,7 +228,7 @@ enum FuncCode LFUN_VC_COMMAND, LFUN_VC_LOCKING_TOGGLE, // 165 - LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE, // ARRae 971202 + LFUN_VC_REPO_SYNCHRO, LFUN_BUFFER_CHKTEX, // Asger 971030 LFUN_HYPERLINK_INSERT, // CFO-G 971121 LFUN_WORD_FIND_FORWARD, // Etienne 980216 @@ -442,6 +442,7 @@ enum FuncCode LFUN_BUFFER_CLOSE_ALL, // vfr 20090806 LFUN_GRAPHICS_RELOAD, // vfr 20090810 LFUN_SCREEN_SHOW_CURSOR, // vfr, 20090325 + LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE, // ARRae 971202 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 9bb658cb7c..d5f6e9dae7 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2171,6 +2171,16 @@ void LyXAction::init() * \endvar */ { LFUN_VC_LOCKING_TOGGLE, "vc-locking-toggle", ReadOnly, System }, +/*! + * \var lyx::FuncCode lyx::LFUN_VC_REPO_SYNCHRO + * \li Action: Synchronize the local archive directory in which resides + the current document with the repository. + * \li Notion: This is currently implemented only for SVN as revert + update operation. + * \li Syntax: vc-repo-synchro + * \li Origin: sanda, 16 Oct 2009 + * \endvar + */ + { LFUN_VC_REPO_SYNCHRO, "vc-repo-synchro", ReadOnly, System }, /*! * \var lyx::FuncCode lyx::LFUN_CHANGES_TRACK diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index a845554664..4acdd39972 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -170,6 +170,13 @@ string LyXVC::checkOut() } +string LyXVC::repoSynchro() +{ + LYXERR(Debug::LYXVC, "LyXVC: repoSynchro"); + return vcs->repoSynchro(); +} + + string LyXVC::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: