Plugins/VcsPlugins/vcsMercurial/RebaseExtension/rebase.py

changeset 1093
47bc4ef30315
child 1249
77f836a883c1
equal deleted inserted replaced
1092:1b149c2d9ae1 1093:47bc4ef30315
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the rebase extension interface.
8 """
9
10 import os
11
12 from PyQt4.QtGui import QDialog
13
14 from ..HgExtension import HgExtension
15 from ..HgDialog import HgDialog
16
17 from .HgRebaseDialog import HgRebaseDialog
18
19
20 class Rebase(HgExtension):
21 """
22 Class implementing the rebase extension interface.
23 """
24 def __init__(self, vcs):
25 """
26 Constructor
27
28 @param vcs reference to the Mercurial vcs object
29 """
30 super().__init__(vcs)
31
32 def hgRebase(self, path):
33 """
34 Public method to rebase changesets to a different branch.
35
36 @param path directory name of the project (string)
37 @return flag indicating that the project should be reread (boolean)
38 """
39 # find the root of the repo
40 repodir = self.vcs.splitPath(path)[0]
41 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
42 repodir = os.path.dirname(repodir)
43 if repodir == os.sep:
44 return False
45
46 res = False
47 if self.vcs.isExtensionActive("bookmarks"):
48 bookmarksList = \
49 self.vcs.getExtensionObject("bookmarks").hgGetBookmarksList(repodir)
50 else:
51 bookmarksList = None
52 dlg = HgRebaseDialog(self.vcs.hgGetTagsList(repodir),
53 self.vcs.hgGetBranchesList(repodir),
54 bookmarksList)
55 if dlg.exec_() == QDialog.Accepted:
56 indicator, sourceRev, destRev, collapse, keep, keepBranches, detach = \
57 dlg.getData()
58
59 args = []
60 args.append("rebase")
61 if indicator == "S":
62 args.append("--source")
63 args.append(sourceRev)
64 elif indicator == "B":
65 args.append("--base")
66 args.append(sourceRev)
67 if destRev:
68 args.append("--dest")
69 args.append(destRev)
70 if collapse:
71 args.append("--collapse")
72 if keep:
73 args.append("--keep")
74 if keepBranches:
75 args.append("--keepbranches")
76 if detach:
77 args.append("--detach")
78 args.append("--verbose")
79
80 dia = HgDialog(self.trUtf8('Rebase Changesets'))
81 res = dia.startProcess(args, repodir)
82 if res:
83 dia.exec_()
84 res = dia.hasAddOrDelete()
85 self.vcs.checkVCSStatus()
86 return res
87
88 def hgRebaseContinue(self, path):
89 """
90 Public method to continue rebasing changesets from another branch.
91
92 @param path directory name of the project (string)
93 @return flag indicating that the project should be reread (boolean)
94 """
95 # find the root of the repo
96 repodir = self.vcs.splitPath(path)[0]
97 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
98 repodir = os.path.dirname(repodir)
99 if repodir == os.sep:
100 return False
101
102 args = []
103 args.append("rebase")
104 args.append("--continue")
105 args.append("--verbose")
106
107 dia = HgDialog(self.trUtf8('Rebase Changesets (Continue)'))
108 res = dia.startProcess(args, repodir)
109 if res:
110 dia.exec_()
111 res = dia.hasAddOrDelete()
112 self.vcs.checkVCSStatus()
113 return res
114
115 def hgRebaseAbort(self, path):
116 """
117 Public method to abort rebasing changesets from another branch.
118
119 @param path directory name of the project (string)
120 @return flag indicating that the project should be reread (boolean)
121 """
122 # find the root of the repo
123 repodir = self.vcs.splitPath(path)[0]
124 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
125 repodir = os.path.dirname(repodir)
126 if repodir == os.sep:
127 return False
128
129 args = []
130 args.append("rebase")
131 args.append("--abort")
132 args.append("--verbose")
133
134 dia = HgDialog(self.trUtf8('Rebase Changesets (Abort)'))
135 res = dia.startProcess(args, repodir)
136 if res:
137 dia.exec_()
138 res = dia.hasAddOrDelete()
139 self.vcs.checkVCSStatus()
140 return res

eric ide

mercurial