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
This commit is contained in:
Pavel Sanda 2009-10-06 23:20:52 +00:00
parent 89dde39404
commit 4f0957c819
9 changed files with 131 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -257,6 +257,8 @@ ToolbarSet
Item "Revert changes" "vc-revert" Item "Revert changes" "vc-revert"
Separator Separator
Item "Use SVN file locking property" "vc-locking-toggle" Item "Use SVN file locking property" "vc-locking-toggle"
Separator
Item "Synchronize local directory with repository" "vc-repo-synchro"
End End
Toolbar "math_panels" "Math Panels" Toolbar "math_panels" "Math Panels"

View File

@ -228,7 +228,7 @@ enum FuncCode
LFUN_VC_COMMAND, LFUN_VC_COMMAND,
LFUN_VC_LOCKING_TOGGLE, LFUN_VC_LOCKING_TOGGLE,
// 165 // 165
LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE, // ARRae 971202 LFUN_VC_REPO_SYNCHRO,
LFUN_BUFFER_CHKTEX, // Asger 971030 LFUN_BUFFER_CHKTEX, // Asger 971030
LFUN_HYPERLINK_INSERT, // CFO-G 971121 LFUN_HYPERLINK_INSERT, // CFO-G 971121
LFUN_WORD_FIND_FORWARD, // Etienne 980216 LFUN_WORD_FIND_FORWARD, // Etienne 980216
@ -442,6 +442,7 @@ enum FuncCode
LFUN_BUFFER_CLOSE_ALL, // vfr 20090806 LFUN_BUFFER_CLOSE_ALL, // vfr 20090806
LFUN_GRAPHICS_RELOAD, // vfr 20090810 LFUN_GRAPHICS_RELOAD, // vfr 20090810
LFUN_SCREEN_SHOW_CURSOR, // vfr, 20090325 LFUN_SCREEN_SHOW_CURSOR, // vfr, 20090325
LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE, // ARRae 971202
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };

View File

@ -2171,6 +2171,16 @@ void LyXAction::init()
* \endvar * \endvar
*/ */
{ LFUN_VC_LOCKING_TOGGLE, "vc-locking-toggle", ReadOnly, System }, { 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 * \var lyx::FuncCode lyx::LFUN_CHANGES_TRACK

View File

@ -170,6 +170,13 @@ string LyXVC::checkOut()
} }
string LyXVC::repoSynchro()
{
LYXERR(Debug::LYXVC, "LyXVC: repoSynchro");
return vcs->repoSynchro();
}
string LyXVC::lockingToggle() string LyXVC::lockingToggle()
{ {
LYXERR(Debug::LYXVC, "LyXVC: toggle locking property"); LYXERR(Debug::LYXVC, "LyXVC: toggle locking property");

View File

@ -77,6 +77,11 @@ public:
/// Does the current VC supports this operation? /// Does the current VC supports this operation?
bool checkOutEnabled(); 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, * Toggle locking property of the edited file,
* i.e. whether the file uses locking mechanism. * i.e. whether the file uses locking mechanism.

View File

@ -204,6 +204,20 @@ bool RCS::checkOutEnabled()
return owner_ && owner_->isReadonly(); return owner_ && owner_->isReadonly();
} }
string RCS::repoSynchro()
{
lyxerr << "Sorry, not implemented." << endl;
return string();
}
bool RCS::repoSynchroEnabled()
{
return false;
}
string RCS::lockingToggle() string RCS::lockingToggle()
{ {
lyxerr << "Sorry, not implemented." << endl; 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() string CVS::lockingToggle()
{ {
lyxerr << "Sorry, not implemented." << endl; 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() string SVN::lockingToggle()
{ {
FileName tmpf = FileName::tempName("lyxvcout"); FileName tmpf = FileName::tempName("lyxvcout");

View File

@ -43,6 +43,10 @@ public:
virtual std::string checkOut() = 0; virtual std::string checkOut() = 0;
// can be this operation processed in the current RCS? // can be this operation processed in the current RCS?
virtual bool checkOutEnabled() = 0; 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 // toggle locking property of the file
virtual std::string lockingToggle() = 0; virtual std::string lockingToggle() = 0;
// can be this operation processed in the current RCS? // can be this operation processed in the current RCS?
@ -131,6 +135,10 @@ public:
virtual bool checkOutEnabled(); virtual bool checkOutEnabled();
virtual std::string repoSynchro();
virtual bool repoSynchroEnabled();
virtual std::string lockingToggle(); virtual std::string lockingToggle();
virtual bool lockingToggleEnabled(); virtual bool lockingToggleEnabled();
@ -174,6 +182,10 @@ public:
virtual bool checkOutEnabled(); virtual bool checkOutEnabled();
virtual std::string repoSynchro();
virtual bool repoSynchroEnabled();
virtual std::string lockingToggle(); virtual std::string lockingToggle();
virtual bool lockingToggleEnabled(); virtual bool lockingToggleEnabled();
@ -220,6 +232,10 @@ public:
virtual bool checkOutEnabled(); virtual bool checkOutEnabled();
virtual std::string repoSynchro();
virtual bool repoSynchroEnabled();
virtual std::string lockingToggle(); virtual std::string lockingToggle();
virtual bool lockingToggleEnabled(); virtual bool lockingToggleEnabled();

View File

@ -1414,6 +1414,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
case LFUN_VC_UNDO_LAST: case LFUN_VC_UNDO_LAST:
enable = doc_buffer && doc_buffer->lyxvc().undoLastEnabled(); enable = doc_buffer && doc_buffer->lyxvc().undoLastEnabled();
break; break;
case LFUN_VC_REPO_SYNCHRO:
enable = doc_buffer && doc_buffer->lyxvc().inUse();
break;
case LFUN_VC_COMMAND: { case LFUN_VC_COMMAND: {
if (cmd.argument().empty()) if (cmd.argument().empty())
enable = false; enable = false;
@ -2334,6 +2337,15 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
reloadBuffer(); reloadBuffer();
break; 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: { case LFUN_VC_COMMAND: {
string flag = cmd.getArg(0); string flag = cmd.getArg(0);
if (buffer && contains(flag, 'R') && !ensureBufferClean(buffer)) if (buffer && contains(flag, 'R') && !ensureBufferClean(buffer))
@ -2754,6 +2766,7 @@ bool GuiView::dispatch(FuncRequest const & cmd)
case LFUN_VC_REGISTER: case LFUN_VC_REGISTER:
case LFUN_VC_CHECK_IN: case LFUN_VC_CHECK_IN:
case LFUN_VC_CHECK_OUT: case LFUN_VC_CHECK_OUT:
case LFUN_VC_REPO_SYNCHRO:
case LFUN_VC_LOCKING_TOGGLE: case LFUN_VC_LOCKING_TOGGLE:
case LFUN_VC_REVERT: case LFUN_VC_REVERT:
case LFUN_VC_UNDO_LAST: case LFUN_VC_UNDO_LAST: