hgext/histedit.py
branchstable
changeset 44402 9b8e13a038db
parent 43995 801b8d314791
child 44429 24a3a9f7ea77
child 44440 d543ef183eb8
equal deleted inserted replaced
44401:92b7caf4cb9e 44402:9b8e13a038db
  1643                 ch = encoding.strtolocal(stdscr.getkey())
  1643                 ch = encoding.strtolocal(stdscr.getkey())
  1644         except curses.error:
  1644         except curses.error:
  1645             pass
  1645             pass
  1646 
  1646 
  1647 
  1647 
  1648 def _chistedit(ui, repo, *freeargs, **opts):
  1648 def _chistedit(ui, repo, freeargs, opts):
  1649     """interactively edit changeset history via a curses interface
  1649     """interactively edit changeset history via a curses interface
  1650 
  1650 
  1651     Provides a ncurses interface to histedit. Press ? in chistedit mode
  1651     Provides a ncurses interface to histedit. Press ? in chistedit mode
  1652     to see an extensive help. Requires python-curses to be installed."""
  1652     to see an extensive help. Requires python-curses to be installed."""
  1653 
  1653 
  1715             ui.status(_(b"performing changes\n"))
  1715             ui.status(_(b"performing changes\n"))
  1716             rules = makecommands(rc)
  1716             rules = makecommands(rc)
  1717             with repo.vfs(b'chistedit', b'w+') as fp:
  1717             with repo.vfs(b'chistedit', b'w+') as fp:
  1718                 for r in rules:
  1718                 for r in rules:
  1719                     fp.write(r)
  1719                     fp.write(r)
  1720                 opts['commands'] = fp.name
  1720                 opts[b'commands'] = fp.name
  1721             return _texthistedit(ui, repo, *freeargs, **opts)
  1721             return _texthistedit(ui, repo, freeargs, opts)
  1722     except KeyboardInterrupt:
  1722     except KeyboardInterrupt:
  1723         pass
  1723         pass
  1724     return -1
  1724     return -1
  1725 
  1725 
  1726 
  1726 
  1853 
  1853 
  1854     Returns 0 on success, 1 if user intervention is required (not only
  1854     Returns 0 on success, 1 if user intervention is required (not only
  1855     for intentional "edit" command, but also for resolving unexpected
  1855     for intentional "edit" command, but also for resolving unexpected
  1856     conflicts).
  1856     conflicts).
  1857     """
  1857     """
       
  1858     opts = pycompat.byteskwargs(opts)
       
  1859 
  1858     # kludge: _chistedit only works for starting an edit, not aborting
  1860     # kludge: _chistedit only works for starting an edit, not aborting
  1859     # or continuing, so fall back to regular _texthistedit for those
  1861     # or continuing, so fall back to regular _texthistedit for those
  1860     # operations.
  1862     # operations.
  1861     if (
  1863     if (
  1862         ui.interface(b'histedit') == b'curses'
  1864         ui.interface(b'histedit') == b'curses'
  1863         and _getgoal(pycompat.byteskwargs(opts)) == goalnew
  1865         and _getgoal(opts) == goalnew
  1864     ):
  1866     ):
  1865         return _chistedit(ui, repo, *freeargs, **opts)
  1867         return _chistedit(ui, repo, freeargs, opts)
  1866     return _texthistedit(ui, repo, *freeargs, **opts)
  1868     return _texthistedit(ui, repo, freeargs, opts)
  1867 
  1869 
  1868 
  1870 
  1869 def _texthistedit(ui, repo, *freeargs, **opts):
  1871 def _texthistedit(ui, repo, freeargs, opts):
  1870     state = histeditstate(repo)
  1872     state = histeditstate(repo)
  1871     with repo.wlock() as wlock, repo.lock() as lock:
  1873     with repo.wlock() as wlock, repo.lock() as lock:
  1872         state.wlock = wlock
  1874         state.wlock = wlock
  1873         state.lock = lock
  1875         state.lock = lock
  1874         _histedit(ui, repo, state, *freeargs, **opts)
  1876         _histedit(ui, repo, state, freeargs, opts)
  1875 
  1877 
  1876 
  1878 
  1877 goalcontinue = b'continue'
  1879 goalcontinue = b'continue'
  1878 goalabort = b'abort'
  1880 goalabort = b'abort'
  1879 goaleditplan = b'edit-plan'
  1881 goaleditplan = b'edit-plan'
  1950                 raise error.Abort(
  1952                 raise error.Abort(
  1951                     _(b'histedit requires exactly one ancestor revision')
  1953                     _(b'histedit requires exactly one ancestor revision')
  1952                 )
  1954                 )
  1953 
  1955 
  1954 
  1956 
  1955 def _histedit(ui, repo, state, *freeargs, **opts):
  1957 def _histedit(ui, repo, state, freeargs, opts):
  1956     opts = pycompat.byteskwargs(opts)
       
  1957     fm = ui.formatter(b'histedit', opts)
  1958     fm = ui.formatter(b'histedit', opts)
  1958     fm.startitem()
  1959     fm.startitem()
  1959     goal = _getgoal(opts)
  1960     goal = _getgoal(opts)
  1960     revs = opts.get(b'rev', [])
  1961     revs = opts.get(b'rev', [])
  1961     nobackup = not ui.configbool(b'rewrite', b'backup-bundle')
  1962     nobackup = not ui.configbool(b'rewrite', b'backup-bundle')