2555: On a https Mercurial URL, a diff on a file that currently exists throws an error

mail*****@gmai***** (Google Code) (Is this you? Claim this profile.)
July 4, 2012
2567
Configure reviewboard with a Mercurial https URL that works with the clone request. Change a file, create a diff using hg diff, upload. View the diff. (New files show up properly). The following error is thrown for any change on an existing file:

The file 'README' (rtip) could not be found in the repository
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/diffviewer/views.py", line 151, in view_diff
    interdiffset, highlighting, True)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 1072, in get_diff_files
    large_data=True)
  File "/usr/local/lib/python2.7/dist-packages/Djblets-0.6.16-py2.7.egg/djblets/util/misc.py", line 157, in cache_memoize
    data = lookup_callable()
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 1071, in <lambda>
    enable_syntax_highlighting)),
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 552, in get_chunks
    old = get_original_file(filediff)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 365, in get_original_file
    large_data=True)[0]
  File "/usr/local/lib/python2.7/dist-packages/Djblets-0.6.16-py2.7.egg/djblets/util/misc.py", line 157, in cache_memoize
    data = lookup_callable()
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 364, in <lambda>
    data = cache_memoize(key, lambda: [fetch_file(file, revision)],
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 343, in fetch_file
    data = tool.get_file(file, revision)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/scmtools/hg.py", line 35, in get_file
    return self.client.cat_file(path, str(revision))
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.4.1-py2.7.egg/reviewboard/scmtools/hg.py", line 199, in cat_file
    raise FileNotFoundError(path, rev)
FileNotFoundError: The file 'README' (rtip) could not be found in the repository
#1 mail*****@gmai***** (Google Code) (Is this you? Claim this profile.)
In hg.py, the offending function is:

class HgWebClient(SCMClient):
    FULL_FILE_URL = '%(url)s/%(rawpath)s/%(revision)s/%(quoted_path)s'

    def __init__(self, path, username, password):
        super(HgWebClient, self).__init__(path, username=username,
                                          password=password)

        logging.debug('Initialized HgWebClient with url=%r, username=%r',
                      self.path, self.username)

    def cat_file(self, path, rev="tip"):
        if rev == HEAD or rev == UNKNOWN:
            rev = "tip"
        elif rev == PRE_CREATION:
            rev = ""

        for rawpath in ["raw-file", "raw"]:
            try:
                url = self.FULL_FILE_URL % {
                    'url': self.path.rstrip('/'),
                    'rawpath': rawpath,
                    'revision': rev,
                    'quoted_path': urllib_quote(path.lstrip('/')),
                }

                url = url.replace('https', 'http')
                return self.get_file_http(url, path, rev)
            except Exception:
                # It failed. Error was logged and we may try again.
                pass

        raise FileNotFoundError(path, rev)
#3 mail*****@gmai***** (Google Code) (Is this you? Claim this profile.)
When fetching the file, the https was replaced with http, resulting in the error.
#4 mail*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Logs:
2012-03-28 16:41:44,497 - DEBUG - Initialized HgWebClient with url=u'https://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui', username=u'swami'
2012-03-28 16:41:44,498 - DEBUG - Initialized HgWebClient with url=u'https://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui', username=u'swami'
2012-03-28 16:41:44,500 - DEBUG - Generating diff viewer page for filediff id 9
2012-03-28 16:41:44,502 - DEBUG - Begin: Generating diff file info for diffset id 9
2012-03-28 16:41:44,504 - DEBUG - Initialized HgWebClient with url=u'https://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui', username=u'swami'
2012-03-28 16:41:44,505 - DEBUG - End: Generating diff file info for diffset id 9
2012-03-28 16:41:44,505 - DEBUG - Generating diff file info for diffset id 9 took 0.3049 seconds
2012-03-28 16:41:44,506 - DEBUG - Begin: Generating diff file info for diffset id 9, filediff 14
2012-03-28 16:41:44,506 - DEBUG - Initialized HgWebClient with url=u'https://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui', username=u'swami'
2012-03-28 16:41:44,507 - INFO - Cache miss for key reviews.example.com:diff-sidebyside-hl-14.
2012-03-28 16:41:44,507 - DEBUG - Initialized HgWebClient with url=u'https://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui', username=u'swami'
2012-03-28 16:41:44,508 - INFO - Cache miss for key reviews.nimblestorage.com:https%3A//in.example.com/cgi-bin/hgwebdir.cgi/dev/gui:README:UNKNOWN.
2012-03-28 16:41:44,508 - DEBUG - Begin: Fetching file 'README' rUNKNOWN from gui
2012-03-28 16:41:44,508 - INFO - Fetching file from http://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui/raw-file/tip/README
2012-03-28 16:41:44,512 - ERROR - Unexpected error fetching file from http://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui/raw-file/tip/README: <urlopen error [Errno 111] Connection refused>
2012-03-28 16:41:44,512 - INFO - Fetching file from http://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui/raw/tip/README
2012-03-28 16:41:44,515 - ERROR - Unexpected error fetching file from http://in.example.com/cgi-bin/hgwebdir.cgi/dev/gui/raw/tip/README: <urlopen error [Errno 111] Connection refused>
#6 tph***@gmai***** (Google Code) (Is this you? Claim this profile.)
This line commented out
                url = url.replace('https', 'http')
is working so far for us
#7 mail*****@gmai***** (Google Code) (Is this you? Claim this profile.)
In which file? Which line number?
#8 jon.ba*******@gmai***** (Google Code) (Is this you? Claim this profile.)
reviewboard/scmtools/hg.py:192

Had to find and fix this again after upgrading. 
#9 jon.ba*******@gmai***** (Google Code) (Is this you? Claim this profile.)
You may also need to remove the hg.pyc file to get it to read the changed file.
david
#10 david
Fixed in commit 514cbe4. This will go out with the next 1.6.x release.
  • +Fixed