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 29819 - RFE: Remove *.orig files after the Patch was successfully applied and The Diff Window was closed
Summary: RFE: Remove *.orig files after the Patch was successfully applied and The Dif...
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Diff (show other bugs)
Version: 3.x
Hardware: All All
: P4 blocker (vote)
Assignee: _ mihmax
URL:
Keywords: SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2003-01-06 20:28 UTC by _ mihmax
Modified: 2003-12-11 14:20 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
An unidiff patch to accomplish RFE (2.47 KB, patch)
2003-07-01 16:01 UTC, _ mihmax
Details | Diff
Corrected patch upon Martin's comments (3.06 KB, patch)
2003-08-03 21:51 UTC, _ mihmax
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ mihmax 2003-01-06 20:28:10 UTC
When I apply a big and complex patch, a lot of
files original.file.name.orig appear near the
patched files. 

I searched through Tools->Options and din't find a
one to turn creating these files Off. Hence filing
a low-priority RFE.
Comment 1 Martin Entlicher 2003-01-07 09:56:08 UTC
O.K., it might have sense. E.g. if you files are in CVS you do not
care about an extra .orig file.

Scheduling for 'future' for now...
Comment 2 _ mihmax 2003-06-19 15:40:52 UTC
Martin,
why these .orig files appear at all? What design document covers that
and who is the designer? 

I think they are useless, that's why I'd like to argue a bit with the
designer of diff feature. 

And, imho, we have too many of options in NB, so I rephrase this RFE
simply to remove .orig files at all. If this is unacceptable for some
serious reason, fell free to close this RFE as WONTFIX.
Comment 3 Martin Entlicher 2003-06-19 15:57:08 UTC
The POSIX patch command has --backup-if-mismatch as the default
option. So perhaps we should use the same approach and create the
.orig file only in case the patch was not successfully applied.

Currently the .orig file is also used by subsequent diff if you want
to view the applied changes. So perhaps we should create the .orig
file every time and delete it after the GUI diff was closed and the
patch was successfully applied.
Comment 4 Martin Entlicher 2003-06-19 16:02:21 UTC
To answer your questions:
The designer is me and there is no design document that covers this.
The goal is to behave in a similar way to UNIX patch, but this goal
was not reached yet.
The .orig files were introduced just to be sure that there will be no
data loss when something goes wrong.
Comment 5 _ mihmax 2003-06-19 17:07:14 UTC
OK, Martin, so diff _has_ _to_ create .orig files in order to:
1. view the successfully applyed changes
2. have a backup if the patch is not applyed successfully

Do you agree with the following formulation:
RFE: Remove *.orig files after the Patch was successfully applied and
The Diff Window was closed
?
Comment 6 Martin Entlicher 2003-06-19 17:31:56 UTC
Yes, that's perfect. Thanks Maxym.
Comment 7 Martin Entlicher 2003-06-19 17:32:58 UTC
Scheduling for 4.0, this should not be hard to fix.
Comment 8 _ mihmax 2003-06-19 17:34:30 UTC
Any comments what code I may look at to try implementing this RFE? (no
promises ;-(( )
Comment 9 Martin Entlicher 2003-06-19 17:47:36 UTC
org.netbeans.modules.diff.PatchAction. Look at applyFileDiffs()
method. A problem can be to detect that the GUI diff is closed, but it
might be safe to delete the backup files after showDiffs() method
finishes. That would have to be verified.

Thanks for your involvement!

Comment 10 _ mihmax 2003-06-25 22:21:10 UTC
Martin,

I finally got some small time to do a little debugging/testing. I
beleive I should do this on trunk. I suppose the patch is to be ready
in about a week.
Comment 11 _ mihmax 2003-06-25 22:23:29 UTC
actually it's about two hours of work, but I have too little free time
recently (hmm, about half-year now ;-( )
Comment 12 _ mihmax 2003-07-01 16:01:34 UTC
Created attachment 10847 [details]
An unidiff patch to accomplish RFE
Comment 13 _ mihmax 2003-07-01 16:09:52 UTC
Martin, it's really a simple patch, though not a final, because files
like "JFrame.form.orig~" still appear, do you know how to suppress
appearing backup files?
Comment 14 Martin Entlicher 2003-07-04 13:10:22 UTC
Thanks Maxym. The backup files are created by a filesystem when we
write to *.orig file (filesystem creates *.orig~ automatically).
When the FileObject is deleted, *.orig~ files stay there. This can not
be solved by the diff module. The filesystem would have to delete the
*.orig~ file when *.orig file is being deleted, but then it's not a
real backup :-)

Anyway, backups should not be visible in Explorer, so the behavior
should be better. I will only add a condition for "patchFailed"
variable, so that the .orig files are not removed in case the patching
failed.

The filesystems would have to be set not to backup *.orig files by
default to get rid of *.orig~. Backup options will probably change in
4.0 so this can be left for 4.0.
Comment 15 Martin Entlicher 2003-07-04 13:16:03 UTC
Also the error report inside the loop is not nice. If there are 20
files and delete of them will fail, the user will get 20 error
dialogs. Either it's necessary to remember the file names and notify
the error only once at the end of the cycle or ignore the exception
altogether. IMHO it's not such a big deal to disturb the user, at
worse the .orig file will stay around.
Comment 16 _ mihmax 2003-07-07 10:38:00 UTC
I'll rewrite a patch in two weeks (I have a vaction now)
Comment 17 _ mihmax 2003-08-03 21:51:48 UTC
Created attachment 11196 [details]
Corrected patch upon Martin's comments
Comment 18 _ mihmax 2003-08-03 21:54:36 UTC
Martin, sorry it took so long (it wasn't a vacation lasting so long ;-( ),

Now the corrected version of a patch.

Of course, the new Filesystem properties (not to store .orig~ files)
are not there, though in Local Filesystem there's no sence of them
Comment 19 Martin Entlicher 2003-08-04 17:54:53 UTC
Thanks Maxym. The patch looks good, I've committed it into the main
trunk and projects branch:

Checking in Bundle.properties;
/cvs/diff/src/org/netbeans/modules/diff/Bundle.properties,v  <-- 
Bundle.properties
new revision: 1.18; previous revision: 1.17
done
Checking in PatchAction.java;
/cvs/diff/src/org/netbeans/modules/diff/PatchAction.java,v  <-- 
PatchAction.java
new revision: 1.13; previous revision: 1.12
done

Checking in Bundle.properties;
/cvs/diff/src/org/netbeans/modules/diff/Bundle.properties,v  <-- 
Bundle.properties
new revision: 1.17.8.1; previous revision: 1.17
done
Checking in PatchAction.java;
/cvs/diff/src/org/netbeans/modules/diff/PatchAction.java,v  <-- 
PatchAction.java
new revision: 1.12.2.1; previous revision: 1.12
done