Page MenuHomePhabricator

Add sourceControlSystem parameter to differential.createrawdiff
Closed, DuplicatePublic

Description

I'm writing a Mercurial extension to send changesets to Differential like hg email provided by patchbomb extension. Part of the logic requires "find a differential revision by commit hash" so it detects whether to update or create new differential revisions.

Since the extension is in Python, I'd like to use createrawdiff API, which is easier to use than creatediff. However, I found revision with diff created by differential.createrawdiff won't be searched via commit hash, even if local:commits property was added correctly using differential.setdiffproperty.

Upon investigation, it is because createrawdiff won't set sourceControlSystem information. So DifferentialTransactionEditor won't read local:commits metadata and won't write the differential_revisionhash table.

Therefore it'd be nice for createrawdiff to allow setting sourceControlSystem.

Event Timeline

quark.zju created this task.Jul 2 2017, 6:47 PM

I'm writing a Mercurial extension to send changesets to Differential like hg email provided by patchbomb extension.

Why?

See also Contributing Feature Requests.

quark.zju added a comment.EditedJul 2 2017, 7:16 PM

The background is the Mercurial community wants to try Phabricator as an experimental review system. It's using emails now. I'd like to make Phabricator workflow as convenient as traditional email workflow.

The community like small patches. So if someone has a feature branch of 5 commits, they should be sent as 5 differential revisions, instead of 1.

Using hg email, sending a stack of commits is one command like hg email -r 'feature-bookmark % master'. It seems arcanist cannot do that yet.

Note: hg email also allows sending arbitrary (non-continuous) commits, for example, given the following DAG:

  o C
  |
  o B
  |
  | o D
  |/
  o A
 /
o master 
|

It's possible to run hg email -r A+D+C and it sends 3 emails as expected.

What I want to achieve is a drop-in replacement of hg email, since that's more familiar to members in the hg community. To be able to do that, I think it needs to:

  • Accept arbitrary commits.
  • No amends.
  • No editor prompts.

Modern Mercurial could track a chain of hash changes, like if hg commit --amend causes hash X to be changed to Y, it records such information in obsstore where it's possible to get X given Y. I think that information could be used to query Phabricator to get Differential Revision, so amending commit messages could be skipped.