The branch, 2.0.x, has been updated.

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

commit 4d267e4f79c64e48614ce6409672eeb378a80bc8
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 8dc13c3..36d9b1f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2119,49 +2119,57 @@ 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();
-                       enable = arg == "custom" || 
params().isExportable(to_utf8(arg));
-                       if (!enable)
-                               flag.message(bformat(
-                                       _("Don't know how to export to format: 
%1$s"), arg));
-                       break;
-               }
+       case LFUN_BUFFER_EXPORT: {
+               docstring const arg = cmd.argument();
+               enable = arg == "custom" || params().isExportable(to_utf8(arg));
+               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: {
+               BranchList const & 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;
@@ -2266,6 +2274,35 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
                resetAutosaveTimers();
                break;
 
+       case LFUN_BRANCH_ACTIVATE:
+       case LFUN_BRANCH_DEACTIVATE: {
+               BranchList & branch_list = params().branchlist();
+               docstring const branch_name = func.argument();
+               // the case without a branch name is handled elsewhere
+               if (branch_name.empty()) {
+                       dispatched = false;
+                       break;
+               }
+               Branch * branch = branch_list.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 = func.action() == LFUN_BRANCH_ACTIVATE;
+               if (branch->isSelected() != activate) {
+                       undo().recordUndoFullDocument(DocIterator());
+                       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 d490fe7..4ca03d5 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1170,17 +1170,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: {
-               BranchList const & branchList = buffer().params().branchlist();
-               docstring const branchName = cmd.argument();
-               flag.setEnabled(!branchName.empty() && 
branchList.find(branchName));
-               break;
-       }
-
        default:
                return false;
        }
@@ -1935,40 +1924,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: {
-               BranchList & branch_list = buffer().params().branchlist();
-               docstring const branch_name = cmd.argument();
-               // the case without a branch name is handled elsewhere
-               if (branch_name.empty()) {
-                       dispatched = false;
-                       break;
-               }
-               Branch * branch = branch_list.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;
-               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...
diff --git a/status.20x b/status.20x
index 146ccda..aa9cd83 100644
--- a/status.20x
+++ b/status.20x
@@ -61,6 +61,10 @@ What's new
 - Fix bug where searching for next change may leave an empty paragraph
   where cursor was (bug 3199).
 
+- Fix activation of branches from command line (bug 8627).
+
+- Handle correctly undo when a branch is (de)activated.
+
 * DOCUMENTATION AND LOCALIZATION
 
 

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

Summary of changes:
 src/Buffer.cpp     |  101 +++++++++++++++++++++++++++++++++++----------------
 src/BufferView.cpp |   45 -----------------------
 status.20x         |    4 ++
 3 files changed, 73 insertions(+), 77 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to