The patch to {file_name} didn't apply cleanly

687 views
Skip to first unread message

Jonathan Avraham

unread,
Mar 23, 2017, 5:40:21 AM3/23/17
to reviewboard
Hi All,

I have an issue creating a review for a patch I created from a few consecutive git commits.
I used the following command: 
git format-patch --stdout --full-index 6fa2c8f..8094a86 > patch2.patch

Most of the files in the patch are visible in the review, but some of the files have been changed in more than one commit. One of the commits for this file is visible, but the others appear with an error "The patch to {file_name} didn't apply cleanly":

Traceback (most recent call last):
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/views.py", line 299, in get
    response
= renderer.render_to_response(request)
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 56, in render_to_response
   
return HttpResponse(self.render_to_string(request))
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 74, in render_to_string
    large_data
=True)
 
File "/usr/lib/python2.7/site-packages/djblets/cache/backend.py", line 295, in cache_memoize
    compress_large_data
))
 
File "/usr/lib/python2.7/site-packages/djblets/cache/backend.py", line 249, in cache_memoize_iter
    items
= items_or_callable()
 
File "/usr/lib/python2.7/site-packages/djblets/cache/backend.py", line 292, in <lambda>
   
lambda: [lookup_callable()],
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 73, in <lambda>
   
lambda: self.render_to_string_uncached(request),
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 87, in render_to_string_uncached
    request
=request)
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/diffutils.py", line 667, in populate_diff_chunks
    chunks
= list(generator.get_chunks())
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 756, in get_chunks
   
for chunk in super(DiffChunkGenerator, self).get_chunks(cache_key):
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 107, in get_chunks
    large_data
=True)
 
File "/usr/lib/python2.7/site-packages/djblets/cache/backend.py", line 295, in cache_memoize
    compress_large_data
))
 
File "/usr/lib/python2.7/site-packages/djblets/cache/backend.py", line 249, in cache_memoize_iter
    items
= items_or_callable()
 
File "/usr/lib/python2.7/site-packages/djblets/cache/backend.py", line 292, in <lambda>
   
lambda: [lookup_callable()],
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 106, in <lambda>
   
lambda: list(self.get_chunks_uncached()),
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 763, in get_chunks_uncached
   
new = get_patched_file(old, self.filediff, self.request)
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/diffutils.py", line 233, in get_patched_file
   
return patch(diff, buffer, filediff.dest_file, request)
 
File "/usr/lib/python2.7/site-packages/reviewboard/diffviewer/diffutils.py", line 169, in patch
   
'output': stderr,
Exception: The patch to '{file_name}' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.E5Av7z' for debugging purposes.
`patch` returned:

Is there any way to make this workflow work without squashing the commits?

Thanks,
Jonathan 

Christian Hammond

unread,
Mar 23, 2017, 5:49:32 AM3/23/17
to revie...@googlegroups.com
Hi Jonathan,

So there's a few important things to note here, which are the reasons you're encountering problems.

The first is that if you're posting a commit that's based on another commit that's up for review, a diff must be provided that covers everything from the last upstream commit to the base of the commit you want to post. So if you have master -> my-parent -> my-branch, a "parent diff" of master..my-branch must be provided. The reason is that we have to be able to actually apply these uploaded diffs onto something, and if the commit is based on changes that can't be fetched from the repository, the parent diff is needed to convert the most recent version of that file into something that the diff can be applied to.

The second is that, while you're attempting to generate a single diff file containing multiple commits, there's not actually a standard for doing this, and it's not something Review Board supports. You can create a review request per commit (using the "Depends On" field to link them, or you can squash the commits, but you can't have one diff represent multiple commits.

The third is that current versions of Review Board do not support multi-commit review. The diff viewer for a review request can't represent multiple commits. This functionality *is* coming. It's in development for Review Board 4.0. To give you a sense of timeframe, 3.0 is the release we'll be shipping this year, which is still in development, and 4.0 is the following release, which is receiving parallel development. The reason the multi-commit support is getting its own release instead of going into 3.0 is that there's really a lot we want to get just right, and a lot we want to bring with multi-commit support. It won't be ready right away, and we don't want to delay 3.0 any further. It's going to be pretty great, though.

So you'll want to either squash the commits or post one per review request. I strongly encourage you to use RBTools, if you don't already, to post these. It'll make the process much easier. I believe there exists a script somewhere out there for taking a series of commits and turning it into a series of review requests, all linked up, but I don't have it.

Christian

-- 
Christian Hammond
President/CEO of Beanbag
Makers of Review Board

--
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 the Google Groups "reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages