Menu

#776 With team projects, project TM is modified even when no changes are made

None
closed-out-of-date
nobody
None
5
2016-03-18
2015-10-16
No

With the current team project implementation the following can happen:

  1. User A commits changes with OmegaT 3.5.A.
  2. User B merely opens project with OmegaT 3.5.B, and closes the project without making any changes.
  3. The source files of the project are modified.
  4. User B opens the project again and is greeted with the TEAM_NOCHECKOUT message, which is fairly scary and confusing. A full-project sync is not performed, so user B does not see the changes to the source.

The cause is at step 2: RealProject.rebaseProject() is called on close, and because it uses ProjectTMX.exportTMX() to back up the current project TM the backup TMX's version header reads "OmegaT 3.5.B" while the original was "OmegaT 3.5.A". This change is not synced to the server, and prevents proper syncing on the next open.

The following diff illustrates a potential fix: Copy the file instead of using exportTMX().

diff --git a/src/org/omegat/core/data/RealProject.java b/src/org/omegat/core/data/RealProject.java
index 9a9de07..31e4762 100644
--- a/src/org/omegat/core/data/RealProject.java
+++ b/src/org/omegat/core/data/RealProject.java
@@ -88,6 +88,7 @@ import org.omegat.tokenizer.DefaultTokenizer;
 import org.omegat.tokenizer.ITokenizer;
 import org.omegat.util.DirectoryMonitor;
 import org.omegat.util.FileUtil;
+import org.omegat.util.LFileCopy;
 import org.omegat.util.Language;
 import org.omegat.util.Log;
 import org.omegat.util.OConsts;
@@ -814,7 +815,7 @@ public class RealProject implements IProject {
             // save into ".new" file
             filenameTMXwithLocalChangesOnBase = new File(projectTMXFilename + "-based_on_" + baseRevTMX + OConsts.NEWFILE_EXTENSION);
             filenameGlossarywithLocalChangesOnBase = null;

-            projectTMX.exportTMX(m_config, filenameTMXwithLocalChangesOnBase, false, false, true); //overwrites file if it exists
+            LFileCopy.copy(projectTMXFile, filenameTMXwithLocalChangesOnBase); //overwrites file if it exists
             if (System.getProperty("team.supersafe") != null) {
                 // save supersafe backup
                 File bak = new File(projectTMXFilename + "-based_on_" + baseRevTMX + "_at_"

Since the team project implementation will change greatly in 3.6, I will not commit this change to trunk. This ticket is intented to serve as a reminder to address this issue if it is still present in the new implementation.

Discussion

  • Aaron Madlon-Kay

    A different potential fix that would work regardless of team implementation: Don't do team sync on project close if the project has not been modified.

    diff --git a/src/org/omegat/gui/main/ProjectUICommands.java b/src/org/omegat/gui/main/ProjectUICommands.java
    index ddf190d..c22b252 100644
    --- a/src/org/omegat/gui/main/ProjectUICommands.java
    +++ b/src/org/omegat/gui/main/ProjectUICommands.java
    @@ -495,7 +495,7 @@ public class ProjectUICommands {
    
                     Preferences.save();
    
    
    -                Core.getProject().saveProject();
    +                Core.getProject().saveProject(Core.getProject().isProjectModified());
    
                     Core.getMainWindow().showStatusMessageRB("MW_STATUS_SAVED");
                     mainWindow.setCursor(oldCursor);
    
     
  • Aaron Madlon-Kay

    I also like the second fix better because the first fix makes the project_save.tmx file the "true" TM instead of the in-memory representation.

     
  • Didier Briel

    Didier Briel - 2015-10-16

    The second fix sounds good.
    Not only it solves the issue, but it also saves significant time on a slow connection.
    Isn't it worth committing to /trunk?

    Didier

     
  • Aaron Madlon-Kay

    One annoyance with the second fix is that it can leave some other version-controlled files modified:

    1. Project is set up with project-specific omegat/filters.xml from OmegaT version X.
    2. OmegaT version Y adds new filters to default filter config.
    3. Users of version Y will now have a modified local filters.xml upon opening the project.
    4. filters.xml is reset to committed version on every rebaseProject(). But with the second fix above, opening and closing project without making changes leaves filters.xml modified.
    5. Upon reopening the project, with git the contents are properly blown away, but I'm not sure what happens with svn if the server version has changed such as to introduce a conflict.

    The same issue can happen with omegat.project: my projects were created before <source_dir_excludes> was added, so omegat.project is left with this still modified after close.

     

    Last edit: Aaron Madlon-Kay 2015-10-16
  • Aaron Madlon-Kay

    As I thought, there is the potential for conflicts here with svn:

    1. User's filters.xml is modified with default settings for newly added filters, per situation above.
    2. Project manager updates remote filters.xml with non-default settings for these added filters.
    3. Upon next open, user's filters.xml will be in a conflicted state, and will fail to load. This results in default filter settings.
    4. I think the only way filters.xml can be restored to a normal state without special intervention is by rebaseProject(), but this now requires the user to manually save the project or wait for autosave, and then reload to get the correct filter settings loaded.

    The solution for this would be for SVNRemoteRepository.updateFullProject() to do a reset in addition to an update.

     

    Last edit: Aaron Madlon-Kay 2015-10-16
  • Aaron Madlon-Kay

    Even if we have updateFullProject do a reset, it is still the case that simply opening and closing the project leaves it in a needlessly modified state. What we really want is for rebaseProject to not leave the project modified if everything went smoothly (we are online and had no errors).

    For my purposes, then, the solution is to reset at the end of rebaseProject if we are online (if we are offline we must not reset).

    diff --git a/src/org/omegat/core/data/RealProject.java b/src/org/omegat/core/data/RealProject.java
    index dd6ae27..4213f32 100644
    --- a/src/org/omegat/core/data/RealProject.java
    +++ b/src/org/omegat/core/data/RealProject.java
    @@ -1017,6 +1017,22 @@ public class RealProject implements IProject {
                     throw new KnownException(ex, "TEAM_SYNCHRONIZATION_ERROR");
                 }
             }
    
    +        
    +        // Reset project again here to address bug 776:
    +        // With team projects, project TM is modified even when no changes are made
    +        // https://sourceforge.net/p/omegat/bugs/776/
    +        //
    +        // This should be OK because if we have made it this far *while online* then
    +        // the important changes made by the rebase loop are still in memory and were
    +        // pushed to the server.
    +        if (isOnlineMode) {
    +            unlockProject(); // So that we are able to replace omegat.project
    +            try {
    +                repository.reset();
    +            } finally {
    +                lockProject(); // we restore the lock
    +            }
    +        }
             Log.logInfoRB("TEAM_REBASE_END");
         }
    
     

    Last edit: Aaron Madlon-Kay 2015-10-19
  • Aaron Madlon-Kay

    • status: open --> closed-out-of-date
     
  • Aaron Madlon-Kay

    This appears to have been addressed in [feature-requests:#1189].

     

    Related

    Feature Requests: #1189


Log in to post a comment.

MongoDB Logo MongoDB