1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #8199 open

Pull Request REST API-2.0 doesn't generate diff for empty files in Mercurial (BB-8785)

Kacper Kowalik
created an issue

Example of the behaviour can be seen here

where you get:

--- /dev/null
+++ b/pelny.txt
@@ -0,0 +1,1 @@
+blababab

instead of

diff --git a/pelny.txt b/pelny.txt
new file mode 100644
--- /dev/null
+++ b/pelny.txt
@@ -0,0 +1,1 @@
+blababab
diff --git a/pusty.txt b/pusty.txt
new file mode 100644

It is troublesome for Python projects which tend to use things like empty __init__.py a lot. This breaks our CI as patch -p1 < REST_patch fails to create everything properly. I guess this is caused by using just hg diff, possible solution is to switch to using hg diff --git -U 1 internally.

Comments (12)

  1. Erik van Zijst staff

    Let me give you a quick update on this.

    This is indeed caused by Hg not using -g when it generates the diff. We normally produce git-style diffs on the site (e.g. https://bitbucket.org/pypy/pypy/commits/9d966eac78e1531926f9a3685fbbbf2b74f4400e/raw/), except for pull requests.

    This is due to a limitation in the code that is responsible for computing the merge for open pull requests, without actually committing anything to the destination repo. This code is currently not capable of doing git-style diffs.

    Another consequence of this limitation is that we're not able to include any binary files.

  2. Martin Lui

    Is it correct to say that, because of this bug, all Mercurial pull request diffs provided by the "GET https://bitbucket.org/api/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/diff" API is not using the GIT format, contrary to the documentation at https://confluence.atlassian.com/display/BITBUCKET/pullrequests+Resource#pullrequestsResource-getDiffGETthediffforapullrequest ?

    I've noticed this issue while testing on a private test repository, for example: https://bitbucket.org/api/2.0/repositories/martian111/test/pullrequests/1/diff

    I was about to open a ticket indicating that the returned diff is not in th GIT format. If this is the same issue, then I won't (or shouldn't) open a new ticket. Please advise...

    Thanks!

  3. Log in to comment