hgext/phabricator.py
changeset 44550 bbb170f9396d
parent 44452 9d2b2df2c2ba
child 44551 9bae1d1a0f4c
equal deleted inserted replaced
44549:47f8c741df0f 44550:bbb170f9396d
  1701 
  1701 
  1702     readpatch(ui, drevs, _write)
  1702     readpatch(ui, drevs, _write)
  1703 
  1703 
  1704 
  1704 
  1705 @vcrcommand(
  1705 @vcrcommand(
       
  1706     b'phabimport',
       
  1707     [(b'', b'stack', False, _(b'import dependencies as well'))],
       
  1708     _(b'DREVSPEC [OPTIONS]'),
       
  1709     helpcategory=command.CATEGORY_IMPORT_EXPORT,
       
  1710 )
       
  1711 def phabimport(ui, repo, spec, **opts):
       
  1712     """import patches from Phabricator for the specified Differential Revisions
       
  1713 
       
  1714     The patches are read and applied starting at the parent of the working
       
  1715     directory.
       
  1716 
       
  1717     See ``hg help phabread`` for how to specify DREVSPEC.
       
  1718     """
       
  1719     opts = pycompat.byteskwargs(opts)
       
  1720 
       
  1721     # --bypass avoids losing exec and symlink bits when importing on Windows,
       
  1722     # and allows importing with a dirty wdir.  It also aborts instead of leaving
       
  1723     # rejects.
       
  1724     opts[b'bypass'] = True
       
  1725 
       
  1726     # Mandatory default values, synced with commands.import
       
  1727     opts[b'strip'] = 1
       
  1728     opts[b'prefix'] = b''
       
  1729     # Evolve 9.3.0 assumes this key is present in cmdutil.tryimportone()
       
  1730     opts[b'obsolete'] = False
       
  1731 
       
  1732     def _write(patches):
       
  1733         parents = repo[None].parents()
       
  1734 
       
  1735         with repo.wlock(), repo.lock(), repo.transaction(b'phabimport'):
       
  1736             for drev, contents in patches:
       
  1737                 ui.status(_(b'applying patch from D%s\n') % drev)
       
  1738 
       
  1739                 with patch.extract(ui, pycompat.bytesio(contents)) as patchdata:
       
  1740                     msg, node, rej = cmdutil.tryimportone(
       
  1741                         ui,
       
  1742                         repo,
       
  1743                         patchdata,
       
  1744                         parents,
       
  1745                         opts,
       
  1746                         [],
       
  1747                         None,  # Never update wdir to another revision
       
  1748                     )
       
  1749 
       
  1750                     if not node:
       
  1751                         raise error.Abort(_(b'D%s: no diffs found') % drev)
       
  1752 
       
  1753                     ui.note(msg + b'\n')
       
  1754                     parents = [repo[node]]
       
  1755 
       
  1756     opts = pycompat.byteskwargs(opts)
       
  1757     if opts.get(b'stack'):
       
  1758         spec = b':(%s)' % spec
       
  1759     drevs = querydrev(repo.ui, spec)
       
  1760 
       
  1761     readpatch(repo.ui, drevs, _write)
       
  1762 
       
  1763 
       
  1764 @vcrcommand(
  1706     b'phabupdate',
  1765     b'phabupdate',
  1707     [
  1766     [
  1708         (b'', b'accept', False, _(b'accept revisions')),
  1767         (b'', b'accept', False, _(b'accept revisions')),
  1709         (b'', b'reject', False, _(b'reject revisions')),
  1768         (b'', b'reject', False, _(b'reject revisions')),
  1710         (b'', b'abandon', False, _(b'abandon revisions')),
  1769         (b'', b'abandon', False, _(b'abandon revisions')),