You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Becroft <dj...@gmail.com> on 2011/02/08 22:34:53 UTC
[PATCH] Fix issue #3686 - executable bit not set during merge
Hi,
Attached is a completed patch to resolve issue 3686[1], where the executable
bit is not maintained during the merge of a binary file.
I thought about making this change more generic, and applying it to text
files as well (there was discussion with performance of simple-case merging
a month ago on users@), but thought I'd leave that for later. I didn't want
to worry about (potential) line-endings, keywords, etc. problems.
[[[
Fix issue #3686 - executable bit not set during merge.
The cause was the special case in libsvn_client, which bypassed the use of
the
workqueue. This logic has now been moved into libsvn_wc.
Additionally, this change allows the status of binary files (during a
dry-run
merge) to be reported correctly (previously, all binary files were reported
as
conflicted).
* subversion/libsvn_client/merge.c
(merge_file_changed): Removed binary-merge special case (now in libsvn_wc).
Removed merge_required variable (resulting in indentation changes).
* subversion/libsvn_wc/merge.c
(merge_binary_file): Added dry_run parameter. Add the special case merging
of binary files.
* subversion/tests/cmdline/merge_tests.py
(merge_change_to_file_with_executable): Remove @XFail decorator.
]]]
[1]
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=463&dsMessageId=2635024
Cheers,
Daniel B.
---
Daniel Becroft
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Stefan Sperling wrote on Tue, Mar 01, 2011 at 14:01:54 +0100:
> On Tue, Mar 01, 2011 at 07:24:56PM +1100, Gavin Beau Baumanis wrote:
> > Ping. This submission has received no new comments.
>
> Thanks for the reminder. Committed in r1075802.
Thanks, Stefan.
(The patch had swapped out for me since my original review; that's why
I couldn't promptly review the resubmission.)
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Stefan Sperling <st...@elego.de>.
On Tue, Mar 01, 2011 at 07:24:56PM +1100, Gavin Beau Baumanis wrote:
> Ping. This submission has received no new comments.
Thanks for the reminder. Committed in r1075802.
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Gavin Beau Baumanis <ga...@thespidernet.com>.
Ping. This submission has received no new comments.
On 22/02/2011, at 8:31 AM, Daniel Becroft wrote:
> On Sun, Feb 13, 2011 at 2:15 AM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> Daniel Becroft wrote on Sat, Feb 12, 2011 at 08:37:12 +1000:
> > On Sat, Feb 12, 2011 at 7:31 AM, Daniel Shahaf <d....@daniel.shahaf.name>wrote:
> >
> > > Daniel Becroft wrote on Sat, Feb 12, 2011 at 06:27:31 +1000:
> > > > On Fri, Feb 11, 2011 at 11:26 PM, Daniel Shahaf <d.s@daniel.shahaf.name
> > > >wrote:
> > > > > Daniel Becroft wrote on Thu, Feb 10, 2011 at 07:21:30 +1000:
> > > > > > @@ -1118,6 +1120,33 @@ merge_binary_file(svn_skel_t **work_items,
> > > > > > + /* Attempt to merge the binary file. At the moment, we can only
> > > > > > + handle the special case: if the LEFT side of the merge is equal
> > > > > > + to WORKING, then we can copy RIGHT directly. */
> > > > >
> > > > > The comment in libsvn_client mentioned two special case, what happened
> > > > > to the other one? Does the existing wc code already handle it? (I'd be
> > > > > surprised)
> > > > >
> > > > > - Alternately, if the 'left' side of the merge doesn't exist
> > > in
> > > > > - the repository, and the 'right' side of the merge is
> > > > > - identical to the WC, pretend we did the merge (a no-op).
> > > > >
> > > >
> > > > I've been trying to think of a valid scenario for this to occur, but I
> > > can't
> > > > seem to think of one. There's a comment further up:
> > > >
> > >
> > > Concocted:
> > > % svn add foo.bin
> > > % svn ci -m r5
> > > % svn rm ^/foo.bin -m r6
> > > % svnmucc -m r7 put foo.bin ^/foo.bin
> > > % svn merge -c7 ^/ ./
> > >
> >
> > Maybe it's early, and the coffee hasn't kicked in yet, but wouldn't (and
> > shouldn't) this give a tree-conflict? foo.bin@7 and foo.bin in the WC are
> > two different nodes (with the same name).
> >
>
> I hadn't considered that this might be a tree conflict (an add of an
> already-existing file with the same contents). My point was not the
> tree conflict but that the scenario described in the "Alternately" can
> happen.
>
> I've looked through this several times now to try and be sure that I'm not missing anything.
>
> Previously, the "Special case" block handled both when to merge the binary file, as well as how. Now, the "when" logic is now the same logic as text files, and the how has been moved into libsvn_wc (rather than libsvn_client).
>
> I've attached the file version of the patch.
>
> > > > /* Other easy outs: if the merge target isn't under version
> > > > control, or is just missing from disk, fogettaboutit. There's no
> > > > way svn_wc_merge4() can do the merge. */
> > > >
> > > > This should apply to all situations (binary and text files), so I think
> > > this
> > > > second "special case" is redundant.
> > > >
> > >
> > > Not sure. If the merge-left does not exist, and the local file doesn't
> > > exist either, then the situation is 'compatible' and can be merged...
> > >
> >
> > Isn't this just an incoming add (which is handled by a different function)?
> >
>
> I don't know the code very well. If you're saying that at the point of
> the comment we know that the merge-left exists, then I agree that it
> makes sense to flag a conflict if the merge target is non-existent.
>
> Yep, this is already done as part of the standard merge logic (ie why doesn't left exist? It is an incoming add, or already deleted in the WC, etc).
>
>
> > > > I can submit a follow-up patch that fixes this as well, if necessary.
> > >
> > > That would be great, assuming that the FALSE *really* should be changed
> > > to TRUE. (I haven't investigated that myself.)
> > >
> >
> > Not sure what is is in reference to. I was thinking of just putting a if
> > (content_state) before the local modifications check (again, coffee may not
> > have kicked in yet).
> >
>
> I was trying to say: "It would be great if you could look further into
> that matter, but I haven't done so myself yet so I don't know if a patch
> is required or the current code is correct."
>
> Gotcha (I just couldn't figure out where the TRUE/FALSE reference came from), but anywho ...
>
> In other words, thanks for looking into this, but I don't know myself
> whether a follow-up patch would be necessary.
>
> > Cheers,
> > Daniel^2.
>
> HTH
>
> Yep. I've attached the (final) version of the patch (generated with the C functions this time), and the log message is below.
>
> [[[
> Fix issue #3686 - executable bit not set during merge.
>
> The cause was the special case in libsvn_client, which bypassed the use of the
> workqueue. This logic has now been moved into libsvn_wc.
>
> Additionally, this change allows the status of binary files (during a dry-run
> merge) to be reported correctly (previously, all binary files were reported as
> conflicted).
>
> * subversion/libsvn_client/merge.c
> (merge_file_changed): Remove binary-merge special case (now in libsvn_wc).
> Remove merge_required variable (resulting in indentation changes).
>
> * subversion/libsvn_wc/merge.c
> (merge_binary_file): Add dry_run parameter. Add the special case merging
> of binary files.
> (svn_wc__internal_merge): Remove dry_run check for binary files, and pass to
> merge_binary_file instead.
>
> * subversion/tests/cmdline/merge_tests.py
> (merge_change_to_file_with_executable): Remove @XFail decorator.
> ]]]
>
> Let me know if there's anything else I need to fix up.
>
> Cheers,
> Daniel B.
>
> <3686_3.patch>
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Becroft <dj...@gmail.com>.
On Sun, Feb 13, 2011 at 2:15 AM, Daniel Shahaf <d....@daniel.shahaf.name>wrote:
> Daniel Becroft wrote on Sat, Feb 12, 2011 at 08:37:12 +1000:
> > On Sat, Feb 12, 2011 at 7:31 AM, Daniel Shahaf <d.s@daniel.shahaf.name
> >wrote:
> >
> > > Daniel Becroft wrote on Sat, Feb 12, 2011 at 06:27:31 +1000:
> > > > On Fri, Feb 11, 2011 at 11:26 PM, Daniel Shahaf <
> d.s@daniel.shahaf.name
> > > >wrote:
> > > > > Daniel Becroft wrote on Thu, Feb 10, 2011 at 07:21:30 +1000:
> > > > > > @@ -1118,6 +1120,33 @@ merge_binary_file(svn_skel_t **work_items,
> > > > > > + /* Attempt to merge the binary file. At the moment, we can
> only
> > > > > > + handle the special case: if the LEFT side of the merge is
> equal
> > > > > > + to WORKING, then we can copy RIGHT directly. */
> > > > >
> > > > > The comment in libsvn_client mentioned two special case, what
> happened
> > > > > to the other one? Does the existing wc code already handle it?
> (I'd be
> > > > > surprised)
> > > > >
> > > > > - Alternately, if the 'left' side of the merge doesn't
> exist
> > > in
> > > > > - the repository, and the 'right' side of the merge is
> > > > > - identical to the WC, pretend we did the merge (a no-op).
> > > > >
> > > >
> > > > I've been trying to think of a valid scenario for this to occur, but
> I
> > > can't
> > > > seem to think of one. There's a comment further up:
> > > >
> > >
> > > Concocted:
> > > % svn add foo.bin
> > > % svn ci -m r5
> > > % svn rm ^/foo.bin -m r6
> > > % svnmucc -m r7 put foo.bin ^/foo.bin
> > > % svn merge -c7 ^/ ./
> > >
> >
> > Maybe it's early, and the coffee hasn't kicked in yet, but wouldn't (and
> > shouldn't) this give a tree-conflict? foo.bin@7 and foo.bin in the WC
> are
> > two different nodes (with the same name).
> >
>
> I hadn't considered that this might be a tree conflict (an add of an
> already-existing file with the same contents). My point was not the
> tree conflict but that the scenario described in the "Alternately" can
> happen.
>
I've looked through this several times now to try and be sure that I'm not
missing anything.
Previously, the "Special case" block handled both when to merge the binary
file, as well as how. Now, the "when" logic is now the same logic as text
files, and the how has been moved into libsvn_wc (rather than
libsvn_client).
I've attached the file version of the patch.
> > > /* Other easy outs: if the merge target isn't under version
> > > > control, or is just missing from disk, fogettaboutit. There's
> no
> > > > way svn_wc_merge4() can do the merge. */
> > > >
> > > > This should apply to all situations (binary and text files), so I
> think
> > > this
> > > > second "special case" is redundant.
> > > >
> > >
> > > Not sure. If the merge-left does not exist, and the local file doesn't
> > > exist either, then the situation is 'compatible' and can be merged...
> > >
> >
> > Isn't this just an incoming add (which is handled by a different
> function)?
> >
>
> I don't know the code very well. If you're saying that at the point of
> the comment we know that the merge-left exists, then I agree that it
> makes sense to flag a conflict if the merge target is non-existent.
>
Yep, this is already done as part of the standard merge logic (ie why
doesn't left exist? It is an incoming add, or already deleted in the WC,
etc).
>
> > > > I can submit a follow-up patch that fixes this as well, if necessary.
> > >
> > > That would be great, assuming that the FALSE *really* should be changed
> > > to TRUE. (I haven't investigated that myself.)
> > >
> >
> > Not sure what is is in reference to. I was thinking of just putting a if
> > (content_state) before the local modifications check (again, coffee may
> not
> > have kicked in yet).
> >
>
> I was trying to say: "It would be great if you could look further into
> that matter, but I haven't done so myself yet so I don't know if a patch
> is required or the current code is correct."
>
Gotcha (I just couldn't figure out where the TRUE/FALSE reference came
from), but anywho ...
> In other words, thanks for looking into this, but I don't know myself
> whether a follow-up patch would be necessary.
>
> > Cheers,
> > Daniel^2.
>
> HTH
Yep. I've attached the (final) version of the patch (generated with the C
functions this time), and the log message is below.
[[[
Fix issue #3686 - executable bit not set during merge.
The cause was the special case in libsvn_client, which bypassed the use of
the
workqueue. This logic has now been moved into libsvn_wc.
Additionally, this change allows the status of binary files (during a
dry-run
merge) to be reported correctly (previously, all binary files were reported
as
conflicted).
* subversion/libsvn_client/merge.c
(merge_file_changed): Remove binary-merge special case (now in libsvn_wc).
Remove merge_required variable (resulting in indentation changes).
* subversion/libsvn_wc/merge.c
(merge_binary_file): Add dry_run parameter. Add the special case merging
of binary files.
(svn_wc__internal_merge): Remove dry_run check for binary files, and pass
to
merge_binary_file instead.
* subversion/tests/cmdline/merge_tests.py
(merge_change_to_file_with_executable): Remove @XFail decorator.
]]]
Let me know if there's anything else I need to fix up.
Cheers,
Daniel B.
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Daniel Becroft wrote on Sat, Feb 12, 2011 at 08:37:12 +1000:
> On Sat, Feb 12, 2011 at 7:31 AM, Daniel Shahaf <d....@daniel.shahaf.name>wrote:
>
> > Daniel Becroft wrote on Sat, Feb 12, 2011 at 06:27:31 +1000:
> > > On Fri, Feb 11, 2011 at 11:26 PM, Daniel Shahaf <d.s@daniel.shahaf.name
> > >wrote:
> > > > Daniel Becroft wrote on Thu, Feb 10, 2011 at 07:21:30 +1000:
> > > > > @@ -1118,6 +1120,33 @@ merge_binary_file(svn_skel_t **work_items,
> > > > > + /* Attempt to merge the binary file. At the moment, we can only
> > > > > + handle the special case: if the LEFT side of the merge is equal
> > > > > + to WORKING, then we can copy RIGHT directly. */
> > > >
> > > > The comment in libsvn_client mentioned two special case, what happened
> > > > to the other one? Does the existing wc code already handle it? (I'd be
> > > > surprised)
> > > >
> > > > - Alternately, if the 'left' side of the merge doesn't exist
> > in
> > > > - the repository, and the 'right' side of the merge is
> > > > - identical to the WC, pretend we did the merge (a no-op).
> > > >
> > >
> > > I've been trying to think of a valid scenario for this to occur, but I
> > can't
> > > seem to think of one. There's a comment further up:
> > >
> >
> > Concocted:
> > % svn add foo.bin
> > % svn ci -m r5
> > % svn rm ^/foo.bin -m r6
> > % svnmucc -m r7 put foo.bin ^/foo.bin
> > % svn merge -c7 ^/ ./
> >
>
> Maybe it's early, and the coffee hasn't kicked in yet, but wouldn't (and
> shouldn't) this give a tree-conflict? foo.bin@7 and foo.bin in the WC are
> two different nodes (with the same name).
>
I hadn't considered that this might be a tree conflict (an add of an
already-existing file with the same contents). My point was not the
tree conflict but that the scenario described in the "Alternately" can
happen.
> I just tried the above (without svnmucc, but just a svn rm and svn add) with
> both 1.6.x, and trunk, and both raised a tree conflict:
>
> Using 1.6.x:
> --- Merging r3 into '.':
> C foo.txt
> Summary of conflicts:
> Tree conflicts: 1
>
> Using trunk:
> --- Merging r3 into '.':
> C foo.bin
> --- Recording mergeinfo for merge of r3 into '.':
> U .
> Summary of conflicts:
> Tree conflicts: 1
>
> Replacing the -c with a -r in the 'svn merge' command gives a status of "R
> foo.bin", which is correct.
>
Thanks for testing this :)
>
> > > /* Other easy outs: if the merge target isn't under version
> > > control, or is just missing from disk, fogettaboutit. There's no
> > > way svn_wc_merge4() can do the merge. */
> > >
> > > This should apply to all situations (binary and text files), so I think
> > this
> > > second "special case" is redundant.
> > >
> >
> > Not sure. If the merge-left does not exist, and the local file doesn't
> > exist either, then the situation is 'compatible' and can be merged...
> >
>
> Isn't this just an incoming add (which is handled by a different function)?
>
I don't know the code very well. If you're saying that at the point of
the comment we know that the merge-left exists, then I agree that it
makes sense to flag a conflict if the merge target is non-existent.
> > (that depends on where exactly the local file is missing --- in BASE, in
> > WORKING, or in ACTUAL)
> >
>
> I'll look into this a bit more. As I said, the behavior for binary files is
> now the same as text files, especially in terms of missing files in
> BASE/WORKING/ACTUAL. What that behavior is, I'm not 100% sure on.
>
Heh. Fair enough for me :-)
> <snipped />
>
>
> > > > You only need HAS_LOCAL_MODS now when CONTENT_STATE is set. Shouldn't
> > > > you skip this call when CONTENT_STATE is NULL then? (It may perform
> > > > stat() or read().)
> > > >
> > >
> > > Agreed, however this was always the case. The only change I made to this
> > > section was indentation
> > > due to removing the surrounding if (merge_required) { } clause.
> >
> > Oh, you're right. I was confused because the 'diff -w' patch showed
> > these two lines as removed and later re-added; your original patch
> > shows it correctly.
> >
> > Sorry for my confusion.
> >
> > > I didn't want to make other changes that would be clouded.
> > >
> >
> > +1
> >
> > > I can submit a follow-up patch that fixes this as well, if necessary.
> >
> > That would be great, assuming that the FALSE *really* should be changed
> > to TRUE. (I haven't investigated that myself.)
> >
>
> Not sure what is is in reference to. I was thinking of just putting a if
> (content_state) before the local modifications check (again, coffee may not
> have kicked in yet).
>
I was trying to say: "It would be great if you could look further into
that matter, but I haven't done so myself yet so I don't know if a patch
is required or the current code is correct."
In other words, thanks for looking into this, but I don't know myself
whether a follow-up patch would be necessary.
> Cheers,
> Daniel^2.
HTH,
Daniel
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Becroft <dj...@gmail.com>.
On Sat, Feb 12, 2011 at 7:31 AM, Daniel Shahaf <d....@daniel.shahaf.name>wrote:
> Daniel Becroft wrote on Sat, Feb 12, 2011 at 06:27:31 +1000:
> > On Fri, Feb 11, 2011 at 11:26 PM, Daniel Shahaf <d.s@daniel.shahaf.name
> >wrote:
> > > Daniel Becroft wrote on Thu, Feb 10, 2011 at 07:21:30 +1000:
> > > > @@ -1118,6 +1120,33 @@ merge_binary_file(svn_skel_t **work_items,
> > > > + /* Attempt to merge the binary file. At the moment, we can only
> > > > + handle the special case: if the LEFT side of the merge is equal
> > > > + to WORKING, then we can copy RIGHT directly. */
> > >
> > > The comment in libsvn_client mentioned two special case, what happened
> > > to the other one? Does the existing wc code already handle it? (I'd be
> > > surprised)
> > >
> > > - Alternately, if the 'left' side of the merge doesn't exist
> in
> > > - the repository, and the 'right' side of the merge is
> > > - identical to the WC, pretend we did the merge (a no-op).
> > >
> >
> > I've been trying to think of a valid scenario for this to occur, but I
> can't
> > seem to think of one. There's a comment further up:
> >
>
> Concocted:
> % svn add foo.bin
> % svn ci -m r5
> % svn rm ^/foo.bin -m r6
> % svnmucc -m r7 put foo.bin ^/foo.bin
> % svn merge -c7 ^/ ./
>
Maybe it's early, and the coffee hasn't kicked in yet, but wouldn't (and
shouldn't) this give a tree-conflict? foo.bin@7 and foo.bin in the WC are
two different nodes (with the same name).
I just tried the above (without svnmucc, but just a svn rm and svn add) with
both 1.6.x, and trunk, and both raised a tree conflict:
Using 1.6.x:
--- Merging r3 into '.':
C foo.txt
Summary of conflicts:
Tree conflicts: 1
Using trunk:
--- Merging r3 into '.':
C foo.bin
--- Recording mergeinfo for merge of r3 into '.':
U .
Summary of conflicts:
Tree conflicts: 1
Replacing the -c with a -r in the 'svn merge' command gives a status of "R
foo.bin", which is correct.
> > /* Other easy outs: if the merge target isn't under version
> > control, or is just missing from disk, fogettaboutit. There's no
> > way svn_wc_merge4() can do the merge. */
> >
> > This should apply to all situations (binary and text files), so I think
> this
> > second "special case" is redundant.
> >
>
> Not sure. If the merge-left does not exist, and the local file doesn't
> exist either, then the situation is 'compatible' and can be merged...
>
Isn't this just an incoming add (which is handled by a different function)?
> (that depends on where exactly the local file is missing --- in BASE, in
> WORKING, or in ACTUAL)
>
I'll look into this a bit more. As I said, the behavior for binary files is
now the same as text files, especially in terms of missing files in
BASE/WORKING/ACTUAL. What that behavior is, I'm not 100% sure on.
<snipped />
> > > You only need HAS_LOCAL_MODS now when CONTENT_STATE is set. Shouldn't
> > > you skip this call when CONTENT_STATE is NULL then? (It may perform
> > > stat() or read().)
> > >
> >
> > Agreed, however this was always the case. The only change I made to this
> > section was indentation
> > due to removing the surrounding if (merge_required) { } clause.
>
> Oh, you're right. I was confused because the 'diff -w' patch showed
> these two lines as removed and later re-added; your original patch
> shows it correctly.
>
> Sorry for my confusion.
>
> > I didn't want to make other changes that would be clouded.
> >
>
> +1
>
> > I can submit a follow-up patch that fixes this as well, if necessary.
>
> That would be great, assuming that the FALSE *really* should be changed
> to TRUE. (I haven't investigated that myself.)
>
Not sure what is is in reference to. I was thinking of just putting a if
(content_state) before the local modifications check (again, coffee may not
have kicked in yet).
Cheers,
Daniel^2.
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Daniel Becroft wrote on Sat, Feb 12, 2011 at 06:27:31 +1000:
> On Fri, Feb 11, 2011 at 11:26 PM, Daniel Shahaf <d....@daniel.shahaf.name>wrote:
> > Daniel Becroft wrote on Thu, Feb 10, 2011 at 07:21:30 +1000:
> > > @@ -1118,6 +1120,33 @@ merge_binary_file(svn_skel_t **work_items,
> > > + /* Attempt to merge the binary file. At the moment, we can only
> > > + handle the special case: if the LEFT side of the merge is equal
> > > + to WORKING, then we can copy RIGHT directly. */
> >
> > The comment in libsvn_client mentioned two special case, what happened
> > to the other one? Does the existing wc code already handle it? (I'd be
> > surprised)
> >
> > - Alternately, if the 'left' side of the merge doesn't exist in
> > - the repository, and the 'right' side of the merge is
> > - identical to the WC, pretend we did the merge (a no-op).
> >
>
> I've been trying to think of a valid scenario for this to occur, but I can't
> seem to think of one. There's a comment further up:
>
Concocted:
% svn add foo.bin
% svn ci -m r5
% svn rm ^/foo.bin -m r6
% svnmucc -m r7 put foo.bin ^/foo.bin
% svn merge -c7 ^/ ./
> /* Other easy outs: if the merge target isn't under version
> control, or is just missing from disk, fogettaboutit. There's no
> way svn_wc_merge4() can do the merge. */
>
> This should apply to all situations (binary and text files), so I think this
> second "special case" is redundant.
>
Not sure. If the merge-left does not exist, and the local file doesn't
exist either, then the situation is 'compatible' and can be merged...
(that depends on where exactly the local file is missing --- in BASE, in
WORKING, or in ACTUAL)
> > > + SVN_ERR(svn_wc__wq_build_file_install(&work_item,
> > > + db, target_abspath,
> > > + right_abspath,
> > > + FALSE /*
> > use_commit_times */,
> > > + FALSE /* record_fileinfo
> > */,
> >
> > About RECORD_FILEINFO:
> >
> > * Why are you passing FALSE? (I see that other calls do this too, so
> > this is for my education mainly)) A quick scan makes me expect that
> > parameter to control the mtime/size caches for modification detection.
> >
>
> I copied this directly from the call further down, where a file is copied
> depending on which version to use in a conflict. Even if "theirs" is used,
> we still pass in FALSE for record_fileinfo.
>
Because that call is also used for the svn_wc_conflict_choose_postpone,
which installs a non-pristine file.
> The RECORD_FILEINFO flag controls whether the file's information should be
> recorded into the wc.db. It seems that we only pass TRUE to this if we are
> installing a fresh file. It makes sense to pass in FALSE during a merge,
> otherwise the file won't be seen as modified.
>
Doh. +1.
> PS: The two calls in update_editor.c don't pass in NULL, but pass in a value
> based on comparing against NULL.
>
> record_fileinfo = new_contents == NULL;
> record_fileinfo = install_from == NULL;
>
Oops. Added parentheses now. Thanks.
> * In update_editor.c there are two places that pass NULL (not FALSE) for
> > that, and have above them comment that says that "If %s, we want to
> > pass FALSE". What is going on there?
> > (this is to the list, not specifically at Daniel)
> >
> > > + result_pool,
> > scratch_pool));
> > > + *work_items = svn_wc__wq_merge(*work_items, work_item,
> > result_pool);
> >
> > Don't you need to convert the next svn_wc__wq_build_file_install() to
> > use this 'build-then-merge' approach too? Otherwise, won't it overwrite
> > your WORK_ITEMS?
> >
>
> Which svn_wc__wq_build_file_install() call do you mean?
>
The only other call in the same function (merge_binary_file()).
> We return SVN_NO_ERROR immediately after building adding this workqueue
> item, so the other one for the binary file conflict resolution will not get
> called.
>
Ah, right. I missed that. I'll not pursue this point further then.
> > > @@ -1502,6 +1463,9 @@ merge_file_changed(const char *local_dir_abspath,
> > > const svn_wc_conflict_version_t *left;
> > > const svn_wc_conflict_version_t *right;
> > >
> > > + SVN_ERR(svn_wc_text_modified_p2(&has_local_mods,
> > merge_b->ctx->wc_ctx,
> > > + mine_abspath, FALSE, subpool));
> > > +
> >
> > You only need HAS_LOCAL_MODS now when CONTENT_STATE is set. Shouldn't
> > you skip this call when CONTENT_STATE is NULL then? (It may perform
> > stat() or read().)
> >
>
> Agreed, however this was always the case. The only change I made to this
> section was indentation
> due to removing the surrounding if (merge_required) { } clause.
Oh, you're right. I was confused because the 'diff -w' patch showed
these two lines as removed and later re-added; your original patch
shows it correctly.
Sorry for my confusion.
> I didn't want to make other changes that would be clouded.
>
+1
> I can submit a follow-up patch that fixes this as well, if necessary.
That would be great, assuming that the FALSE *really* should be changed
to TRUE. (I haven't investigated that myself.)
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Becroft <dj...@gmail.com>.
On Fri, Feb 11, 2011 at 11:26 PM, Daniel Shahaf <d....@daniel.shahaf.name>wrote:
> [ disclaimer: I'm not familiar with wc internals yet; sorry; hope I'll
> learn something while reviewing this ]
>
> Daniel Becroft wrote on Thu, Feb 10, 2011 at 07:21:30 +1000:
> > >
> > Hey Stefan,
> >
> > It was only partially bypassing the work queue. The items to update the
> > executable bit (and read/write bits) is always done at the end of the
> > svn_wc_merge4() function, so that's why the test started passing.
> However,
> > you are correct - I should have been using the
> svn_wc__wq_build_file_install
> > workqueue task to copy the file across (this is what happens when a
> conflict
> > is resolved with "theirs-full").
> >
> > An updated patch is attached.
> >
> > [[[
> > Fix issue #3686 - executable bit not set during merge.
> >
> > The cause was the special case in libsvn_client, which bypassed the
> > use of the workqueue. This logic has now been moved into libsvn_wc.
> >
> > Additionally, this change allows the status of binary files (during
> > a dry-run merge) to be reported correctly (previously, all binary
> > files were reported as conflicted).
> >
>
> Well written.
>
> > * subversion/libsvn_client/merge.c
> > (merge_file_changed): Removed binary-merge special case (now in
> libsvn_wc).
> > Removed merge_required variable (resulting in indentation changes).
> >
>
> Two spaces before (. [I guess it was right when you sent it, since your
> mail mis-wrapped the above paragraphs as well]
>
> > * subversion/libsvn_wc/merge.c
> > (merge_binary_file): Added dry_run parameter. Add the special case
> merging
> > of binary files.
> > (svn_wc__internal_merge): Removed dry_run check for binary files, and
> > pass to merge_binary_file instead.
> >
>
> Use present tense please.
>
> > * subversion/tests/cmdline/merge_tests.py
> > (merge_change_to_file_with_executable): Remove @XFail decorator.
> > ]]]
> >
> > Cheers,
> > Daniel B
> > (who is not a C programmer by trade ...)
>
> > Index: subversion/libsvn_wc/merge.c
> > ===================================================================
> > --- subversion/libsvn_wc/merge.c (revision 1068136)
> > +++ subversion/libsvn_wc/merge.c (working copy)
> > @@ -1094,6 +1094,7 @@
> > const char *left_label,
> > const char *right_label,
> > const char *target_label,
> > + svn_boolean_t dry_run,
>
> It would have been easier to review the patch if you'd attached
> a version generated with 'svn diff -x-pw'.
>
I wasn't aware of these options. Thanks.
> > Index: subversion/libsvn_wc/merge.c
> > ===================================================================
> > --- subversion/libsvn_wc/merge.c (revision 1069789)
> > +++ subversion/libsvn_wc/merge.c (working copy)
> > @@ -1094,6 +1094,7 @@ merge_binary_file(svn_skel_t **work_items,
> > const char *left_label,
> > const char *right_label,
> > const char *target_label,
> > + svn_boolean_t dry_run,
> > const svn_wc_conflict_version_t *left_version,
> > const svn_wc_conflict_version_t *right_version,
> > const char *detranslated_target_abspath,
> > @@ -1118,6 +1120,33 @@ merge_binary_file(svn_skel_t **work_items,
> >
> > svn_dirent_split(&merge_dirpath, &merge_filename, target_abspath,
> pool);
> >
> > + /* Attempt to merge the binary file. At the moment, we can only
> > + handle the special case: if the LEFT side of the merge is equal
> > + to WORKING, then we can copy RIGHT directly. */
>
> The comment in libsvn_client mentioned two special case, what happened
> to the other one? Does the existing wc code already handle it? (I'd be
> surprised)
>
> - Alternately, if the 'left' side of the merge doesn't exist in
> - the repository, and the 'right' side of the merge is
> - identical to the WC, pretend we did the merge (a no-op).
>
I've been trying to think of a valid scenario for this to occur, but I can't
seem to think of one. There's a comment further up:
/* Other easy outs: if the merge target isn't under version
control, or is just missing from disk, fogettaboutit. There's no
way svn_wc_merge4() can do the merge. */
This should apply to all situations (binary and text files), so I think this
second "special case" is redundant.
> > + SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> > + left_abspath,
> > + target_abspath,
> > + scratch_pool));
> > +
> > + if (same_contents)
> > + {
> > + if (!dry_run)
> > + {
> > + svn_skel_t *work_item;
> > +
>
> subversion/libsvn_wc/merge.c: In function ‘merge_binary_file’:
> subversion/libsvn_wc/merge.c:1135: warning: declaration of ‘work_item’
> shadows a previous local
> subversion/libsvn_wc/merge.c:1114: warning: shadowed declaration is here
>
Oops, fixed.
> > + SVN_ERR(svn_wc__wq_build_file_install(&work_item,
> > + db, target_abspath,
> > + right_abspath,
> > + FALSE /*
> use_commit_times */,
> > + FALSE /* record_fileinfo
> */,
>
> About RECORD_FILEINFO:
>
> * Why are you passing FALSE? (I see that other calls do this too, so
> this is for my education mainly)) A quick scan makes me expect that
> parameter to control the mtime/size caches for modification detection.
>
I copied this directly from the call further down, where a file is copied
depending on which version to use in a conflict. Even if "theirs" is used,
we still pass in FALSE for record_fileinfo.
The RECORD_FILEINFO flag controls whether the file's information should be
recorded into the wc.db. It seems that we only pass TRUE to this if we are
installing a fresh file. It makes sense to pass in FALSE during a merge,
otherwise the file won't be seen as modified.
PS: The two calls in update_editor.c don't pass in NULL, but pass in a value
based on comparing against NULL.
record_fileinfo = new_contents == NULL;
record_fileinfo = install_from == NULL;
* In update_editor.c there are two places that pass NULL (not FALSE) for
> that, and have above them comment that says that "If %s, we want to
> pass FALSE". What is going on there?
> (this is to the list, not specifically at Daniel)
>
> > + result_pool,
> scratch_pool));
> > + *work_items = svn_wc__wq_merge(*work_items, work_item,
> result_pool);
>
> Don't you need to convert the next svn_wc__wq_build_file_install() to
> use this 'build-then-merge' approach too? Otherwise, won't it overwrite
> your WORK_ITEMS?
>
Which svn_wc__wq_build_file_install() call do you mean?
We return SVN_NO_ERROR immediately after building adding this workqueue
item, so the other one for the binary file conflict resolution will not get
called.
> > + }
> > +
> > + *merge_outcome = svn_wc_merge_merged;
> > + return SVN_NO_ERROR;
> > + }
> > +
> > /* Give the conflict resolution callback a chance to clean
> > up the conflict before we mark the file 'conflicted' */
> > if (conflict_func)
> > @@ -1357,10 +1386,6 @@ svn_wc__internal_merge(svn_skel_t **work_items,
> >
> > if (is_binary)
> > {
> > - if (dry_run)
> > - /* in dry-run mode, binary files always conflict */
> > - *merge_outcome = svn_wc_merge_conflict;
> > - else
> > SVN_ERR(merge_binary_file(work_items,
> > merge_outcome,
> > db,
> > @@ -1370,6 +1395,7 @@ svn_wc__internal_merge(svn_skel_t **work_items,
> > left_label,
> > right_label,
> > target_label,
> > + dry_run,
> > left_version,
> > right_version,
> > detranslated_target_abspath,
> > Index: subversion/libsvn_client/merge.c
> > ===================================================================
> > --- subversion/libsvn_client/merge.c (revision 1069789)
> > +++ subversion/libsvn_client/merge.c (working copy)
> > @@ -1300,7 +1300,6 @@ merge_file_changed(const char *local_dir_abspath,
> > {
> > merge_cmd_baton_t *merge_b = baton;
> > apr_pool_t *subpool = svn_pool_create(merge_b->pool);
> > - svn_boolean_t merge_required = TRUE;
> > enum svn_wc_merge_outcome_t merge_outcome;
> >
> > SVN_ERR_ASSERT(mine_abspath && svn_dirent_is_absolute(mine_abspath));
> > @@ -1449,45 +1448,7 @@ merge_file_changed(const char *local_dir_abspath,
> > if (older_abspath)
> > {
> > svn_boolean_t has_local_mods;
> > - SVN_ERR(svn_wc_text_modified_p2(&has_local_mods,
> merge_b->ctx->wc_ctx,
> > - mine_abspath, FALSE, subpool));
> >
> > - /* Special case: if a binary file's working file is
> > - exactly identical to the 'left' side of the merge, then don't
> > - allow svn_wc_merge to produce a conflict. Instead, just
> > - overwrite the working file with the 'right' side of the
> > - merge. Why'd we check for local mods above? Because we want
> > - to do a different notification depending on whether or not
> > - the file was locally modified.
> > -
> > - Alternately, if the 'left' side of the merge doesn't exist in
> > - the repository, and the 'right' side of the merge is
> > - identical to the WC, pretend we did the merge (a no-op). */
> > - if ((mimetype1 && svn_mime_type_is_binary(mimetype1))
> > - || (mimetype2 && svn_mime_type_is_binary(mimetype2)))
> > - {
> > - /* For adds, the 'left' side of the merge doesn't exist. */
> > - svn_boolean_t older_revision_exists =
> > - !merge_b->add_necessitated_merge;
> > - svn_boolean_t same_contents;
> > - SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> > - (older_revision_exists ?
> > - older_abspath :
> yours_abspath),
> > - mine_abspath, subpool));
> > - if (same_contents)
> > - {
> > - if (older_revision_exists && !merge_b->dry_run)
> > - {
> > - SVN_ERR(svn_io_file_move(yours_abspath, mine_abspath,
> > - subpool));
> > - }
> > - merge_outcome = svn_wc_merge_merged;
> > - merge_required = FALSE;
> > - }
> > - }
> > -
> > - if (merge_required)
> > - {
> > /* xgettext: the '.working', '.merge-left.r%ld' and
> > '.merge-right.r%ld' strings are used to tag onto a file
> > name in case of a merge conflict */
> > @@ -1502,6 +1463,9 @@ merge_file_changed(const char *local_dir_abspath,
> > const svn_wc_conflict_version_t *left;
> > const svn_wc_conflict_version_t *right;
> >
> > + SVN_ERR(svn_wc_text_modified_p2(&has_local_mods,
> merge_b->ctx->wc_ctx,
> > + mine_abspath, FALSE, subpool));
> > +
>
> You only need HAS_LOCAL_MODS now when CONTENT_STATE is set. Shouldn't
> you skip this call when CONTENT_STATE is NULL then? (It may perform
> stat() or read().)
>
Agreed, however this was always the case. The only change I made to this
section was indentation
due to removing the surrounding if (merge_required) { } clause. I didn't
want to make other changes
that would be clouded.
I can submit a follow-up patch that fixes this as well, if necessary.
> > conflict_baton.wrapped_func = merge_b->ctx->conflict_func;
> > conflict_baton.wrapped_baton = merge_b->ctx->conflict_baton;
> > conflict_baton.conflicted_paths = &merge_b->conflicted_paths;
> > @@ -1519,7 +1483,6 @@ merge_file_changed(const char *local_dir_abspath,
> > merge_b->ctx->cancel_func,
> > merge_b->ctx->cancel_baton,
> > subpool));
> > - }
> >
> > if (content_state)
> > {
>
Thanks for the review, Daniel.
Cheers,
Daniel^2.
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
[ disclaimer: I'm not familiar with wc internals yet; sorry; hope I'll
learn something while reviewing this ]
Daniel Becroft wrote on Thu, Feb 10, 2011 at 07:21:30 +1000:
> >
> Hey Stefan,
>
> It was only partially bypassing the work queue. The items to update the
> executable bit (and read/write bits) is always done at the end of the
> svn_wc_merge4() function, so that's why the test started passing. However,
> you are correct - I should have been using the svn_wc__wq_build_file_install
> workqueue task to copy the file across (this is what happens when a conflict
> is resolved with "theirs-full").
>
> An updated patch is attached.
>
> [[[
> Fix issue #3686 - executable bit not set during merge.
>
> The cause was the special case in libsvn_client, which bypassed the
> use of the workqueue. This logic has now been moved into libsvn_wc.
>
> Additionally, this change allows the status of binary files (during
> a dry-run merge) to be reported correctly (previously, all binary
> files were reported as conflicted).
>
Well written.
> * subversion/libsvn_client/merge.c
> (merge_file_changed): Removed binary-merge special case (now in libsvn_wc).
> Removed merge_required variable (resulting in indentation changes).
>
Two spaces before (. [I guess it was right when you sent it, since your
mail mis-wrapped the above paragraphs as well]
> * subversion/libsvn_wc/merge.c
> (merge_binary_file): Added dry_run parameter. Add the special case merging
> of binary files.
> (svn_wc__internal_merge): Removed dry_run check for binary files, and
> pass to merge_binary_file instead.
>
Use present tense please.
> * subversion/tests/cmdline/merge_tests.py
> (merge_change_to_file_with_executable): Remove @XFail decorator.
> ]]]
>
> Cheers,
> Daniel B
> (who is not a C programmer by trade ...)
> Index: subversion/libsvn_wc/merge.c
> ===================================================================
> --- subversion/libsvn_wc/merge.c (revision 1068136)
> +++ subversion/libsvn_wc/merge.c (working copy)
> @@ -1094,6 +1094,7 @@
> const char *left_label,
> const char *right_label,
> const char *target_label,
> + svn_boolean_t dry_run,
It would have been easier to review the patch if you'd attached
a version generated with 'svn diff -x-pw'.
> Index: subversion/libsvn_wc/merge.c
> ===================================================================
> --- subversion/libsvn_wc/merge.c (revision 1069789)
> +++ subversion/libsvn_wc/merge.c (working copy)
> @@ -1094,6 +1094,7 @@ merge_binary_file(svn_skel_t **work_items,
> const char *left_label,
> const char *right_label,
> const char *target_label,
> + svn_boolean_t dry_run,
> const svn_wc_conflict_version_t *left_version,
> const svn_wc_conflict_version_t *right_version,
> const char *detranslated_target_abspath,
> @@ -1118,6 +1120,33 @@ merge_binary_file(svn_skel_t **work_items,
>
> svn_dirent_split(&merge_dirpath, &merge_filename, target_abspath, pool);
>
> + /* Attempt to merge the binary file. At the moment, we can only
> + handle the special case: if the LEFT side of the merge is equal
> + to WORKING, then we can copy RIGHT directly. */
The comment in libsvn_client mentioned two special case, what happened
to the other one? Does the existing wc code already handle it? (I'd be
surprised)
- Alternately, if the 'left' side of the merge doesn't exist in
- the repository, and the 'right' side of the merge is
- identical to the WC, pretend we did the merge (a no-op).
> + SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> + left_abspath,
> + target_abspath,
> + scratch_pool));
> +
> + if (same_contents)
> + {
> + if (!dry_run)
> + {
> + svn_skel_t *work_item;
> +
subversion/libsvn_wc/merge.c: In function ‘merge_binary_file’:
subversion/libsvn_wc/merge.c:1135: warning: declaration of ‘work_item’ shadows a previous local
subversion/libsvn_wc/merge.c:1114: warning: shadowed declaration is here
> + SVN_ERR(svn_wc__wq_build_file_install(&work_item,
> + db, target_abspath,
> + right_abspath,
> + FALSE /* use_commit_times */,
> + FALSE /* record_fileinfo */,
About RECORD_FILEINFO:
* Why are you passing FALSE? (I see that other calls do this too, so
this is for my education mainly)) A quick scan makes me expect that
parameter to control the mtime/size caches for modification detection.
* In update_editor.c there are two places that pass NULL (not FALSE) for
that, and have above them comment that says that "If %s, we want to
pass FALSE". What is going on there?
(this is to the list, not specifically at Daniel)
> + result_pool, scratch_pool));
> + *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);
Don't you need to convert the next svn_wc__wq_build_file_install() to
use this 'build-then-merge' approach too? Otherwise, won't it overwrite
your WORK_ITEMS?
> + }
> +
> + *merge_outcome = svn_wc_merge_merged;
> + return SVN_NO_ERROR;
> + }
> +
> /* Give the conflict resolution callback a chance to clean
> up the conflict before we mark the file 'conflicted' */
> if (conflict_func)
> @@ -1357,10 +1386,6 @@ svn_wc__internal_merge(svn_skel_t **work_items,
>
> if (is_binary)
> {
> - if (dry_run)
> - /* in dry-run mode, binary files always conflict */
> - *merge_outcome = svn_wc_merge_conflict;
> - else
> SVN_ERR(merge_binary_file(work_items,
> merge_outcome,
> db,
> @@ -1370,6 +1395,7 @@ svn_wc__internal_merge(svn_skel_t **work_items,
> left_label,
> right_label,
> target_label,
> + dry_run,
> left_version,
> right_version,
> detranslated_target_abspath,
> Index: subversion/libsvn_client/merge.c
> ===================================================================
> --- subversion/libsvn_client/merge.c (revision 1069789)
> +++ subversion/libsvn_client/merge.c (working copy)
> @@ -1300,7 +1300,6 @@ merge_file_changed(const char *local_dir_abspath,
> {
> merge_cmd_baton_t *merge_b = baton;
> apr_pool_t *subpool = svn_pool_create(merge_b->pool);
> - svn_boolean_t merge_required = TRUE;
> enum svn_wc_merge_outcome_t merge_outcome;
>
> SVN_ERR_ASSERT(mine_abspath && svn_dirent_is_absolute(mine_abspath));
> @@ -1449,45 +1448,7 @@ merge_file_changed(const char *local_dir_abspath,
> if (older_abspath)
> {
> svn_boolean_t has_local_mods;
> - SVN_ERR(svn_wc_text_modified_p2(&has_local_mods, merge_b->ctx->wc_ctx,
> - mine_abspath, FALSE, subpool));
>
> - /* Special case: if a binary file's working file is
> - exactly identical to the 'left' side of the merge, then don't
> - allow svn_wc_merge to produce a conflict. Instead, just
> - overwrite the working file with the 'right' side of the
> - merge. Why'd we check for local mods above? Because we want
> - to do a different notification depending on whether or not
> - the file was locally modified.
> -
> - Alternately, if the 'left' side of the merge doesn't exist in
> - the repository, and the 'right' side of the merge is
> - identical to the WC, pretend we did the merge (a no-op). */
> - if ((mimetype1 && svn_mime_type_is_binary(mimetype1))
> - || (mimetype2 && svn_mime_type_is_binary(mimetype2)))
> - {
> - /* For adds, the 'left' side of the merge doesn't exist. */
> - svn_boolean_t older_revision_exists =
> - !merge_b->add_necessitated_merge;
> - svn_boolean_t same_contents;
> - SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> - (older_revision_exists ?
> - older_abspath : yours_abspath),
> - mine_abspath, subpool));
> - if (same_contents)
> - {
> - if (older_revision_exists && !merge_b->dry_run)
> - {
> - SVN_ERR(svn_io_file_move(yours_abspath, mine_abspath,
> - subpool));
> - }
> - merge_outcome = svn_wc_merge_merged;
> - merge_required = FALSE;
> - }
> - }
> -
> - if (merge_required)
> - {
> /* xgettext: the '.working', '.merge-left.r%ld' and
> '.merge-right.r%ld' strings are used to tag onto a file
> name in case of a merge conflict */
> @@ -1502,6 +1463,9 @@ merge_file_changed(const char *local_dir_abspath,
> const svn_wc_conflict_version_t *left;
> const svn_wc_conflict_version_t *right;
>
> + SVN_ERR(svn_wc_text_modified_p2(&has_local_mods, merge_b->ctx->wc_ctx,
> + mine_abspath, FALSE, subpool));
> +
You only need HAS_LOCAL_MODS now when CONTENT_STATE is set. Shouldn't
you skip this call when CONTENT_STATE is NULL then? (It may perform
stat() or read().)
> conflict_baton.wrapped_func = merge_b->ctx->conflict_func;
> conflict_baton.wrapped_baton = merge_b->ctx->conflict_baton;
> conflict_baton.conflicted_paths = &merge_b->conflicted_paths;
> @@ -1519,7 +1483,6 @@ merge_file_changed(const char *local_dir_abspath,
> merge_b->ctx->cancel_func,
> merge_b->ctx->cancel_baton,
> subpool));
> - }
>
> if (content_state)
> {
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Becroft <dj...@gmail.com>.
>
> > Index: subversion/libsvn_wc/merge.c
>> > ===================================================================
>> > --- subversion/libsvn_wc/merge.c (revision 1068136)
>> > +++ subversion/libsvn_wc/merge.c (working copy)
>> > @@ -1094,6 +1094,7 @@
>> > const char *left_label,
>> > const char *right_label,
>> > const char *target_label,
>> > + svn_boolean_t dry_run,
>> > const svn_wc_conflict_version_t *left_version,
>> > const svn_wc_conflict_version_t *right_version,
>> > const char *detranslated_target_abspath,
>> > @@ -1111,13 +1112,31 @@
>> > const char *merge_dirpath, *merge_filename;
>> > const char *conflict_wrk;
>> > svn_skel_t *work_item;
>> > + svn_boolean_t same_contents = FALSE;
>> >
>> > SVN_ERR_ASSERT(svn_dirent_is_absolute(target_abspath));
>> >
>> > *work_items = NULL;
>> >
>> > svn_dirent_split(&merge_dirpath, &merge_filename, target_abspath,
>> pool);
>> > +
>> > + /* Attempt to merge the binary file. At the moment, we can only
>> > + handle the special case: if the LEFT side of the merge is equal
>> > + to WORKING, then we can copy RIGHT directly. */
>> > + SVN_ERR(svn_io_files_contents_same_p(&same_contents,
>> > + left_abspath,
>> > + target_abspath,
>> > + scratch_pool));
>> >
>> > + if (same_contents)
>> > + {
>> > + if (!dry_run)
>> > + SVN_ERR(svn_io_file_move(right_abspath, target_abspath,
>> > + scratch_pool));
>>
>> Isn't calling svn_io_file_move() directly still bypassing the work queue?
>> Shouldn't this code queue a task instead?
>>
>
> Hmm ... I'll look into that. The test went from XFAIL to XPASS, and I was
> working off the "minimum required to get test to pass" mantra.
>
Hey Stefan,
It was only partially bypassing the work queue. The items to update the
executable bit (and read/write bits) is always done at the end of the
svn_wc_merge4() function, so that's why the test started passing. However,
you are correct - I should have been using the svn_wc__wq_build_file_install
workqueue task to copy the file across (this is what happens when a conflict
is resolved with "theirs-full").
An updated patch is attached.
[[[
Fix issue #3686 - executable bit not set during merge.
The cause was the special case in libsvn_client, which bypassed the use of
the
workqueue. This logic has now been moved into libsvn_wc.
Additionally, this change allows the status of binary files (during a
dry-run
merge) to be reported correctly (previously, all binary files were reported
as
conflicted).
* subversion/libsvn_client/merge.c
(merge_file_changed): Removed binary-merge special case (now in libsvn_wc).
Removed merge_required variable (resulting in indentation changes).
* subversion/libsvn_wc/merge.c
(merge_binary_file): Added dry_run parameter. Add the special case merging
of binary files.
(svn_wc__internal_merge): Removed dry_run check for binary files, and pass
to
merge_binary_file instead.
* subversion/tests/cmdline/merge_tests.py
(merge_change_to_file_with_executable): Remove @XFail decorator.
]]]
Cheers,
Daniel B
(who is not a C programmer by trade ...)
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Daniel Becroft <dj...@gmail.com>.
On Wed, Feb 9, 2011 at 7:46 AM, Stefan Sperling <st...@elego.de> wrote:
> On Wed, Feb 09, 2011 at 07:34:53AM +1000, Daniel Becroft wrote:
> > Hi,
> >
> > Attached is a completed patch to resolve issue 3686[1], where the
> executable
> > bit is not maintained during the merge of a binary file.
> >
> > I thought about making this change more generic, and applying it to text
> > files as well (there was discussion with performance of simple-case
> merging
> > a month ago on users@), but thought I'd leave that for later. I didn't
> want
> > to worry about (potential) line-endings, keywords, etc. problems.
>
> Some comments inline.
>
> >
> > [[[
> > Fix issue #3686 - executable bit not set during merge.
> >
> > The cause was the special case in libsvn_client, which bypassed the use
> of
> > the
> > workqueue. This logic has now been moved into libsvn_wc.
> >
> > Additionally, this change allows the status of binary files (during a
> > dry-run
> > merge) to be reported correctly (previously, all binary files were
> reported
> > as
> > conflicted).
> >
> > * subversion/libsvn_client/merge.c
> > (merge_file_changed): Removed binary-merge special case (now in
> libsvn_wc).
> > Removed merge_required variable (resulting in indentation changes).
> >
> > * subversion/libsvn_wc/merge.c
> > (merge_binary_file): Added dry_run parameter. Add the special case
> merging
> > of binary files.
>
> The log messages doesn't mention the caller of merge_binary_file()
> which was also changed.>
>
Oops, will fix.
> * subversion/tests/cmdline/merge_tests.py
> > (merge_change_to_file_with_executable): Remove @XFail decorator.
> > ]]]
> >
> > [1]
> >
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=463&dsMessageId=2635024
> >
> > Cheers,
> > Daniel B.
> >
> > ---
> > Daniel Becroft
>
> > Index: subversion/tests/cmdline/merge_tests.py
> > ===================================================================
> > --- subversion/tests/cmdline/merge_tests.py (revision 1068136)
> > +++ subversion/tests/cmdline/merge_tests.py (working copy)
> > @@ -16469,7 +16469,6 @@
> > #----------------------------------------------------------------------
> > # Test for issue #3686 'executable flag not correctly set on merge'
> > # See http://subversion.tigris.org/issues/show_bug.cgi?id=3686
> > -@XFail()
> > @Issue(3686)
> > @SkipUnless(svntest.main.is_posix_os)
> > def merge_change_to_file_with_executable(sbox):
> > Index: subversion/libsvn_wc/merge.c
> > ===================================================================
> > --- subversion/libsvn_wc/merge.c (revision 1068136)
> > +++ subversion/libsvn_wc/merge.c (working copy)
> > @@ -1094,6 +1094,7 @@
> > const char *left_label,
> > const char *right_label,
> > const char *target_label,
> > + svn_boolean_t dry_run,
> > const svn_wc_conflict_version_t *left_version,
> > const svn_wc_conflict_version_t *right_version,
> > const char *detranslated_target_abspath,
> > @@ -1111,13 +1112,31 @@
> > const char *merge_dirpath, *merge_filename;
> > const char *conflict_wrk;
> > svn_skel_t *work_item;
> > + svn_boolean_t same_contents = FALSE;
> >
> > SVN_ERR_ASSERT(svn_dirent_is_absolute(target_abspath));
> >
> > *work_items = NULL;
> >
> > svn_dirent_split(&merge_dirpath, &merge_filename, target_abspath,
> pool);
> > +
> > + /* Attempt to merge the binary file. At the moment, we can only
> > + handle the special case: if the LEFT side of the merge is equal
> > + to WORKING, then we can copy RIGHT directly. */
> > + SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> > + left_abspath,
> > + target_abspath,
> > + scratch_pool));
> >
> > + if (same_contents)
> > + {
> > + if (!dry_run)
> > + SVN_ERR(svn_io_file_move(right_abspath, target_abspath,
> > + scratch_pool));
>
> Isn't calling svn_io_file_move() directly still bypassing the work queue?
> Shouldn't this code queue a task instead?
>
Hmm ... I'll look into that. The test went from XFAIL to XPASS, and I was
working off the "minimum required to get test to pass" mantra.
> + *merge_outcome = svn_wc_merge_merged;
> > + return SVN_NO_ERROR;
> > + }
> > +
> > /* Give the conflict resolution callback a chance to clean
> > up the conflict before we mark the file 'conflicted' */
> > if (conflict_func)
> > @@ -1357,26 +1376,23 @@
> >
> > if (is_binary)
> > {
> > - if (dry_run)
> > - /* in dry-run mode, binary files always conflict */
> > - *merge_outcome = svn_wc_merge_conflict;
> > - else
> > - SVN_ERR(merge_binary_file(work_items,
> > - merge_outcome,
> > - db,
> > - left_abspath,
> > - right_abspath,
> > - target_abspath,
> > - left_label,
> > - right_label,
> > - target_label,
> > - left_version,
> > - right_version,
> > - detranslated_target_abspath,
> > - mimeprop,
> > - conflict_func,
> > - conflict_baton,
> > - result_pool, scratch_pool));
> > + SVN_ERR(merge_binary_file(work_items,
> > + merge_outcome,
> > + db,
> > + left_abspath,
> > + right_abspath,
> > + target_abspath,
> > + left_label,
> > + right_label,
> > + target_label,
> > + dry_run,
> > + left_version,
> > + right_version,
> > + detranslated_target_abspath,
> > + mimeprop,
> > + conflict_func,
> > + conflict_baton,
> > + result_pool, scratch_pool));
> > }
> > else
> > {
> > Index: subversion/libsvn_client/merge.c
> > ===================================================================
> > --- subversion/libsvn_client/merge.c (revision 1068136)
> > +++ subversion/libsvn_client/merge.c (working copy)
> > @@ -1300,7 +1300,6 @@
> > {
> > merge_cmd_baton_t *merge_b = baton;
> > apr_pool_t *subpool = svn_pool_create(merge_b->pool);
> > - svn_boolean_t merge_required = TRUE;
> > enum svn_wc_merge_outcome_t merge_outcome;
> >
> > SVN_ERR_ASSERT(mine_abspath && svn_dirent_is_absolute(mine_abspath));
> > @@ -1452,75 +1451,38 @@
> > SVN_ERR(svn_wc_text_modified_p2(&has_local_mods,
> merge_b->ctx->wc_ctx,
> > mine_abspath, FALSE, subpool));
> >
> > - /* Special case: if a binary file's working file is
> > - exactly identical to the 'left' side of the merge, then don't
> > - allow svn_wc_merge to produce a conflict. Instead, just
> > - overwrite the working file with the 'right' side of the
> > - merge. Why'd we check for local mods above? Because we want
> > - to do a different notification depending on whether or not
> > - the file was locally modified.
> > + /* xgettext: the '.working', '.merge-left.r%ld' and
> > + '.merge-right.r%ld' strings are used to tag onto a file
> > + name in case of a merge conflict */
> > + const char *target_label = _(".working");
> > + const char *left_label = apr_psprintf(subpool,
> > + _(".merge-left.r%ld"),
> > + older_rev);
> > + const char *right_label = apr_psprintf(subpool,
> > + _(".merge-right.r%ld"),
> > + yours_rev);
> > + conflict_resolver_baton_t conflict_baton = { 0 };
> > + const svn_wc_conflict_version_t *left;
> > + const svn_wc_conflict_version_t *right;
>
> The above will fail to compile with C89 compilers.
> Variables must be declared at the beginning of a scope.
>
Thanks. These variables were all wrapped in the if (merge_required) block,
and I simply removed that and adjusted indentation.
> >
> > - Alternately, if the 'left' side of the merge doesn't exist in
> > - the repository, and the 'right' side of the merge is
> > - identical to the WC, pretend we did the merge (a no-op). */
> > - if ((mimetype1 && svn_mime_type_is_binary(mimetype1))
> > - || (mimetype2 && svn_mime_type_is_binary(mimetype2)))
> > - {
> > - /* For adds, the 'left' side of the merge doesn't exist. */
> > - svn_boolean_t older_revision_exists =
> > - !merge_b->add_necessitated_merge;
> > - svn_boolean_t same_contents;
> > - SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> > - (older_revision_exists ?
> > - older_abspath :
> yours_abspath),
> > - mine_abspath, subpool));
> > - if (same_contents)
> > - {
> > - if (older_revision_exists && !merge_b->dry_run)
> > - {
> > - SVN_ERR(svn_io_file_move(yours_abspath, mine_abspath,
> > - subpool));
> > - }
> > - merge_outcome = svn_wc_merge_merged;
> > - merge_required = FALSE;
> > - }
> > - }
> > + conflict_baton.wrapped_func = merge_b->ctx->conflict_func;
> > + conflict_baton.wrapped_baton = merge_b->ctx->conflict_baton;
> > + conflict_baton.conflicted_paths = &merge_b->conflicted_paths;
> > + conflict_baton.pool = merge_b->pool;
> >
> > - if (merge_required)
> > - {
> > - /* xgettext: the '.working', '.merge-left.r%ld' and
> > - '.merge-right.r%ld' strings are used to tag onto a file
> > - name in case of a merge conflict */
> > - const char *target_label = _(".working");
> > - const char *left_label = apr_psprintf(subpool,
> > - _(".merge-left.r%ld"),
> > - older_rev);
> > - const char *right_label = apr_psprintf(subpool,
> > - _(".merge-right.r%ld"),
> > - yours_rev);
> > - conflict_resolver_baton_t conflict_baton = { 0 };
> > - const svn_wc_conflict_version_t *left;
> > - const svn_wc_conflict_version_t *right;
> > + SVN_ERR(make_conflict_versions(&left, &right, mine_abspath,
> > + svn_node_file, merge_b));
> > + SVN_ERR(svn_wc_merge4(&merge_outcome, merge_b->ctx->wc_ctx,
> > + older_abspath, yours_abspath, mine_abspath,
> > + left_label, right_label, target_label,
> > + left, right,
> > + merge_b->dry_run, merge_b->diff3_cmd,
> > + merge_b->merge_options, prop_changes,
> > + conflict_resolver, &conflict_baton,
> > + merge_b->ctx->cancel_func,
> > + merge_b->ctx->cancel_baton,
> > + subpool));
> >
> > - conflict_baton.wrapped_func = merge_b->ctx->conflict_func;
> > - conflict_baton.wrapped_baton = merge_b->ctx->conflict_baton;
> > - conflict_baton.conflicted_paths = &merge_b->conflicted_paths;
> > - conflict_baton.pool = merge_b->pool;
> > -
> > - SVN_ERR(make_conflict_versions(&left, &right, mine_abspath,
> > - svn_node_file, merge_b));
> > - SVN_ERR(svn_wc_merge4(&merge_outcome, merge_b->ctx->wc_ctx,
> > - older_abspath, yours_abspath,
> mine_abspath,
> > - left_label, right_label, target_label,
> > - left, right,
> > - merge_b->dry_run, merge_b->diff3_cmd,
> > - merge_b->merge_options, prop_changes,
> > - conflict_resolver, &conflict_baton,
> > - merge_b->ctx->cancel_func,
> > - merge_b->ctx->cancel_baton,
> > - subpool));
> > - }
> > -
> > if (content_state)
> > {
> > if (merge_outcome == svn_wc_merge_conflict)
>
>
Re: [PATCH] Fix issue #3686 - executable bit not set during merge
Posted by Stefan Sperling <st...@elego.de>.
On Wed, Feb 09, 2011 at 07:34:53AM +1000, Daniel Becroft wrote:
> Hi,
>
> Attached is a completed patch to resolve issue 3686[1], where the executable
> bit is not maintained during the merge of a binary file.
>
> I thought about making this change more generic, and applying it to text
> files as well (there was discussion with performance of simple-case merging
> a month ago on users@), but thought I'd leave that for later. I didn't want
> to worry about (potential) line-endings, keywords, etc. problems.
Some comments inline.
>
> [[[
> Fix issue #3686 - executable bit not set during merge.
>
> The cause was the special case in libsvn_client, which bypassed the use of
> the
> workqueue. This logic has now been moved into libsvn_wc.
>
> Additionally, this change allows the status of binary files (during a
> dry-run
> merge) to be reported correctly (previously, all binary files were reported
> as
> conflicted).
>
> * subversion/libsvn_client/merge.c
> (merge_file_changed): Removed binary-merge special case (now in libsvn_wc).
> Removed merge_required variable (resulting in indentation changes).
>
> * subversion/libsvn_wc/merge.c
> (merge_binary_file): Added dry_run parameter. Add the special case merging
> of binary files.
The log messages doesn't mention the caller of merge_binary_file()
which was also changed.
>
> * subversion/tests/cmdline/merge_tests.py
> (merge_change_to_file_with_executable): Remove @XFail decorator.
> ]]]
>
> [1]
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=463&dsMessageId=2635024
>
> Cheers,
> Daniel B.
>
> ---
> Daniel Becroft
> Index: subversion/tests/cmdline/merge_tests.py
> ===================================================================
> --- subversion/tests/cmdline/merge_tests.py (revision 1068136)
> +++ subversion/tests/cmdline/merge_tests.py (working copy)
> @@ -16469,7 +16469,6 @@
> #----------------------------------------------------------------------
> # Test for issue #3686 'executable flag not correctly set on merge'
> # See http://subversion.tigris.org/issues/show_bug.cgi?id=3686
> -@XFail()
> @Issue(3686)
> @SkipUnless(svntest.main.is_posix_os)
> def merge_change_to_file_with_executable(sbox):
> Index: subversion/libsvn_wc/merge.c
> ===================================================================
> --- subversion/libsvn_wc/merge.c (revision 1068136)
> +++ subversion/libsvn_wc/merge.c (working copy)
> @@ -1094,6 +1094,7 @@
> const char *left_label,
> const char *right_label,
> const char *target_label,
> + svn_boolean_t dry_run,
> const svn_wc_conflict_version_t *left_version,
> const svn_wc_conflict_version_t *right_version,
> const char *detranslated_target_abspath,
> @@ -1111,13 +1112,31 @@
> const char *merge_dirpath, *merge_filename;
> const char *conflict_wrk;
> svn_skel_t *work_item;
> + svn_boolean_t same_contents = FALSE;
>
> SVN_ERR_ASSERT(svn_dirent_is_absolute(target_abspath));
>
> *work_items = NULL;
>
> svn_dirent_split(&merge_dirpath, &merge_filename, target_abspath, pool);
> +
> + /* Attempt to merge the binary file. At the moment, we can only
> + handle the special case: if the LEFT side of the merge is equal
> + to WORKING, then we can copy RIGHT directly. */
> + SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> + left_abspath,
> + target_abspath,
> + scratch_pool));
>
> + if (same_contents)
> + {
> + if (!dry_run)
> + SVN_ERR(svn_io_file_move(right_abspath, target_abspath,
> + scratch_pool));
Isn't calling svn_io_file_move() directly still bypassing the work queue?
Shouldn't this code queue a task instead?
> + *merge_outcome = svn_wc_merge_merged;
> + return SVN_NO_ERROR;
> + }
> +
> /* Give the conflict resolution callback a chance to clean
> up the conflict before we mark the file 'conflicted' */
> if (conflict_func)
> @@ -1357,26 +1376,23 @@
>
> if (is_binary)
> {
> - if (dry_run)
> - /* in dry-run mode, binary files always conflict */
> - *merge_outcome = svn_wc_merge_conflict;
> - else
> - SVN_ERR(merge_binary_file(work_items,
> - merge_outcome,
> - db,
> - left_abspath,
> - right_abspath,
> - target_abspath,
> - left_label,
> - right_label,
> - target_label,
> - left_version,
> - right_version,
> - detranslated_target_abspath,
> - mimeprop,
> - conflict_func,
> - conflict_baton,
> - result_pool, scratch_pool));
> + SVN_ERR(merge_binary_file(work_items,
> + merge_outcome,
> + db,
> + left_abspath,
> + right_abspath,
> + target_abspath,
> + left_label,
> + right_label,
> + target_label,
> + dry_run,
> + left_version,
> + right_version,
> + detranslated_target_abspath,
> + mimeprop,
> + conflict_func,
> + conflict_baton,
> + result_pool, scratch_pool));
> }
> else
> {
> Index: subversion/libsvn_client/merge.c
> ===================================================================
> --- subversion/libsvn_client/merge.c (revision 1068136)
> +++ subversion/libsvn_client/merge.c (working copy)
> @@ -1300,7 +1300,6 @@
> {
> merge_cmd_baton_t *merge_b = baton;
> apr_pool_t *subpool = svn_pool_create(merge_b->pool);
> - svn_boolean_t merge_required = TRUE;
> enum svn_wc_merge_outcome_t merge_outcome;
>
> SVN_ERR_ASSERT(mine_abspath && svn_dirent_is_absolute(mine_abspath));
> @@ -1452,75 +1451,38 @@
> SVN_ERR(svn_wc_text_modified_p2(&has_local_mods, merge_b->ctx->wc_ctx,
> mine_abspath, FALSE, subpool));
>
> - /* Special case: if a binary file's working file is
> - exactly identical to the 'left' side of the merge, then don't
> - allow svn_wc_merge to produce a conflict. Instead, just
> - overwrite the working file with the 'right' side of the
> - merge. Why'd we check for local mods above? Because we want
> - to do a different notification depending on whether or not
> - the file was locally modified.
> + /* xgettext: the '.working', '.merge-left.r%ld' and
> + '.merge-right.r%ld' strings are used to tag onto a file
> + name in case of a merge conflict */
> + const char *target_label = _(".working");
> + const char *left_label = apr_psprintf(subpool,
> + _(".merge-left.r%ld"),
> + older_rev);
> + const char *right_label = apr_psprintf(subpool,
> + _(".merge-right.r%ld"),
> + yours_rev);
> + conflict_resolver_baton_t conflict_baton = { 0 };
> + const svn_wc_conflict_version_t *left;
> + const svn_wc_conflict_version_t *right;
The above will fail to compile with C89 compilers.
Variables must be declared at the beginning of a scope.
>
> - Alternately, if the 'left' side of the merge doesn't exist in
> - the repository, and the 'right' side of the merge is
> - identical to the WC, pretend we did the merge (a no-op). */
> - if ((mimetype1 && svn_mime_type_is_binary(mimetype1))
> - || (mimetype2 && svn_mime_type_is_binary(mimetype2)))
> - {
> - /* For adds, the 'left' side of the merge doesn't exist. */
> - svn_boolean_t older_revision_exists =
> - !merge_b->add_necessitated_merge;
> - svn_boolean_t same_contents;
> - SVN_ERR(svn_io_files_contents_same_p(&same_contents,
> - (older_revision_exists ?
> - older_abspath : yours_abspath),
> - mine_abspath, subpool));
> - if (same_contents)
> - {
> - if (older_revision_exists && !merge_b->dry_run)
> - {
> - SVN_ERR(svn_io_file_move(yours_abspath, mine_abspath,
> - subpool));
> - }
> - merge_outcome = svn_wc_merge_merged;
> - merge_required = FALSE;
> - }
> - }
> + conflict_baton.wrapped_func = merge_b->ctx->conflict_func;
> + conflict_baton.wrapped_baton = merge_b->ctx->conflict_baton;
> + conflict_baton.conflicted_paths = &merge_b->conflicted_paths;
> + conflict_baton.pool = merge_b->pool;
>
> - if (merge_required)
> - {
> - /* xgettext: the '.working', '.merge-left.r%ld' and
> - '.merge-right.r%ld' strings are used to tag onto a file
> - name in case of a merge conflict */
> - const char *target_label = _(".working");
> - const char *left_label = apr_psprintf(subpool,
> - _(".merge-left.r%ld"),
> - older_rev);
> - const char *right_label = apr_psprintf(subpool,
> - _(".merge-right.r%ld"),
> - yours_rev);
> - conflict_resolver_baton_t conflict_baton = { 0 };
> - const svn_wc_conflict_version_t *left;
> - const svn_wc_conflict_version_t *right;
> + SVN_ERR(make_conflict_versions(&left, &right, mine_abspath,
> + svn_node_file, merge_b));
> + SVN_ERR(svn_wc_merge4(&merge_outcome, merge_b->ctx->wc_ctx,
> + older_abspath, yours_abspath, mine_abspath,
> + left_label, right_label, target_label,
> + left, right,
> + merge_b->dry_run, merge_b->diff3_cmd,
> + merge_b->merge_options, prop_changes,
> + conflict_resolver, &conflict_baton,
> + merge_b->ctx->cancel_func,
> + merge_b->ctx->cancel_baton,
> + subpool));
>
> - conflict_baton.wrapped_func = merge_b->ctx->conflict_func;
> - conflict_baton.wrapped_baton = merge_b->ctx->conflict_baton;
> - conflict_baton.conflicted_paths = &merge_b->conflicted_paths;
> - conflict_baton.pool = merge_b->pool;
> -
> - SVN_ERR(make_conflict_versions(&left, &right, mine_abspath,
> - svn_node_file, merge_b));
> - SVN_ERR(svn_wc_merge4(&merge_outcome, merge_b->ctx->wc_ctx,
> - older_abspath, yours_abspath, mine_abspath,
> - left_label, right_label, target_label,
> - left, right,
> - merge_b->dry_run, merge_b->diff3_cmd,
> - merge_b->merge_options, prop_changes,
> - conflict_resolver, &conflict_baton,
> - merge_b->ctx->cancel_func,
> - merge_b->ctx->cancel_baton,
> - subpool));
> - }
> -
> if (content_state)
> {
> if (merge_outcome == svn_wc_merge_conflict)