Guify setting of svn locking property

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30255 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2009-06-25 14:48:11 +00:00
parent 7df973465a
commit 7355a53a73
11 changed files with 218 additions and 1 deletions

View File

@ -18396,7 +18396,15 @@ The file exchange through various revision control systems brings the problem
\begin_layout Standard
SVN has two mechanisms to provide such kind of mutual exclusivity for file
access - locks and automatical setting of write permissions based on
access - locks and automatical setting of write permissions (see sec.
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Automatical-Locking-Property"
\end_inset
) based on
\begin_inset Flex CharStyle:Code
status collapsed
@ -18484,6 +18492,72 @@ svn update "<file-name>"
svn lock "<file-name>"
\end_layout
\begin_layout Subsubsection
\family typewriter
\begin_inset CommandInset label
LatexCommand label
name "subsec:Automatical-Locking-Property"
\end_inset
\family default
Automatical Locking Property
\end_layout
\begin_layout Standard
The above mentioned automatical setting of write permissions of the .lyx
file can be set through
\family sans
\bar under
F
\bar default
ile\SpecialChar \menuseparator
\bar under
V
\bar default
ersion
\begin_inset space ~
\end_inset
Control\SpecialChar \menuseparator
\bar under
T
\bar default
oggle locking property
\family default
.
This command is active only when the file is not locked on the svn server
(i.e.
you need to check-out before proceeding).
\end_layout
\begin_layout Labeling
\labelwidthstring 00.00.0000
SVN
\begin_inset space ~
\end_inset
commands:
\end_layout
\begin_layout Labeling
\labelwidthstring 00.00.0000
Set:
\family typewriter
svn propset svn:needs-lock ON "<file-name>"
\end_layout
\begin_layout Labeling
\labelwidthstring 00.00.0000
Unset:
\family typewriter
svn propdel svn:needs-lock "<file-name>"
\end_layout
\begin_layout Subsection
SVN and Windows Environment
\end_layout

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

View File

@ -66,6 +66,7 @@ Menuset
OptItem "Revert to Repository Version|R" "vc-revert"
OptItem "Undo Last Check In|U" "vc-undo-last"
OptItem "Show History...|H" "dialog-show vclog"
OptItem "Toggle locking property|T" "vc-locking-toggle"
End
Menu "file_import"

View File

@ -242,6 +242,8 @@ ToolbarSet
Item "Check-in changes" "vc-check-in"
Item "View revision log" "dialog-show vclog"
Item "Revert changes" "vc-revert"
Separator
Item "Toggle svn file locking property" "vc-locking-toggle"
End
Toolbar "math_panels" "Math Panels"

View File

@ -433,6 +433,7 @@ enum FuncCode
LFUN_FONT_UULINE,
// 335
LFUN_FONT_UWAVE,
LFUN_VC_LOCKING_TOGGLE,
LFUN_LASTACTION // end of the table
};

View File

@ -2121,6 +2121,15 @@ void LyXAction::init()
* \endvar
*/
{ LFUN_VC_COMMAND, "vc-command", NoBuffer | ReadOnly, System },
/*!
* \var lyx::FuncCode lyx::LFUN_VC_LOCKING_TOGGLE
* \li Action: Toggles the locking property of the edited file.
* \li Notion: This is currently implemented only for SVN.
* \li Syntax: vc-locking-toggle
* \li Origin: sanda, 25 Jun 2009
* \endvar
*/
{ LFUN_VC_LOCKING_TOGGLE, "vc-locking-toggle", ReadOnly, System },
/*!
* \var lyx::FuncCode lyx::LFUN_CHANGES_TRACK

View File

@ -471,6 +471,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
case LFUN_VC_CHECK_OUT:
enable = buf->lyxvc().checkOutEnabled();
break;
case LFUN_VC_LOCKING_TOGGLE:
enable = !buf->isReadonly() && buf->lyxvc().lockingToggleEnabled();
break;
case LFUN_VC_REVERT:
enable = buf->lyxvc().inUse();
break;
@ -1045,6 +1048,22 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
}
break;
case LFUN_VC_LOCKING_TOGGLE:
LASSERT(lyx_view_ && buffer, /**/);
if (!ensureBufferClean(view()) || buffer->isReadonly())
break;
if (buffer->lyxvc().inUse()) {
string res = buffer->lyxvc().lockingToggle();
if (res.empty())
frontend::Alert::error(_("Revision control error."),
_("Error when setting the locking property."));
else {
setMessage(from_utf8(res));
reloadBuffer();
}
}
break;
case LFUN_VC_REVERT:
LASSERT(lyx_view_ && buffer, /**/);
buffer->lyxvc().revert();

View File

@ -170,6 +170,13 @@ string LyXVC::checkOut()
}
string LyXVC::lockingToggle()
{
LYXERR(Debug::LYXVC, "LyXVC: toggle locking property");
return vcs->lockingToggle();
}
void LyXVC::revert()
{
LYXERR(Debug::LYXVC, "LyXVC: revert");
@ -266,6 +273,12 @@ bool LyXVC::checkInEnabled()
}
bool LyXVC::lockingToggleEnabled()
{
return vcs && vcs->lockingToggleEnabled();
}
bool LyXVC::undoLastEnabled()
{
return vcs && vcs->undoLastEnabled();

View File

@ -77,6 +77,14 @@ public:
/// Does the current VC supports this operation?
bool checkOutEnabled();
/**
* Toggle locking property of the edited file,
* i.e. whether the file uses locking mechanism.
*/
std::string lockingToggle();
/// Does the current VC supports this operation?
bool lockingToggleEnabled();
/// Revert to last version
void revert();

View File

@ -204,6 +204,18 @@ bool RCS::checkOutEnabled()
return owner_ && owner_->isReadonly();
}
string RCS::lockingToggle()
{
lyxerr << "Sorry, not implemented." << endl;
return string();
}
bool RCS::lockingToggleEnabled()
{
return false;
}
void RCS::revert()
{
@ -367,6 +379,19 @@ bool CVS::checkOutEnabled()
}
string CVS::lockingToggle()
{
lyxerr << "Sorry, not implemented." << endl;
return string();
}
bool CVS::lockingToggleEnabled()
{
return false;
}
void CVS::revert()
{
// Reverts to the version in CVS repository and
@ -569,6 +594,10 @@ string SVN::scanLogFile(FileName const & f, string & status)
ifs.close();
return line;
}
if (contains(line, "svn:needs-lock")) {
ifs.close();
return line;
}
}
ifs.close();
return string();
@ -643,6 +672,51 @@ bool SVN::checkOutEnabled()
}
string SVN::lockingToggle()
{
FileName tmpf = FileName::tempName("lyxvcout");
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return N_("Error: Could not generate logfile.");
}
int ret = doVCCommand("svn proplist " + quoteName(onlyFilename(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (ret)
return string();
string log;
string res = scanLogFile(tmpf, log);
bool locking = contains(res, "svn:needs-lock");
if (!locking)
ret = doVCCommand("svn propset svn:needs-lock ON "
+ quoteName(onlyFilename(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
else
ret = doVCCommand("svn propdel svn:needs-lock "
+ quoteName(onlyFilename(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (ret)
return string();
tmpf.erase();
frontend::Alert::warning(_("VCN File Locking"),
(locking ? _("Locking property unset.") : _("Locking property set.") + "\n")
+ _("Do not forget to commit the locking property into the repository."),
true);
return N_("SVN: Locking property set.");
}
bool SVN::lockingToggleEnabled()
{
return true;
}
void SVN::revert()
{
// Reverts to the version in CVS repository and

View File

@ -43,6 +43,10 @@ public:
virtual std::string checkOut() = 0;
// can be this operation processed in the current RCS?
virtual bool checkOutEnabled() = 0;
// toggle locking property of the file
virtual std::string lockingToggle() = 0;
// can be this operation processed in the current RCS?
virtual bool lockingToggleEnabled() = 0;
/// revert current edits
virtual void revert() = 0;
/// FIXME
@ -127,6 +131,10 @@ public:
virtual bool checkOutEnabled();
virtual std::string lockingToggle();
virtual bool lockingToggleEnabled();
virtual void revert();
virtual void undoLast();
@ -166,6 +174,10 @@ public:
virtual bool checkOutEnabled();
virtual std::string lockingToggle();
virtual bool lockingToggleEnabled();
virtual void revert();
virtual void undoLast();
@ -208,6 +220,10 @@ public:
virtual bool checkOutEnabled();
virtual std::string lockingToggle();
virtual bool lockingToggleEnabled();
virtual void revert();
virtual void undoLast();