hgext/phabricator.py
changeset 44647 99fa161a883c
parent 44646 5f9c917e3b50
child 44648 949a87145336
equal deleted inserted replaced
44646:5f9c917e3b50 44647:99fa161a883c
  1166             _(b'unknown username: %s') % b' '.join(sorted(unresolved))
  1166             _(b'unknown username: %s') % b' '.join(sorted(unresolved))
  1167         )
  1167         )
  1168     return [entry[b'phid'] for entry in data]
  1168     return [entry[b'phid'] for entry in data]
  1169 
  1169 
  1170 
  1170 
       
  1171 def _amend_diff_properties(unfi, drevid, newnodes, diff):
       
  1172     """update the local commit list for the ``diff`` associated with ``drevid``
       
  1173 
       
  1174     This is a utility function for the amend phase of ``phabsend``, which
       
  1175     converts failures to warning messages.
       
  1176     """
       
  1177     try:
       
  1178         writediffproperties([unfi[newnode] for newnode in newnodes], diff)
       
  1179     except util.urlerr.urlerror:
       
  1180         # If it fails just warn and keep going, otherwise the DREV
       
  1181         # associations will be lost
       
  1182         unfi.ui.warnnoi18n(b'Failed to update metadata for D%d\n' % drevid)
       
  1183 
       
  1184 
  1171 @vcrcommand(
  1185 @vcrcommand(
  1172     b'phabsend',
  1186     b'phabsend',
  1173     [
  1187     [
  1174         (b'r', b'rev', [], _(b'revisions to send'), _(b'REV')),
  1188         (b'r', b'rev', [], _(b'revisions to send'), _(b'REV')),
  1175         (b'', b'amend', True, _(b'update commit messages')),
  1189         (b'', b'amend', True, _(b'update commit messages')),
  1355                     )
  1369                     )
  1356 
  1370 
  1357                     newnode = new.commit()
  1371                     newnode = new.commit()
  1358 
  1372 
  1359                     mapping[old.node()] = [newnode]
  1373                     mapping[old.node()] = [newnode]
  1360                     # Update diff property
  1374 
  1361                     # If it fails just warn and keep going, otherwise the DREV
  1375                     _amend_diff_properties(
  1362                     # associations will be lost
  1376                         unfi, drevid, [newnode], diffmap[old.node()]
  1363                     try:
  1377                     )
  1364                         writediffproperties(
       
  1365                             [unfi[newnode]], diffmap[old.node()]
       
  1366                         )
       
  1367                     except util.urlerr.urlerror:
       
  1368                         ui.warnnoi18n(
       
  1369                             b'Failed to update metadata for D%d\n' % drevid
       
  1370                         )
       
  1371                 # Remove local tags since it's no longer necessary
  1378                 # Remove local tags since it's no longer necessary
  1372                 tagname = b'D%d' % drevid
  1379                 tagname = b'D%d' % drevid
  1373                 if tagname in repo.tags():
  1380                 if tagname in repo.tags():
  1374                     tags.tag(
  1381                     tags.tag(
  1375                         repo,
  1382                         repo,