comparison hgext/phabricator.py @ 43829:16b607e9f714

phabricator: fix processing of tags/desc in getoldnodedrevmap() It seems that the previous logic was wrong (it essentially comes from changeset 3ab0d5767b54 where the result got accumulated instead of early returned). First of all, the "continue" in first "if m:" is useless because we're at the end of the loop. Then, the algorithm seems weird because we will process all predecessors of a node and possibly override `toconfirm[node]` for each of these having a tag (maybe this doesn't happen, but still). Finally, we would also override `toconfirm[node]` when the "Differential Revision: " is found in changeset description. Maybe this is not a big deal when there is no mix of local tag and changeset description update? The logic is changed so that the loop on predecessors stops upon first match of a tag and so that the changeset description is only checked if no tag was found. Therefore, `toconfirm[node]` is only set once. Differential Revision: https://phab.mercurial-scm.org/D7513
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 21 Nov 2019 18:10:12 +0100
parents 4cb3f5bb29ec
children 70060915c3f2
comparison
equal deleted inserted replaced
43828:36444dddaeb4 43829:16b607e9f714
401 if has_node(n): 401 if has_node(n):
402 for tag in unfi.nodetags(n): 402 for tag in unfi.nodetags(n):
403 m = _differentialrevisiontagre.match(tag) 403 m = _differentialrevisiontagre.match(tag)
404 if m: 404 if m:
405 toconfirm[node] = (0, set(precnodes), int(m.group(1))) 405 toconfirm[node] = (0, set(precnodes), int(m.group(1)))
406 continue 406 break
407 407 else:
408 # Check commit message 408 continue # move to next predecessor
409 m = _differentialrevisiondescre.search(ctx.description()) 409 break # found a tag, stop
410 if m: 410 else:
411 toconfirm[node] = (1, set(precnodes), int(m.group('id'))) 411 # Check commit message
412 m = _differentialrevisiondescre.search(ctx.description())
413 if m:
414 toconfirm[node] = (1, set(precnodes), int(m.group('id')))
412 415
413 # Double check if tags are genuine by collecting all old nodes from 416 # Double check if tags are genuine by collecting all old nodes from
414 # Phabricator, and expect precursors overlap with it. 417 # Phabricator, and expect precursors overlap with it.
415 if toconfirm: 418 if toconfirm:
416 drevs = [drev for force, precs, drev in toconfirm.values()] 419 drevs = [drev for force, precs, drev in toconfirm.values()]