2492: HgWebClient.cat_file is broken: it returns valid data for missing files

dshpe******@gmai***** (Google Code) (Is this you? Claim this profile.)
Jan. 30, 2014
What version are you running?

1.6.3

What's the URL of the page containing the problem?

http://[host]/r/[id]/diff/#index_

What steps will reproduce the problem?

1. clone upstream mercurial repository 
2. add a commit, but don't push it
3. do 'hg postreview tip'
4. try to 'View Diff' on the draft review page

What is the expected output? What do you see instead?

Expected to see API reject the patch mentioning non-existent commit (it's not in upstream, remember?) and, thus, expected postreview to fail.
But instead postreview is successful, but diff page shows a trace saying it can't apply the patch

What operating system are you using? What browser?

Debian Linux, Iceweasel (a.k.a Firefox)

Please provide any additional information below.

Basically, the that newly created commit isn't present in upstream and thus reviewboard cannot properly fetch 'raw-file/NEW_REVISION/path/to/file'. That's OK, given the fact that it's _my_ error to post a review for a commit not present in upstream. But here's the glitch: somewhere under the hood an arbitrary file is actually fetched, but it's not the expected file and patching fails.

I've traced the source to HgWebClient.cat_file('path/to/file', rev=>'NEW_REVISION'), which succeeds and instead of the requested file or HTTP404 returns a summary page, which is wrong.

The loop

        for rawpath in ["raw-file", "raw"]:
            full_url = ''

returns proper HTTP404 for "raw-file" iteration, but for "raw" it succeeds and return contents of a summary web-page.
#1 dshpe******@gmai***** (Google Code) (Is this you? Claim this profile.)
A minor followup here:

I've taken the freedom to remove "raw" from that loop and now 'hg postreview' fails with

HTTP Error 400: BAD REQUEST

So, an additional request here is to see if a meaningful API error may be returned in such situations.

PS. On second thought, mercurial-postreview may be guilty in this situation. My apologies, if that's the case.
david
#2 david
  • +Component-SCMTools
david
#3 david
Yeah, I think that this is a third-party problem.
  • +ThirdParty