##// END OF EJS Templates
phabricator: teach createdifferentialrevision() to allow a folded commit range...
Matt Harbison -
r45135:419fec82 default
parent child Browse files
Show More
@@ -1014,9 +1014,10 b' def writediffproperties(ctxs, diff):'
1014 1014
1015 1015
1016 1016 def createdifferentialrevision(
1017 ctx,
1017 ctxs,
1018 1018 revid=None,
1019 1019 parentrevphid=None,
1020 oldbasenode=None,
1020 1021 oldnode=None,
1021 1022 olddiff=None,
1022 1023 actions=None,
@@ -1027,17 +1028,29 b' def createdifferentialrevision('
1027 1028 If revid is None, create a new Differential Revision, otherwise update
1028 1029 revid. If parentrevphid is not None, set it as a dependency.
1029 1030
1031 If there is a single commit for the new Differential Revision, ``ctxs`` will
1032 be a list of that single context. Otherwise, it is a list that covers the
1033 range of changes for the differential, where ``ctxs[0]`` is the first change
1034 to include and ``ctxs[-1]`` is the last.
1035
1030 1036 If oldnode is not None, check if the patch content (without commit message
1031 and metadata) has changed before creating another diff.
1037 and metadata) has changed before creating another diff. For a Revision with
1038 a single commit, ``oldbasenode`` and ``oldnode`` have the same value. For a
1039 Revision covering multiple commits, ``oldbasenode`` corresponds to
1040 ``ctxs[0]`` the previous time this Revision was posted, and ``oldnode``
1041 corresponds to ``ctxs[-1]``.
1032 1042
1033 1043 If actions is not None, they will be appended to the transaction.
1034 1044 """
1035 basectx = ctx
1045 ctx = ctxs[-1]
1046 basectx = ctxs[0]
1047
1036 1048 repo = ctx.repo()
1037 1049 if oldnode:
1038 1050 diffopts = mdiff.diffopts(git=True, context=32767)
1039 oldctx = repo.unfiltered()[oldnode]
1040 oldbasectx = oldctx
1051 unfi = repo.unfiltered()
1052 oldctx = unfi[oldnode]
1053 oldbasectx = unfi[oldbasenode]
1041 1054 neednewdiff = getdiff(basectx, ctx, diffopts) != getdiff(
1042 1055 oldbasectx, oldctx, diffopts
1043 1056 )
@@ -1056,7 +1069,7 b' def createdifferentialrevision('
1056 1069 # pushers could know the correct node metadata.
1057 1070 assert olddiff
1058 1071 diff = olddiff
1059 writediffproperties([ctx], diff)
1072 writediffproperties(ctxs, diff)
1060 1073
1061 1074 # Set the parent Revision every time, so commit re-ordering is picked-up
1062 1075 if parentrevphid:
@@ -1076,7 +1089,7 b' def createdifferentialrevision('
1076 1089 # this gets assigned to the title.
1077 1090 fields = util.sortdict() # sorted for stable wire protocol in tests
1078 1091
1079 for i, _ctx in enumerate([ctx]):
1092 for i, _ctx in enumerate(ctxs):
1080 1093 # Parse commit message and update related fields.
1081 1094 desc = _ctx.description()
1082 1095 info = callconduit(
@@ -1111,7 +1124,11 b' def createdifferentialrevision('
1111 1124
1112 1125 revision = callconduit(repo.ui, b'differential.revision.edit', params)
1113 1126 if not revision:
1114 raise error.Abort(_(b'cannot create revision for %s') % ctx)
1127 if len(ctxs) == 1:
1128 msg = _(b'cannot create revision for %s') % ctx
1129 else:
1130 msg = _(b'cannot create revision for %s::%s') % (basectx, ctx)
1131 raise error.Abort(msg)
1115 1132
1116 1133 return revision, diff
1117 1134
@@ -1226,12 +1243,14 b' def phabsend(ui, repo, *revs, **opts):'
1226 1243
1227 1244 # Get Differential Revision ID
1228 1245 oldnode, olddiff, revid = oldmap.get(ctx.node(), (None, None, None))
1246 oldbasenode = oldnode
1229 1247 if oldnode != ctx.node() or opts.get(b'amend'):
1230 1248 # Create or update Differential Revision
1231 1249 revision, diff = createdifferentialrevision(
1232 ctx,
1250 [ctx],
1233 1251 revid,
1234 1252 lastrevphid,
1253 oldbasenode,
1235 1254 oldnode,
1236 1255 olddiff,
1237 1256 actions,
General Comments 0
You need to be logged in to leave comments. Login now