1. TortoiseHg
  2. TortoiseHg
  3. thg

Commits

Angel Ezquerra  committed 5022d44

phases: add "change phase to" submenu to revision context menu

This menu lets the user change the phase of a given revision.
Currently it is only supported changing the phase of a single revision at a
time.

  • Participants
  • Parent commits 5ac642f
  • Branches stable

Comments (0)

Files changed (1)

File tortoisehg/hgqt/repowidget.py

View file
  • Ignore whitespace
 import binascii
 import os
 
-from mercurial import revset, error, patch
+from mercurial import revset, error, patch, commands
 
 from tortoisehg.util import hglib, shlib, paths
 
               self.copyHash)
         entry(menu)
 
+        # hg >= 2.1
+        if hasattr(commands, 'phase'):
+            submenu = menu.addMenu(_('Change Phase to'))
+            entry(submenu, None, isrev, _('Secret'), None,
+                  lambda: self.changePhase('secret'))
+            entry(submenu, None, isrev, _('Draft'), None,
+                  lambda: self.changePhase('draft'))
+            entry(submenu, None, isrev, _('Public'), None,
+                  lambda: self.changePhase('public'))
+            entry(menu)
+
         entry(menu, 'transplant', fixed, _('Transplant to local'), 'hg-transplant',
               self.transplantRevisions)
 
         clip = QApplication.clipboard()
         clip.setText(binascii.hexlify(self.repo[self.rev].node()))
 
+    def changePhase(self, phase):
+        cmdlines = []
+        cmdlines.append(['phase', '--rev', '%s' % self.rev,
+                       '--repository', self.repo.root])
+        self.runCommand(*cmdlines)
+
     def rebaseRevision(self):
         """Rebase selected revision on top of working directory parent"""
         opts = {'source' : self.rev, 'dest': self.repo['.'].rev()}