"View Diff" cause "patch didn't apply cleanly" error when ReviewBoard is used with BitBucket repositories

2,112 views
Skip to first unread message

Nikita Zhuk

unread,
Dec 9, 2011, 3:03:07 AM12/9/11
to reviewboard
I'm using ReviewBoard 1.6.3 and my repositories are hosted at
BitBucket as private repositories. I have configured my repository in
the admin section of the RB by using HTTP URL and by entering my
BitBucket user name and password. I can submit review requests, upload
diffs and view raw diffs ("Download Diff") successfully, but when I
click "View Diff" button on the review page, I get the following stack
trace:

The patch to 'README.txt' didn't apply cleanly. The temporary files
have been left in '/tmp/reviewboard.FtaN0j' for debugging purposes.
`patch` returned: patching file /tmp/reviewboard.FtaN0j/tmpEtmkDI Hunk
#1 FAILED at 1. 1 out of 1 hunk FAILED -- saving rejects to file /tmp/
reviewboard.FtaN0j/tmpEtmkDI-new.rej

Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/ReviewBoard-1.6.3-py2.7.egg/
reviewboard/diffviewer/views.py", line 151, in view_diff
interdiffset, highlighting, True)
File "/Library/Python/2.7/site-packages/ReviewBoard-1.6.3-py2.7.egg/
reviewboard/diffviewer/diffutils.py", line 1071, in get_diff_files
large_data=True)
File "/Library/Python/2.7/site-packages/Djblets-0.6.14-py2.7.egg/
djblets/util/misc.py", line 156, in cache_memoize
data = lookup_callable()
File "/Library/Python/2.7/site-packages/ReviewBoard-1.6.3-py2.7.egg/
reviewboard/diffviewer/diffutils.py", line 1070, in <lambda>
enable_syntax_highlighting)),
File "/Library/Python/2.7/site-packages/ReviewBoard-1.6.3-py2.7.egg/
reviewboard/diffviewer/diffutils.py", line 552, in get_chunks
new = get_patched_file(old, filediff)
File "/Library/Python/2.7/site-packages/ReviewBoard-1.6.3-py2.7.egg/
reviewboard/diffviewer/diffutils.py", line 374, in get_patched_file
return patch(filediff.diff, buffer, filediff.dest_file)
File "/Library/Python/2.7/site-packages/ReviewBoard-1.6.3-py2.7.egg/
reviewboard/diffviewer/diffutils.py", line 242, in patch
(filename, tempdir, patch_output))
Exception: The patch to 'README.txt' didn't apply cleanly. The
temporary files have been left in '/tmp/reviewboard.FtaN0j' for
debugging purposes.
`patch` returned: patching file /tmp/reviewboard.FtaN0j/tmpEtmkDI
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file /tmp/
reviewboard.FtaN0j/tmpEtmkDI-new.rej

When I open the file which was saved at /tmp/reviewboard.FtaN0j/
tmpEtmkDI-new I can see the HTML code from BitBucket.org which
presents Log in forms, so no wonder the patching fails.

I found a similar problem description here as well:
https://groups.google.com/forum/#!msg/reviewboard/myKbvnIPqfw/Tk3n24tj-j8J

Any help would be greatly appreciated.

Christian Hammond

unread,
Dec 9, 2011, 2:41:44 PM12/9/11
to revie...@googlegroups.com
Hi Nikita,

Can you show me what the configuration looks like, roughly? (Censor out sensitive parts, but the structure is important).

It sounds like it's just some configuration error. It's not using a valid URL for fetching the raw files.

Christian

--
Christian Hammond - chi...@chipx86.com
Review Board - http://www.reviewboard.org
VMware, Inc. - http://www.vmware.com



--
Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/
Happy user? Let us know at http://www.reviewboard.org/users/
-~----------~----~----~----~------~----~------~--~---
To unsubscribe from this group, send email to reviewboard...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en

Nikita Zhuk

unread,
Dec 12, 2011, 2:30:29 AM12/12/11
to revie...@googlegroups.com
Hi Christian,

Sure. The repository configuration screen doesn't have any sensitive information visible (and I'm using a non-critical test repository anyway), so I'm attaching a screenshot of it here (the password field is blank in the screenshot, but I do use correct password in there of course).

ReviewBoard's settings_local.py looks like this:

$ cat conf/settings_local.py
# Site-specific configuration settings for Review Board
# Definitions of these settings can be found at

# Database configuration
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/Users/xxx/data/reviewboard.db',
    },
}

# Unique secret key. Don't share this with anybody.
SECRET_KEY = 'XXX'

# Cache backend settings.
CACHE_BACKEND = 'file:///tmp/reviewboard_cache'

# Extra site information.
SITE_ID = 1
SITE_ROOT = '/review/'
FORCE_SCRIPT_NAME = ''
DEBUG = True
LOGGING_ENABLED = True


Since I have enabled logging, I can also provide the debug-level log which is generated when I click the "View Diff" button:

ReviewBoard base URL: http://myhost.local/review
URL which is opened by clicking the "View Diff" button: http://myhost.local/review/r/39/diff/#index_header

Log output:

2011-12-09 20:20:00,157 - DEBUG - Logging to /tmp/rb/reviewboard.log with a minimum level of DEBUG
2011-12-09 20:20:00,157 - DEBUG - Log file for Review Board v1.6.3 (PID 10247)
2011-12-09 20:20:15,090 - DEBUG - Initialized HgWebClient with url=u'http://bitbucket.org/nzhuk/testrep1/', username=u'nzhuk'
2011-12-09 20:20:15,090 - DEBUG - Initialized HgWebClient with url=u'http://bitbucket.org/nzhuk/testrep1/', username=u'nzhuk'
2011-12-09 20:20:16,962 - DEBUG - Initialized HgWebClient with url=u'http://bitbucket.org/nzhuk/testrep1/', username=u'nzhuk'
2011-12-09 20:20:16,963 - DEBUG - Initialized HgWebClient with url=u'http://bitbucket.org/nzhuk/testrep1/', username=u'nzhuk'
2011-12-09 20:20:16,965 - DEBUG - Generating diff viewer page for filediff id 13
2011-12-09 20:20:16,966 - DEBUG - Begin: Generating diff file info for diffset id 13
2011-12-09 20:20:16,967 - DEBUG - Initialized HgWebClient with url=u'http://bitbucket.org/nzhuk/testrep1/', username=u'nzhuk'
2011-12-09 20:20:16,968 - DEBUG - End: Generating diff file info for diffset id 13
2011-12-09 20:20:16,968 - DEBUG - Generating diff file info for diffset id 13 took 0.1665 seconds
2011-12-09 20:20:16,968 - DEBUG - Begin: Generating diff file info for diffset id 13, filediff 13
2011-12-09 20:20:16,968 - DEBUG - Initialized HgWebClient with url=u'http://bitbucket.org/nzhuk/testrep1/', username=u'nzhuk'
2011-12-09 20:20:16,969 - INFO - Cache miss for key myhost.local:diff-sidebyside-hl-13.
2011-12-09 20:20:16,969 - DEBUG - Initialized HgWebClient with url=u'http://bitbucket.org/nzhuk/testrep1/', username=u'nzhuk'
2011-12-09 20:20:16,969 - INFO - Cache miss for key myhost.local:http%3A//bitbucket.org/nzhuk/testrep1/:README.txt:2df4ddabbe02.
2011-12-09 20:20:16,970 - DEBUG - Begin: Fetching file 'README.txt' r2df4ddabbe02 from TestRep1
2011-12-09 20:20:19,525 - DEBUG - End: Fetching file 'README.txt' r2df4ddabbe02 from TestRep1
2011-12-09 20:20:19,525 - DEBUG - Fetching file 'README.txt' r2df4ddabbe02 from TestRep1 took 2.555507 seconds
2011-12-09 20:20:19,527 - DEBUG - Begin: Patching file README.txt
2011-12-09 20:20:19,536 - DEBUG - End: Patching file README.txt
2011-12-09 20:20:19,536 - DEBUG - Patching file README.txt took 0.8341 seconds


rb-repository-config.png

Nikita Zhuk

unread,
Dec 21, 2011, 10:08:14 AM12/21/11
to reviewboard
Ok, I've debugged this problem a bit and came to the conclusion that
fetching raw files in hg.py from BitBucket with HTTPBasicAuthHandler
seems to have some issues. I've created a workaround by tweaking the
HgWebClient class a bit to use BitBucket API to fetch raw files. This
patch solved my problem:
https://github.com/nzhuk/reviewboard/commit/a56829a594ade9696a6ba9bfbfcdca63e3c16b25

Since it's BitBucket-only solution you probably wouldn't want to pull
it directly into the main fork, but it might give you some ideas for
the development.

- Nikita Zhuk


On Dec 12, 9:30 am, Nikita Zhuk <nikita.z...@gmail.com> wrote:
> Hi Christian,
>
> Sure. The repository configuration screen doesn't have any sensitive
> information visible (and I'm using a non-critical test repository anyway),
> so I'm attaching a screenshot of it here (the password field is blank in
> the screenshot, but I do use correct password in there of course).
>
> ReviewBoard's settings_local.py looks like this:
>
> $ cat conf/settings_local.py
> # Site-specific configuration settings for Review Board
> # Definitions of these settings can be found at
> #http://docs.djangoproject.com/en/dev/ref/settings/
>  rb-repository-config.png
> 83KViewDownload

Olivia

unread,
Jan 5, 2012, 3:46:35 AM1/5/12
to reviewboard
Hi Nikita,

I met the same issue with Git repository. Do you have any suggestion
to fix?
Should I also change /usr/local/lib/python2.6/dist-packages/
ReviewBoard-1.6-py2.6.egg/reviewboard/scmtools/git.py and how?

Best Regards,
Olivia Yin


On 2011年12月21日, 下午11时08分, Nikita Zhuk <nikita.z...@gmail.com> wrote:
> Ok, I've debugged this problem a bit and came to the conclusion that
> fetching raw files in hg.py from BitBucket with HTTPBasicAuthHandler
> seems to have some issues. I've created a workaround by tweaking the
> HgWebClient class a bit to use BitBucket API to fetch raw files. This
> patch solved my problem:https://github.com/nzhuk/reviewboard/commit/a56829a594ade9696a6ba9bfb...

Vairav

unread,
Jan 5, 2012, 9:04:32 PM1/5/12
to reviewboard
Hi,
I have a similar setup of ReviewBoard with Mercurial repository
being managed by RhodeCode with a username and password
authentication.
I'm able to do a 'hg postreview -o xxx' and when I click on 'View
Diff' I'm getting the same error.

Any pointers on the same would be really helpful.


Thanks,
Vairav

anand kadu

unread,
Feb 27, 2015, 11:04:17 AM2/27/15
to revie...@googlegroups.com, vayi...@gmail.com

Hi Olivia,

I am able to set up git with review board and able to view diff. For this you need to have local git repository on same machine as review board or else if you want connect to remote repository u need to have gitweb installed in git server.

Thanks
Anand
Reply all
Reply to author
Forward
0 new messages