[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Cannot get info for a file that was inside of file-replaced directory

From: Nathan Hartman <hartman.nathan_at_gmail.com>
Date: Fri, 22 Nov 2019 01:01:56 -0500

On Tue, Nov 19, 2019 at 12:03 AM Nathan Hartman <hartman.nathan_at_gmail.com>
wrote:
>
> On Mon, Nov 18, 2019 at 4:53 AM Иван Селин <ivanselin_at_yandex-team.ru>
wrote:
>>
>> Hi!
>>
>> I think I've found a bug in subversion client. Setup is as follows:
>> 1. Create directory with a file in it — commit 1
>> 2. Replace directory with other file — commit 2
>> 3. Call "svn info dir/file_at_1" — it should give information about
dir/file at revision 1, but it fails saying that "dir" is a file at latest
revision:
>>
>> svn: E160016: Failure opening '/dir' in revision 2
>> svn: E160016: '/dir' is not a directory in filesystem
'0bc899d5-c233-4fed-98a3-8705ddfc96c4'
>> But directory can be listed, it shows the file, and file can be listed
too:
>> $ svn info file:///tmp/subversion-info-on-replaced-file/repo/dir_at_1
>> Path: dir
>> URL: file:///tmp/subversion-info-on-replaced-file/repo/dir
>> Relative URL: ^/dir
>> Repository Root: file:///tmp/subversion-info-on-replaced-file/repo
>> Repository UUID: 0bc899d5-c233-4fed-98a3-8705ddfc96c4
>> Revision: 1
>> Node Kind: directory
>> Last Changed Author: ivanselin
>> Last Changed Rev: 1
>> Last Changed Date: 2019-11-18 11:38:16 +0300 (Пн, 18 ноя 2019)
>>
>> $ svn list file:///tmp/subversion-info-on-replaced-file/repo/dir_at_1
>> file
>> $ svn list file:///tmp/subversion-info-on-replaced-file/repo/dir/file_at_1
>> file
>>
>> So, only "info" does not work. It seems that it's performing directory
check against HEAD instead of provided peg revision. Adding --revision key
changes nothing. This is trunk svn (1.14.0-dev, r1869957), svn 1.9.7 does
not have this bug, it correctly shows info.
>>
>> Sample reproduction script attached.
>
>
> Hello Ivan,
>
> Thank you for reporting this.
>
> I performed similar steps and I am seeing the same result, namely:
>
> $ svn info "$repo/dir/file"@1
> svn: E160016: Failure opening '/dir' in revision 2
> svn: E160016: '/dir' is not a directory in filesystem '(snip)'
>
> You asked for peg revision 1, it's looking in revision 2.
>
> I'm investigating...

Hello Ivan,

Update: This bug was introduced in r1823327.

I don't have a fix yet but at least we know where it is now.

The last command in your reproduction script:
'svn info "file://$REPO/dir/file"@1'
works correctly in r1823326, fails in r1823327:

[[[

$ svn log -r 1823327
------------------------------------------------------------------------
r1823327 | julianfoad | 2018-02-06 08:44:17 -0500 (Tue, 06 Feb 2018) | 21
lines

Performance: Make the 'info' command fast on old repository revisions.

The svn_client_info4() API reports the lock status of the given URL (at
head, implicitly) if that is the same resource as the given URL and
revision. The 'same resource' check was inefficient, searching history
forwards from the given revision up to head.

The problem was present even when a peg revision is specified and even when
the 'svn info --show-item=x' option is used. (The 'show-item' filtering is
not performed in the library.)

Example: 'svn info https://svn.apache.org/repos/asf/subversion@850000'
took 13s before and 2s after this change.

See http://colabti.org/irclogger/irclogger_log/svn-dev?date=2018-02-06#l11

* subversion/libsvn_client/info.c
  (same_resource_in_head): Search history backwards instead of forward.

Found by: jcorvel

$ svn diff -x-wp -r 1823326:1823327
Index: subversion/libsvn_client/info.c
===================================================================
--- subversion/libsvn_client/info.c (revision 1823326)
+++ subversion/libsvn_client/info.c (revision 1823327)
@@ -253,17 +253,17 @@ same_resource_in_head(svn_boolean_t *same_p,
                       apr_pool_t *pool)
 {
   svn_error_t *err;
- svn_opt_revision_t start_rev, peg_rev;
+ svn_opt_revision_t operative_rev, peg_rev;
   const char *head_url;

- start_rev.kind = svn_opt_revision_head;
- peg_rev.kind = svn_opt_revision_number;
- peg_rev.value.number = rev;
+ peg_rev.kind = svn_opt_revision_head;
+ operative_rev.kind = svn_opt_revision_number;
+ operative_rev.value.number = rev;

   err = svn_client__repos_locations(&head_url, NULL, NULL, NULL,
                                     ra_session,
                                     url, &peg_rev,
- &start_rev, NULL,
+ &operative_rev, NULL,
                                     ctx, pool);
   if (err &&
       ((err->apr_err == SVN_ERR_CLIENT_UNRELATED_RESOURCES) ||

]]]

I modified your reproduction script a little and ran a bisect using
https://metacpan.org/pod/distribution/App-SVN-Bisect/bin/svn-bisect.
(Excuse the hard-coded paths.)

[[[

#!/bin/bash

SVN=/home/nate/ramdrive/svn-trunk/subversion/svn/svn
SVNADMIN=/home/nate/ramdrive/svn-trunk/subversion/svnadmin/svnadmin

REPO="/home/nate/ramdrive/repo"
WC="/home/nate/ramdrive/wc"

rm -rf "$REPO"
rm -rf "$WC"

"$SVNADMIN" create "$REPO"
"$SVN" checkout "file://$REPO" "$WC"
cd "$WC"

mkdir dir
echo text > dir/file
"$SVN" add dir

# Commit r1
"$SVN" ci -m 'Add file'

"$SVN" cp dir/file file-moved
"$SVN" rm dir
echo replaced > dir
"$SVN" add dir

# Commit r2
"$SVN" ci -m 'Replace dir with file'

"$SVN" up

# The moment of truth
"$SVN" info "file://$REPO/dir/file"@1

]]]

Nathan
Received on 2019-11-22 07:02:14 CET

This is an archived mail posted to the Subversion Users mailing list.