Show More
@@ -483,18 +483,23 b' def getoldnodedrevmap(repo, nodelist):' | |||
|
483 | 483 | alldiffs = callconduit( |
|
484 | 484 | unfi.ui, b'differential.querydiffs', {b'revisionIDs': drevs} |
|
485 | 485 | ) |
|
486 | getnode = lambda d: bin(getdiffmeta(d).get(b'node', b'')) or None | |
|
486 | ||
|
487 | def getnodes(d, precset): | |
|
488 | # Ignore other nodes that were combined into the Differential | |
|
489 | # that aren't predecessors of the current local node. | |
|
490 | return [n for n in getlocalcommits(d) if n in precset] | |
|
491 | ||
|
487 | 492 | for newnode, (force, precset, drev) in toconfirm.items(): |
|
488 | 493 | diffs = [ |
|
489 | 494 | d for d in alldiffs.values() if int(d[b'revisionID']) == drev |
|
490 | 495 | ] |
|
491 | 496 | |
|
492 |
# |
|
|
493 |
phprecset = { |
|
|
497 | # local predecessors known by Phabricator | |
|
498 | phprecset = {n for d in diffs for n in getnodes(d, precset)} | |
|
494 | 499 | |
|
495 | 500 | # Ignore if precursors (Phabricator and local repo) do not overlap, |
|
496 | 501 | # and force is not set (when commit message says nothing) |
|
497 |
if not force and not |
|
|
502 | if not force and not phprecset: | |
|
498 | 503 | tagname = b'D%d' % drev |
|
499 | 504 | tags.tag( |
|
500 | 505 | repo, |
@@ -519,7 +524,20 b' def getoldnodedrevmap(repo, nodelist):' | |||
|
519 | 524 | oldnode = lastdiff = None |
|
520 | 525 | if diffs: |
|
521 | 526 | lastdiff = max(diffs, key=lambda d: int(d[b'id'])) |
|
522 | oldnode = getnode(lastdiff) | |
|
527 | oldnodes = getnodes(lastdiff, precset) | |
|
528 | ||
|
529 | # If this commit was the result of `hg fold` after submission, | |
|
530 | # and now resubmitted with --fold, the easiest thing to do is | |
|
531 | # to leave the node clear. This only results in creating a new | |
|
532 | # diff for the _same_ Differential Revision if this commit is | |
|
533 | # the first or last in the selected range. | |
|
534 | # If this commit is the result of `hg split` in the same | |
|
535 | # scenario, there is a single oldnode here (and multiple | |
|
536 | # newnodes mapped to it). That makes it the same as the normal | |
|
537 | # case, as the edges of the newnode range cleanly maps to one | |
|
538 | # oldnode each. | |
|
539 | if len(oldnodes) == 1: | |
|
540 | oldnode = oldnodes[0] | |
|
523 | 541 | if oldnode and not has_node(oldnode): |
|
524 | 542 | oldnode = None |
|
525 | 543 | |
@@ -1667,6 +1685,21 b' def get_amended_desc(drev, ctx, folded):' | |||
|
1667 | 1685 | return _differentialrevisiondescre.sub(uri, ctx.description()) |
|
1668 | 1686 | |
|
1669 | 1687 | |
|
1688 | def getlocalcommits(diff): | |
|
1689 | """get the set of local commits from a diff object | |
|
1690 | ||
|
1691 | See ``getdiffmeta()`` for an example diff object. | |
|
1692 | """ | |
|
1693 | props = diff.get(b'properties') or {} | |
|
1694 | commits = props.get(b'local:commits') or {} | |
|
1695 | if len(commits) > 1: | |
|
1696 | return {bin(c) for c in commits.keys()} | |
|
1697 | ||
|
1698 | # Storing the diff metadata predates storing `local:commits`, so continue | |
|
1699 | # to use that in the --no-fold case. | |
|
1700 | return {bin(getdiffmeta(diff).get(b'node', b'')) or None} | |
|
1701 | ||
|
1702 | ||
|
1670 | 1703 | def getdiffmeta(diff): |
|
1671 | 1704 | """get commit metadata (date, node, user, p1) from a diff object |
|
1672 | 1705 |
General Comments 0
You need to be logged in to leave comments.
Login now