Mercurial > public > mercurial-scm > hg
comparison contrib/phabricator.py @ 33692:f100354cce52
phabricator: update diff property even if we choose not to create a new diff
The diff property contains metadata like "HG Node". Previously we skip
uploading a new diff if we are sure that the old patch and new patch have a
same content. That has issues when a pusher adds an obsmarker using the old
"HG Node" stored in the old diff.
This patch adds logic to update the diff property so "HG Node" gets updated
to prevent that issue.
Differential Revision: https://phab.mercurial-scm.org/D229
author | Jun Wu <quark@fb.com> |
---|---|
date | Fri, 04 Aug 2017 12:21:23 -0700 |
parents | 1664406a44d9 |
children | e6d8ee3c9ec3 |
comparison
equal
deleted
inserted
replaced
33691:1664406a44d9 | 33692:f100354cce52 |
---|---|
253 }), | 253 }), |
254 } | 254 } |
255 callconduit(ctx.repo(), 'differential.setdiffproperty', params) | 255 callconduit(ctx.repo(), 'differential.setdiffproperty', params) |
256 | 256 |
257 def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, | 257 def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, |
258 actions=None): | 258 olddiff=None, actions=None): |
259 """create or update a Differential Revision | 259 """create or update a Differential Revision |
260 | 260 |
261 If revid is None, create a new Differential Revision, otherwise update | 261 If revid is None, create a new Differential Revision, otherwise update |
262 revid. If parentrevid is not None, set it as a dependency. | 262 revid. If parentrevid is not None, set it as a dependency. |
263 | 263 |
277 transactions = [] | 277 transactions = [] |
278 if neednewdiff: | 278 if neednewdiff: |
279 diff = creatediff(ctx) | 279 diff = creatediff(ctx) |
280 writediffproperties(ctx, diff) | 280 writediffproperties(ctx, diff) |
281 transactions.append({'type': 'update', 'value': diff[r'phid']}) | 281 transactions.append({'type': 'update', 'value': diff[r'phid']}) |
282 else: | |
283 # Even if we don't need to upload a new diff because the patch content | |
284 # does not change. We might still need to update its metadata so | |
285 # pushers could know the correct node metadata. | |
286 assert olddiff | |
287 diff = olddiff | |
288 writediffproperties(ctx, diff) | |
282 | 289 |
283 # Use a temporary summary to set dependency. There might be better ways but | 290 # Use a temporary summary to set dependency. There might be better ways but |
284 # I cannot find them for now. But do not do that if we are updating an | 291 # I cannot find them for now. But do not do that if we are updating an |
285 # existing revision (revid is not None) since that introduces visible | 292 # existing revision (revid is not None) since that introduces visible |
286 # churns (someone edited "Summary" twice) on the web page. | 293 # churns (someone edited "Summary" twice) on the web page. |
381 # Get Differential Revision ID | 388 # Get Differential Revision ID |
382 oldnode, olddiff, revid = oldmap.get(ctx.node(), (None, None, None)) | 389 oldnode, olddiff, revid = oldmap.get(ctx.node(), (None, None, None)) |
383 if oldnode != ctx.node(): | 390 if oldnode != ctx.node(): |
384 # Create or update Differential Revision | 391 # Create or update Differential Revision |
385 revision = createdifferentialrevision(ctx, revid, lastrevid, | 392 revision = createdifferentialrevision(ctx, revid, lastrevid, |
386 oldnode, actions) | 393 oldnode, olddiff, actions) |
387 newrevid = int(revision[r'object'][r'id']) | 394 newrevid = int(revision[r'object'][r'id']) |
388 if revid: | 395 if revid: |
389 action = _('updated') | 396 action = _('updated') |
390 else: | 397 else: |
391 action = _('created') | 398 action = _('created') |