5 |
5 |
6 """ |
6 """ |
7 Module implementing the shelve extension interface. |
7 Module implementing the shelve extension interface. |
8 """ |
8 """ |
9 |
9 |
|
10 import os |
|
11 |
|
12 from PyQt4.QtCore import QDateTime |
|
13 from PyQt4.QtGui import QDialog |
|
14 |
10 from ..HgExtension import HgExtension |
15 from ..HgExtension import HgExtension |
11 ##from ..HgDialog import HgDialog |
16 from ..HgDialog import HgDialog |
12 |
17 |
13 |
18 |
14 class Shelve(HgExtension): |
19 class Shelve(HgExtension): |
15 """ |
20 """ |
16 Class implementing the shelve extension interface. |
21 Class implementing the shelve extension interface. |
25 |
30 |
26 def shutdown(self): |
31 def shutdown(self): |
27 """ |
32 """ |
28 Public method used to shutdown the shelve interface. |
33 Public method used to shutdown the shelve interface. |
29 """ |
34 """ |
|
35 |
|
36 def hgShelve(self, name): |
|
37 """ |
|
38 Public method to shelve current changes of files or directories. |
|
39 |
|
40 @param name directory or file name (string) or list of directory |
|
41 or file names (list of string) |
|
42 @return flag indicating that the project should be reread (boolean) |
|
43 """ |
|
44 if isinstance(name, list): |
|
45 dname = self.vcs.splitPathList(name)[0] |
|
46 else: |
|
47 dname = self.vcs.splitPath(name)[0] |
|
48 |
|
49 # find the root of the repo |
|
50 repodir = dname |
|
51 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): |
|
52 repodir = os.path.dirname(repodir) |
|
53 if os.path.splitdrive(repodir)[1] == os.sep: |
|
54 return False |
|
55 |
|
56 res = False |
|
57 from .HgShelveDataDialog import HgShelveDataDialog |
|
58 dlg = HgShelveDataDialog() |
|
59 if dlg.exec_() == QDialog.Accepted: |
|
60 shelveName, dateTime, message, addRemove = dlg.getData() |
|
61 |
|
62 args = [] |
|
63 args.append("shelve") |
|
64 if shelveName: |
|
65 args.append("--name") |
|
66 args.append(shelveName) |
|
67 if message: |
|
68 args.append("--message") |
|
69 args.append(message) |
|
70 if addRemove: |
|
71 args.append("--addRemove") |
|
72 if dateTime != QDateTime.currentDateTime(): |
|
73 args.append("--date") |
|
74 args.append(dateTime.toString("yyyy-MM-dd hh:mm:ss")) |
|
75 args.append("-v") |
|
76 |
|
77 if isinstance(name, list): |
|
78 self.vcs.addArguments(args, name) |
|
79 else: |
|
80 args.append(name) |
|
81 |
|
82 dia = HgDialog(self.tr('Shelve current changes'), self.vcs) |
|
83 res = dia.startProcess(args, repodir) |
|
84 if res: |
|
85 dia.exec_() |
|
86 res = dia.hasAddOrDelete() |
|
87 self.vcs.checkVCSStatus() |
|
88 return res |