eric7/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/histedit.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the histedit extension interface.
8 """
9
10 import os
11 import sys
12
13 from PyQt5.QtWidgets import QDialog
14
15 from ..HgExtension import HgExtension
16 from ..HgDialog import HgDialog
17
18
19 class Histedit(HgExtension):
20 """
21 Class implementing the histedit extension interface.
22 """
23 def __init__(self, vcs):
24 """
25 Constructor
26
27 @param vcs reference to the Mercurial vcs object
28 @type Hg
29 """
30 super().__init__(vcs)
31
32 def hgHisteditStart(self, rev=""):
33 """
34 Public method to start a histedit session.
35
36 @param rev revision to start histedit at
37 @type str
38 @return flag indicating that the project should be reread
39 @rtype bool
40 """
41 from .HgHisteditConfigDialog import HgHisteditConfigDialog
42 res = False
43 dlg = HgHisteditConfigDialog(self.vcs.hgGetTagsList(),
44 self.vcs.hgGetBranchesList(),
45 self.vcs.hgGetBookmarksList(),
46 rev)
47 if dlg.exec() == QDialog.DialogCode.Accepted:
48 rev, force, keep = dlg.getData()
49
50 args = self.vcs.initCommand("histedit")
51 args.append("-v")
52 if keep:
53 args.append("--keep")
54 if rev:
55 if rev == "--outgoing":
56 if force:
57 args.append("--force")
58 else:
59 args.append("--rev")
60 args.append(rev)
61
62 editor = os.path.join(
63 os.path.dirname(__file__), "HgHisteditEditor.py")
64 env = {"HGEDITOR": "{0} {1}".format(sys.executable, editor)}
65
66 dia = HgDialog(
67 self.tr("Starting histedit session"),
68 self.vcs,
69 useClient=False)
70 res = dia.startProcess(args, environment=env)
71 if res:
72 dia.exec()
73 res = dia.hasAddOrDelete()
74 self.vcs.checkVCSStatus()
75 return res
76
77 def hgHisteditContinue(self):
78 """
79 Public method to continue an interrupted histedit session.
80
81 @return flag indicating that the project should be reread
82 @rtype bool
83 """
84 args = self.vcs.initCommand("histedit")
85 args.append("--continue")
86 args.append("-v")
87
88 editor = os.path.join(
89 os.path.dirname(__file__), "HgHisteditEditor.py")
90 env = {"HGEDITOR": "{0} {1}".format(sys.executable, editor)}
91
92 dia = HgDialog(
93 self.tr("Continue histedit session"),
94 self.vcs,
95 useClient=False)
96 res = dia.startProcess(args, environment=env)
97 if res:
98 dia.exec()
99 res = dia.hasAddOrDelete()
100 self.vcs.checkVCSStatus()
101 return res
102
103 def hgHisteditAbort(self, name):
104 """
105 Public method to abort an interrupted histedit session.
106
107 @param name file/directory name
108 @type str
109 @return flag indicating that the project should be reread
110 @rtype bool
111 """
112 args = self.vcs.initCommand("histedit")
113 args.append("--abort")
114 args.append("-v")
115
116 editor = os.path.join(
117 os.path.dirname(__file__), "HgHisteditEditor.py")
118 env = {"HGEDITOR": "{0} {1}".format(sys.executable, editor)}
119
120 dia = HgDialog(
121 self.tr("Abort histedit session"),
122 self.vcs,
123 useClient=False)
124 res = dia.startProcess(args, environment=env)
125 if res:
126 dia.exec()
127 res = dia.hasAddOrDelete()
128 self.vcs.checkVCSStatus()
129 return res
130
131 def hgHisteditEditPlan(self):
132 """
133 Public method to edit the remaining actions list of an interrupted
134 histedit session.
135
136 @return flag indicating that the project should be reread
137 @rtype bool
138 """
139 args = self.vcs.initCommand("histedit")
140 args.append("--edit-plan")
141 args.append("-v")
142
143 editor = os.path.join(
144 os.path.dirname(__file__), "HgHisteditEditor.py")
145 env = {"HGEDITOR": "{0} {1}".format(sys.executable, editor)}
146
147 dia = HgDialog(
148 self.tr("Edit Plan"),
149 self.vcs,
150 useClient=False)
151 res = dia.startProcess(args, environment=env)
152 if res:
153 dia.exec()
154 res = dia.hasAddOrDelete()
155 self.vcs.checkVCSStatus()
156 return res

eric ide

mercurial