This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 134937

Summary: Editor displays difference on line after "Push to default"
Product: versioncontrol Reporter: Petr Dvorak <joshis>
Component: MercurialAssignee: issues@versioncontrol <issues>
Status: VERIFIED FIXED    
Severity: blocker CC: jlahoda
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: proposed patch

Description Petr Dvorak 2008-05-13 10:55:29 UTC
Product Version: NetBeans IDE Dev (Build 200805130003)
Java: 1.5.0_14; Java HotSpot(TM) Client VM 1.5.0_14-b03
System: Linux version 2.6.22-14-generic running on i386; UTF-8; en_US (nb)

I don't know if this isn't an issue of "diff" or of "editor", please reassign if appropriate. In any case, this is a
minor issue (p4 or maybe even p5, as it is not common to develop project and its clone on 1 PC in the same time).

1. Create a new project (suppose there is a "main.java" file), initialize a mercurial repository, do the first commit,
open main.java in the editor if it is not already opened
2. Clone the project, edit the main.java file from the clone by adding some line (i.e. add a line bellow the TODO
comment in the "int main"), save file and do a commit (on the clone)
3. Update the clone, invoke "Push to default"
4. Open the main.java from the original file (it is already opened, just switch to the tab)
-> there is a green mark in the beginning of the line in the place where a line was added, indicating the added line. If
you close and reopen the same file (main.java from the original), the green mark is not there anymore. It seems that if
you push to some opened file, the diff in the editor accepts the event as if someone typed the changes manually.
Comment 1 Padraig Obriain 2008-05-15 08:41:10 UTC
I can reproduce this problem.
Comment 2 Padraig Obriain 2008-05-15 08:42:50 UTC
Transferring to editor for help in understanding that causes the green mark to be displayed.
Comment 3 Jan Lahoda 2008-05-19 08:34:42 UTC
No idea why this was reassigned to the editor - the green mark is provided by the versioning system and generally means
that the file is modified when compared with the repository version. Please note that the displayed status is
inconsistent - the file is marked as up-to-date (black) in projects tab, but yet the line is marked as added.
Comment 4 Maros Sandor 2008-05-22 13:46:39 UTC
This has to be fixed in mercurial ... it seems that getOriginalFile() method returns a wrong version of the file thus
causing inline diff to show differences. The method is called every time a file is opened in editor.
Comment 5 Padraig Obriain 2008-05-22 15:08:16 UTC
I see no evidence that getOriginalFile is being called when step 4 (switch to tab of original file) is done
Comment 6 Padraig Obriain 2008-05-22 15:14:37 UTC
I am seeing DiffSideBar$RefreshDiffTask.fetchOriginalContent being called and originalContentBufferSerial =
originalContentSerial so getText is not called. My understaning is that getText is what causes getOriginalFile to be called.
Comment 7 Padraig Obriain 2008-05-23 14:00:18 UTC
if I add a call to initialize() to insertUpdate in DiffSidebar.java the problem does not occur.

After the call to hg push, hg update is called on the target repository and this causes Main.java to be changed in the
working directory. It looks like DiffSidebar.java is not aware that getOriginalFile need to be called on Main.java.
Comment 8 Maros Sandor 2008-05-26 10:25:25 UTC
originalContentBufferSerial == originalContentSerial is an indication that the diff sidebar did not detect any change in
the file status. In this case, it is still mercurial to blame ;-) You need to fire status change event for that file
from MercurialVCS so that diff sidebar refreshes its cache.
Comment 9 Padraig Obriain 2008-05-26 12:04:28 UTC
Created attachment 61907 [details]
proposed patch
Comment 10 Padraig Obriain 2008-05-26 12:11:08 UTC
I have added -v option to HgCommand.doUpdateAll to get the list of file which are changed by hg update command.
Then fire sttaus change for each file.

This seems to fix the problem. 
Comment 11 Padraig Obriain 2008-05-26 12:15:57 UTC
changeset:   81563:69ec3771b81c
tag:         tip
user:        padraigob@netbeans.org
date:        Mon May 26 11:59:55 2008 +0100
summary:     134937: Fire status change event for files updated after push
Comment 12 John Rice 2008-05-27 14:57:56 UTC
Same problem exists for local Pull.
Comment 13 Padraig Obriain 2008-05-29 11:37:36 UTC
Logged issue 136066 for pull issue so marking this bug as fixed..
Comment 14 Petr Dvorak 2008-06-25 12:40:51 UTC
Verified (200806240008)