The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 21c5bbec71b7a8a191e10be68396ccef49909c7b
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Tue Apr 16 16:22:10 2013 +0200

    Fix bug #8627: Command line switches to change branch do not appear to work
    
    Move the handling of branch-(de)activate(master) to Buffer. This code was 
moved to Bufferview in [3a03e71c/lyxgit] because a cursor was necessary to call 
Undo::recordUndoFullDocument(). However, it turns out that the undo code is 
already prepared to handle an empty cursor (and do nothing in this case).
    
    Therefore we do that and move the branch code to Buffer where it belongs.
    
    Note that there was a bug in the previous code that broke undo support: 
recordUndo should always be called _before_ doing any change.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index c2a46f1..43b5ecd 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2246,57 +2246,70 @@ bool Buffer::getStatus(FuncRequest const & cmd, 
FuncStatus & flag)
 
        switch (cmd.action()) {
 
-               case LFUN_BUFFER_TOGGLE_READ_ONLY:
-                       flag.setOnOff(isReadonly());
-                       break;
+       case LFUN_BUFFER_TOGGLE_READ_ONLY:
+               flag.setOnOff(isReadonly());
+               break;
 
                // FIXME: There is need for a command-line import.
                //case LFUN_BUFFER_IMPORT:
 
-               case LFUN_BUFFER_AUTO_SAVE:
-                       break;
+       case LFUN_BUFFER_AUTO_SAVE:
+               break;
 
-               case LFUN_BUFFER_EXPORT_CUSTOM:
-                       // FIXME: Nothing to check here?
-                       break;
+       case LFUN_BUFFER_EXPORT_CUSTOM:
+               // FIXME: Nothing to check here?
+               break;
 
-               case LFUN_BUFFER_EXPORT: {
-                       docstring const arg = cmd.argument();
-                       if (arg == "custom") {
-                               enable = true;
-                               break;
-                       }
-                       string format = to_utf8(arg);
-                       size_t pos = format.find(' ');
-                       if (pos != string::npos)
-                               format = format.substr(0, pos);
-                       enable = params().isExportable(format);
-                       if (!enable)
-                               flag.message(bformat(
-                                       _("Don't know how to export to format: 
%1$s"), arg));
+       case LFUN_BUFFER_EXPORT: {
+               docstring const arg = cmd.argument();
+               if (arg == "custom") {
+                       enable = true;
                        break;
                }
+               string format = to_utf8(arg);
+               size_t pos = format.find(' ');
+               if (pos != string::npos)
+                       format = format.substr(0, pos);
+               enable = params().isExportable(format);
+               if (!enable)
+                       flag.message(bformat(
+                                            _("Don't know how to export to 
format: %1$s"), arg));
+               break;
+       }
 
-               case LFUN_BUFFER_CHKTEX:
-                       enable = params().isLatex() && 
!lyxrc.chktex_command.empty();
-                       break;
+       case LFUN_BUFFER_CHKTEX:
+               enable = params().isLatex() && !lyxrc.chktex_command.empty();
+               break;
 
-               case LFUN_BUILD_PROGRAM:
-                       enable = params().isExportable("program");
-                       break;
+       case LFUN_BUILD_PROGRAM:
+               enable = params().isExportable("program");
+               break;
 
-               case LFUN_BRANCH_ADD:
-               case LFUN_BRANCHES_RENAME:
-               case LFUN_BUFFER_PRINT:
-                       // if no Buffer is present, then of course we won't be 
called!
-                       break;
+       case LFUN_BRANCH_ACTIVATE:
+       case LFUN_BRANCH_DEACTIVATE:
+       case LFUN_BRANCH_MASTER_ACTIVATE:
+       case LFUN_BRANCH_MASTER_DEACTIVATE: {
+               bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
+                                    || cmd.action() == 
LFUN_BRANCH_MASTER_DEACTIVATE);
+               BranchList const & branchList = master ? 
masterBuffer()->params().branchlist()
+                       : params().branchlist();
+               docstring const branchName = cmd.argument();
+               flag.setEnabled(!branchName.empty() && 
branchList.find(branchName));
+               break;
+       }
 
-               case LFUN_BUFFER_LANGUAGE:
-                       enable = !isReadonly();
-                       break;
+       case LFUN_BRANCH_ADD:
+       case LFUN_BRANCHES_RENAME:
+       case LFUN_BUFFER_PRINT:
+               // if no Buffer is present, then of course we won't be called!
+               break;
 
-               default:
-                       return false;
+       case LFUN_BUFFER_LANGUAGE:
+               enable = !isReadonly();
+               break;
+
+       default:
+               return false;
        }
        flag.setEnabled(enable);
        return true;
@@ -2404,6 +2417,42 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
                resetAutosaveTimers();
                break;
 
+       case LFUN_BRANCH_ACTIVATE:
+       case LFUN_BRANCH_DEACTIVATE:
+       case LFUN_BRANCH_MASTER_ACTIVATE:
+       case LFUN_BRANCH_MASTER_DEACTIVATE: {
+               bool const master = (func.action() == 
LFUN_BRANCH_MASTER_ACTIVATE
+                                    || func.action() == 
LFUN_BRANCH_MASTER_DEACTIVATE);
+               Buffer * buf = master ? const_cast<Buffer *>(masterBuffer())
+                                     : this;
+
+               docstring const branch_name = func.argument();
+               // the case without a branch name is handled elsewhere
+               if (branch_name.empty()) {
+                       dispatched = false;
+                       break;
+               }
+               Branch * branch = buf->params().branchlist().find(branch_name);
+               if (!branch) {
+                       LYXERR0("Branch " << branch_name << " does not exist.");
+                       dr.setError(true);
+                       docstring const msg =
+                               bformat(_("Branch \"%1$s\" does not exist."), 
branch_name);
+                       dr.setMessage(msg);
+                       break;
+               }
+               bool const activate = (func.action() == LFUN_BRANCH_ACTIVATE
+                                      || func.action() == 
LFUN_BRANCH_MASTER_ACTIVATE);
+               if (branch->isSelected() != activate) {
+                       buf->undo().recordUndoFullDocument(CursorData());
+                       branch->setSelected(activate);
+                       dr.setError(false);
+                       dr.screenUpdate(Update::Force);
+                       dr.forceBufferUpdate();
+               }
+               break;
+       }
+
        case LFUN_BRANCH_ADD: {
                docstring branch_name = func.argument();
                if (branch_name.empty()) {
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 8d84baa..daa05a6 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1186,22 +1186,6 @@ bool BufferView::getStatus(FuncRequest const & cmd, 
FuncStatus & flag)
                break;
        }
 
-       // FIXME We do not really want this here, but at present we need to
-       // handle their dispatch here, for reasons explained there, so we'll
-       // handle this here, too, for consistency.
-       case LFUN_BRANCH_ACTIVATE:
-       case LFUN_BRANCH_DEACTIVATE:
-       case LFUN_BRANCH_MASTER_ACTIVATE:
-       case LFUN_BRANCH_MASTER_DEACTIVATE: {
-               bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
-                                   || cmd.action() == 
LFUN_BRANCH_MASTER_DEACTIVATE);
-               BranchList const & branchList = master ? 
buffer().masterBuffer()->params().branchlist()
-                                                      : 
buffer().params().branchlist();
-               docstring const branchName = cmd.argument();
-               flag.setEnabled(!branchName.empty() && 
branchList.find(branchName));
-               break;
-       }
-
        default:
                return false;
        }
@@ -1988,48 +1972,6 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                break;
        }
 
-       // FIXME We do not really want this here, but it has to be at present
-       // because we need a cursor for the recordUndoFullDocument call. What
-       // we would really like is a recordUndoBufferParams call that did not
-       // need a cursor, but we do not have that yet.
-       // So, if this does get fixed, this code can be moved back to 
Buffer.cpp,
-       // and the corresponding code in getStatus() should be moved back, too.
-       case LFUN_BRANCH_ACTIVATE:
-       case LFUN_BRANCH_DEACTIVATE:
-       case LFUN_BRANCH_MASTER_ACTIVATE:
-       case LFUN_BRANCH_MASTER_DEACTIVATE: {
-               bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
-                                    || cmd.action() == 
LFUN_BRANCH_MASTER_DEACTIVATE);
-               Buffer * buf = master ? const_cast<Buffer 
*>(buffer().masterBuffer())
-                                     : &buffer();
-
-               docstring const branch_name = cmd.argument();
-               // the case without a branch name is handled elsewhere
-               if (branch_name.empty()) {
-                       dispatched = false;
-                       break;
-               }
-               Branch * branch = buf->params().branchlist().find(branch_name);
-               if (!branch) {
-                       LYXERR0("Branch " << branch_name << " does not exist.");
-                       dr.setError(true);
-                       docstring const msg =
-                               bformat(_("Branch \"%1$s\" does not exist."), 
branch_name);
-                       dr.setMessage(msg);
-                       break;
-               }
-               bool activate = (cmd.action() == LFUN_BRANCH_ACTIVATE
-                                || cmd.action() == 
LFUN_BRANCH_MASTER_ACTIVATE);
-               if (branch->isSelected() != activate) {
-                       branch->setSelected(activate);
-                       cur.recordUndoFullDocument();
-                       dr.setError(false);
-                       dr.screenUpdate(Update::Force);
-                       dr.forceBufferUpdate();
-               }
-               break;
-       }
-
        default:
                // OK, so try the Buffer itself...
                buffer_.dispatch(cmd, dr);

-----------------------------------------------------------------------

Summary of changes:
 src/Buffer.cpp     |  125 ++++++++++++++++++++++++++++++++++++----------------
 src/BufferView.cpp |   58 ------------------------
 2 files changed, 87 insertions(+), 96 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to