Cannot load commits from hgweb when using strange branch name

20 views
Skip to first unread message

Rob Petti

unread,
Feb 4, 2020, 12:50:50 PM2/4/20
to Review Board Community
Hi Folks,

I'm currently running into the following issue when trying to view changes in a particular mercurial branch. No changes show up and no error message is visible in the UI. The server log dumps this out:

2020-02-04 15:47:22,688 - ERROR -  - root - Cannot load commits from hgweb: Unexpected error fetching file from http://mercurial.XXXXXX.net/xxxxxx/xxxxx/json-log/?rev=ancestors(08d863d1ad70a60fcae7afe9394206fb2d2c0fac)+and+branch(XXXXX-12371 & XXXXX-10577): URL can't contain control characters. u'/xxxxxx/xxxxxx/json-log/?rev=ancestors(08d863d1ad70a60fcae7afe9394206fb2d2c0fac)+and+branch(XXXXX-12371 & XXXXX-10577)' (found at least u' ')
Traceback (most recent call last):
  File "/opt/venv/local/lib/python2.7/site-packages/reviewboard/scmtools/hg.py", line 386, in get_commits
    contents = self.get_file_http(url, '', '', 'application/json')
  File "/opt/venv/local/lib/python2.7/site-packages/reviewboard/scmtools/core.py", line 1163, in get_file_
http
    raise SCMError(msg)

I'm guessing it's having difficulty handling the branch name "XXXXX-12371 & XXXXX-10577"? Other branches don't seem to have this issue.

~Rob

André Klitzing

unread,
Feb 12, 2020, 5:59:43 AM2/12/20
to Review Board Community
Hi,

seems your branch name needs url encoding. Maybe you could try this quickfix.
I did not test it as I don't have a development environment at the moment. So sorry if it throws errors.

diff --git a/reviewboard/scmtools/hg.py b/reviewboard/scmtools/hg.py
index bbf70cd7c..1e3fca175 100644
--- a/reviewboard/scmtools/hg.py
+++ b/reviewboard/scmtools/hg.py
@@ -378,7 +378,8 @@ class HgWebClient(SCMClient):
         if start:
             query_parts.append('ancestors(%s)' % start)
 
-        query_parts.append('branch(%s)' % (branch or '.'))
+        import urllib.parse
+        query_parts.append('branch(%s)' % (urllib.parse.quote_plus(branch) or '.'))
 
         query = '+and+'.join(query_parts)
 

Rob Petti

unread,
Feb 12, 2020, 10:48:46 AM2/12/20
to revie...@googlegroups.com
Thanks, André

We had the user rename the branch instead and that seemed to work. Your fix looks fine (though I'm also not able to test it) so hopefully the devs will put it into a release in the future.

~Rob

--
Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to a topic in the Google Groups "Review Board Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reviewboard/vdmj1o_moY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reviewboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard/81cc588e-c12d-4ff5-a76b-466603cbc942%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages