Show More
@@ -1067,13 +1067,41 b' def createdifferentialrevision(' | |||
|
1067 | 1067 | if actions: |
|
1068 | 1068 | transactions += actions |
|
1069 | 1069 | |
|
1070 | # When folding multiple local commits into a single review, arcanist will | |
|
1071 | # take the summary line of the first commit as the title, and then | |
|
1072 | # concatenate the rest of the remaining messages (including each of their | |
|
1073 | # first lines) to the rest of the first commit message (each separated by | |
|
1074 | # an empty line), and use that as the summary field. Do the same here. | |
|
1075 | # For commits with only a one line message, there is no summary field, as | |
|
1076 | # this gets assigned to the title. | |
|
1077 | fields = util.sortdict() # sorted for stable wire protocol in tests | |
|
1078 | ||
|
1079 | for i, _ctx in enumerate([ctx]): | |
|
1070 | 1080 | # Parse commit message and update related fields. |
|
1071 | desc = ctx.description() | |
|
1081 | desc = _ctx.description() | |
|
1072 | 1082 | info = callconduit( |
|
1073 | 1083 | repo.ui, b'differential.parsecommitmessage', {b'corpus': desc} |
|
1074 | 1084 | ) |
|
1075 | for k, v in info[b'fields'].items(): | |
|
1076 |
|
|
|
1085 | ||
|
1086 | for k in [b'title', b'summary', b'testPlan']: | |
|
1087 | v = info[b'fields'].get(k) | |
|
1088 | if not v: | |
|
1089 | continue | |
|
1090 | ||
|
1091 | if i == 0: | |
|
1092 | # Title, summary and test plan (if present) are taken verbatim | |
|
1093 | # for the first commit. | |
|
1094 | fields[k] = v.rstrip() | |
|
1095 | continue | |
|
1096 | elif k == b'title': | |
|
1097 | # Add subsequent titles (i.e. the first line of the commit | |
|
1098 | # message) back to the summary. | |
|
1099 | k = b'summary' | |
|
1100 | ||
|
1101 | # Append any current field to the existing composite field | |
|
1102 | fields[k] = b'\n\n'.join(filter(None, [fields.get(k), v.rstrip()])) | |
|
1103 | ||
|
1104 | for k, v in fields.items(): | |
|
1077 | 1105 |
|
|
1078 | 1106 | |
|
1079 | 1107 | params = {b'transactions': transactions} |
@@ -1266,7 +1294,7 b' def phabsend(ui, repo, *revs, **opts):' | |||
|
1266 | 1294 | old = unfi[rev] |
|
1267 | 1295 | drevid = drevids[i] |
|
1268 | 1296 | drev = [d for d in drevs if int(d[b'id']) == drevid][0] |
|
1269 |
newdesc = getdesc |
|
|
1297 | newdesc = get_amended_desc(drev, old, False) | |
|
1270 | 1298 | # Make sure commit message contain "Differential Revision" |
|
1271 | 1299 | if old.description() != newdesc: |
|
1272 | 1300 | if old.phase() == phases.public: |
@@ -1593,6 +1621,33 b' def getdescfromdrev(drev):' | |||
|
1593 | 1621 | return b'\n\n'.join(filter(None, [title, summary, testplan, uri])) |
|
1594 | 1622 | |
|
1595 | 1623 | |
|
1624 | def get_amended_desc(drev, ctx, folded): | |
|
1625 | """similar to ``getdescfromdrev``, but supports a folded series of commits | |
|
1626 | ||
|
1627 | This is used when determining if an individual commit needs to have its | |
|
1628 | message amended after posting it for review. The determination is made for | |
|
1629 | each individual commit, even when they were folded into one review. | |
|
1630 | """ | |
|
1631 | if not folded: | |
|
1632 | return getdescfromdrev(drev) | |
|
1633 | ||
|
1634 | uri = b'Differential Revision: %s' % drev[b'uri'] | |
|
1635 | ||
|
1636 | # Since the commit messages were combined when posting multiple commits | |
|
1637 | # with --fold, the fields can't be read from Phabricator here, or *all* | |
|
1638 | # affected local revisions will end up with the same commit message after | |
|
1639 | # the URI is amended in. Append in the DREV line, or update it if it | |
|
1640 | # exists. At worst, this means commit message or test plan updates on | |
|
1641 | # Phabricator aren't propagated back to the repository, but that seems | |
|
1642 | # reasonable for the case where local commits are effectively combined | |
|
1643 | # in Phabricator. | |
|
1644 | m = _differentialrevisiondescre.search(ctx.description()) | |
|
1645 | if not m: | |
|
1646 | return b'\n\n'.join([ctx.description(), uri]) | |
|
1647 | ||
|
1648 | return _differentialrevisiondescre.sub(uri, ctx.description()) | |
|
1649 | ||
|
1650 | ||
|
1596 | 1651 | def getdiffmeta(diff): |
|
1597 | 1652 | """get commit metadata (date, node, user, p1) from a diff object |
|
1598 | 1653 |
General Comments 0
You need to be logged in to leave comments.
Login now