From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vultr.musolino.id.au ([45.76.123.158]) by ewsd; Thu Dec 5 03:45:05 EST 2019 Received: from 121.45.60.200 ([121.45.60.200]) by vultr; Thu Dec 5 19:44:57 EST 2019 Message-ID: To: 9front@9front.org Subject: hgfs(4) getrevinfo patch From: Alex Musolino Date: Thu, 5 Dec 2019 19:14:56 +1030 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: configuration method Hi again, Another problem with hgfs(4) is that it incorrectly reports the size of files under the 'changes' directory that were renamed in a commit. Here's my fix. Seems to work, but also seems too obvious not to have been done this way already. Thoughts? diff -r 754916eeedf1 sys/src/cmd/hgfs/fs.c --- a/sys/src/cmd/hgfs/fs.c Tue Dec 03 18:32:30 2019 +1030 +++ b/sys/src/cmd/hgfs/fs.c Thu Dec 05 19:13:06 2019 +1030 @@ -104,7 +104,6 @@ getrevinfo(int rev) { Revinfo *ri; - if(rev < 0 || rev >= changelog.nmap) return nil; if(ri = changelog.map[rev].aux) @@ -236,7 +235,7 @@ char buf[64], *s; Revnode *nd; Revinfo *ri; - int rev; + int rev, fd; memset(d, 0, sizeof(*d)); @@ -302,15 +301,9 @@ break; if((rev = hashrev(rl, nd->hash)) >= 0){ if(level == Qtree){ - /* - * BUG: this is not correct. mercurial might - * prefix the data log with random \1\n escaped - * metadata strings (see fmetaheader()) and the flen - * *includes* the metadata part. we try to compensate - * for this once the revision got extracted and - * subtract the metadata header in fsstat(). - */ - d->length = rl->map[rev].flen; + fd = revlogopentemp(rl, rev); + d->length = rl->map[rev].flen - fmetaheader(fd); + close(fd); } ri = getrevinfo(rl->map[rev].linkrev); }