src/eric7/Plugins/VcsPlugins/vcsMercurial/UncommitExtension/uncommit.py

branch
eric7
changeset 11082
58838580274e
equal deleted inserted replaced
11081:7391035e7bc9 11082:58838580274e
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2025 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the uncommit extension interface.
8 """
9
10 from PyQt6.QtWidgets import QDialog
11
12 from ..HgDialog import HgDialog
13 from ..HgExtension import HgExtension
14
15
16 class Uncommit(HgExtension):
17 """
18 Class implementing the uncommit extension interface.
19 """
20
21 def __init__(self, vcs, ui=None):
22 """
23 Constructor
24
25 @param vcs reference to the Mercurial vcs object
26 @type Hg
27 @param ui reference to a UI widget (defaults to None)
28 @type QWidget
29 """
30 super().__init__(vcs, ui=ui)
31
32 def hgUncommit(self, names=None):
33 """
34 Public method to undo the effect of a local commit.
35
36 @param names list of file or directory paths (defaults to None)
37 @type list of str
38 @return flag indicating that the project should be reread
39 @rtype bool
40 """
41 from .HgUncommitDialog import HgUncommitDialog
42
43 res = False
44 dlg = HgUncommitDialog(vcs=self.vcs, parent=self.ui)
45 if dlg.exec() == QDialog.DialogCode.Accepted:
46 message, keep, dirty, author, date = dlg.getUncommitData()
47
48 args = self.vcs.initCommand("uncommit")
49 if message:
50 args.extend(["--message", message])
51 if keep:
52 args.append("--keep")
53 if dirty:
54 args.append("--allow-dirty-working-copy")
55 if author:
56 args.extend(["--user", author])
57 if date:
58 args.extend(["--date", date])
59 args.append("--verbose")
60
61 if names is not None:
62 self.vcs.addArguments(args, names)
63
64 dia = HgDialog(self.tr("Undo Local Commit"), hg=self.vcs, parent=self.ui)
65 res = dia.startProcess(args)
66 if res:
67 dia.exec()
68 res = dia.hasAddOrDelete()
69 self.vcs.checkVCSStatus()
70 return res

eric ide

mercurial