Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/bookmarks.py

changeset 1251
d40491ba96ce
parent 1087
fb8cd56819a9
child 1253
4a994190cf8b
equal deleted inserted replaced
1250:dafdd7d97a9f 1251:d40491ba96ce
65 Public method to get the list of bookmarks. 65 Public method to get the list of bookmarks.
66 66
67 @param repodir directory name of the repository (string) 67 @param repodir directory name of the repository (string)
68 @return list of bookmarks (list of string) 68 @return list of bookmarks (list of string)
69 """ 69 """
70 ioEncoding = Preferences.getSystem("IOEncoding")
71 process = QProcess()
72 args = [] 70 args = []
73 args.append('bookmarks') 71 args.append('bookmarks')
74 process.setWorkingDirectory(repodir) 72
75 process.start('hg', args) 73 client = self.vcs.getClient()
76 procStarted = process.waitForStarted() 74 if client:
77 if procStarted: 75 output = client.runcommand(args)[0]
78 finished = process.waitForFinished(30000) 76 else:
79 if finished and process.exitCode() == 0: 77 ioEncoding = Preferences.getSystem("IOEncoding")
80 output = \ 78 process = QProcess()
81 str(process.readAllStandardOutput(), ioEncoding, 'replace') 79 process.setWorkingDirectory(repodir)
82 self.bookmarksList = [] 80 process.start('hg', args)
83 for line in output.splitlines(): 81 procStarted = process.waitForStarted()
84 l = line.strip().split() 82 if procStarted:
85 if l[-1][0] in "1234567890": 83 finished = process.waitForFinished(30000)
86 # last element is a rev:changeset 84 if finished and process.exitCode() == 0:
87 del l[-1] 85 output = \
88 if l[0] == "*": 86 str(process.readAllStandardOutput(), ioEncoding, 'replace')
89 del l[0] 87
90 name = " ".join(l) 88 self.bookmarksList = []
91 self.bookmarksList.append(name) 89 for line in output.splitlines():
90 l = line.strip().split()
91 if l[-1][0] in "1234567890":
92 # last element is a rev:changeset
93 del l[-1]
94 if l[0] == "*":
95 del l[0]
96 name = " ".join(l)
97 self.bookmarksList.append(name)
92 98
93 return self.bookmarksList[:] 99 return self.bookmarksList[:]
94 100
95 def hgBookmarkDefine(self, name): 101 def hgBookmarkDefine(self, name):
96 """ 102 """
117 if rev: 123 if rev:
118 args.append("--rev") 124 args.append("--rev")
119 args.append(rev) 125 args.append(rev)
120 args.append(bookmark) 126 args.append(bookmark)
121 127
122 dia = HgDialog(self.trUtf8('Mercurial Bookmark')) 128 dia = HgDialog(self.trUtf8('Mercurial Bookmark'), self.vcs)
123 res = dia.startProcess(args, repodir) 129 res = dia.startProcess(args, repodir)
124 if res: 130 if res:
125 dia.exec_() 131 dia.exec_()
126 132
127 def hgBookmarkDelete(self, name): 133 def hgBookmarkDelete(self, name):
147 args = [] 153 args = []
148 args.append("bookmarks") 154 args.append("bookmarks")
149 args.append("--delete") 155 args.append("--delete")
150 args.append(bookmark) 156 args.append(bookmark)
151 157
152 dia = HgDialog(self.trUtf8('Delete Mercurial Bookmark')) 158 dia = HgDialog(self.trUtf8('Delete Mercurial Bookmark'), self.vcs)
153 res = dia.startProcess(args, repodir) 159 res = dia.startProcess(args, repodir)
154 if res: 160 if res:
155 dia.exec_() 161 dia.exec_()
156 162
157 def hgBookmarkRename(self, name): 163 def hgBookmarkRename(self, name):
175 args.append("bookmarks") 181 args.append("bookmarks")
176 args.append("--rename") 182 args.append("--rename")
177 args.append(oldName) 183 args.append(oldName)
178 args.append(newName) 184 args.append(newName)
179 185
180 dia = HgDialog(self.trUtf8('Rename Mercurial Bookmark')) 186 dia = HgDialog(self.trUtf8('Rename Mercurial Bookmark'), self.vcs)
181 res = dia.startProcess(args, repodir) 187 res = dia.startProcess(args, repodir)
182 if res: 188 if res:
183 dia.exec_() 189 dia.exec_()
184 190
185 def hgBookmarkMove(self, name): 191 def hgBookmarkMove(self, name):
208 if rev: 214 if rev:
209 args.append("--rev") 215 args.append("--rev")
210 args.append(rev) 216 args.append(rev)
211 args.append(bookmark) 217 args.append(bookmark)
212 218
213 dia = HgDialog(self.trUtf8('Move Mercurial Bookmark')) 219 dia = HgDialog(self.trUtf8('Move Mercurial Bookmark'), self.vcs)
214 res = dia.startProcess(args, repodir) 220 res = dia.startProcess(args, repodir)
215 if res: 221 if res:
216 dia.exec_() 222 dia.exec_()
217 223
218 def hgBookmarkIncoming(self, name): 224 def hgBookmarkIncoming(self, name):
245 @param incoming flag indicating to get incoming bookmarks (boolean) 251 @param incoming flag indicating to get incoming bookmarks (boolean)
246 @return list of bookmarks (list of string) 252 @return list of bookmarks (list of string)
247 """ 253 """
248 bookmarksList = [] 254 bookmarksList = []
249 255
250 ioEncoding = Preferences.getSystem("IOEncoding")
251 process = QProcess()
252 args = [] 256 args = []
253 if incoming: 257 if incoming:
254 args.append('incoming') 258 args.append('incoming')
255 else: 259 else:
256 args.append('outgoing') 260 args.append('outgoing')
257 args.append('--bookmarks') 261 args.append('--bookmarks')
258 process.setWorkingDirectory(repodir) 262
259 process.start('hg', args) 263 client = self.vcs.getClient()
260 procStarted = process.waitForStarted() 264 if client:
261 if procStarted: 265 output = client.runcommand(args)[0]
262 finished = process.waitForFinished(30000) 266 else:
263 if finished and process.exitCode() == 0: 267 ioEncoding = Preferences.getSystem("IOEncoding")
264 output = \ 268 process = QProcess()
265 str(process.readAllStandardOutput(), ioEncoding, 'replace') 269 process.setWorkingDirectory(repodir)
266 for line in output.splitlines(): 270 process.start('hg', args)
267 if line.startswith(" "): 271 procStarted = process.waitForStarted()
268 l = line.strip().split() 272 if procStarted:
269 del l[-1] 273 finished = process.waitForFinished(30000)
270 name = " ".join(l) 274 if finished and process.exitCode() == 0:
271 bookmarksList.append(name) 275 output = \
276 str(process.readAllStandardOutput(), ioEncoding, 'replace')
277
278 for line in output.splitlines():
279 if line.startswith(" "):
280 l = line.strip().split()
281 del l[-1]
282 name = " ".join(l)
283 bookmarksList.append(name)
272 284
273 return bookmarksList 285 return bookmarksList
274 286
275 def hgBookmarkPull(self, name): 287 def hgBookmarkPull(self, name):
276 """ 288 """
296 if ok and bookmark: 308 if ok and bookmark:
297 args = [] 309 args = []
298 args.append('pull') 310 args.append('pull')
299 args.append('--bookmark') 311 args.append('--bookmark')
300 args.append(bookmark) 312 args.append(bookmark)
301 313
302 dia = HgDialog(self.trUtf8('Pulling bookmark from a remote Mercurial repository')) 314 dia = HgDialog(self.trUtf8('Pulling bookmark from a remote Mercurial repository'),
303 res = dia.startProcess(args, repodir) 315 self.vcs)
304 if res: 316 res = dia.startProcess(args, repodir)
305 dia.exec_() 317 if res:
318 dia.exec_()
306 319
307 def hgBookmarkPush(self, name): 320 def hgBookmarkPush(self, name):
308 """ 321 """
309 Public method to push a bookmark to a remote repository. 322 Public method to push a bookmark to a remote repository.
310 323
328 if ok and bookmark: 341 if ok and bookmark:
329 args = [] 342 args = []
330 args.append('push') 343 args.append('push')
331 args.append('--bookmark') 344 args.append('--bookmark')
332 args.append(bookmark) 345 args.append(bookmark)
333 346
334 dia = HgDialog(self.trUtf8('Pushing bookmark to a remote Mercurial repository')) 347 dia = HgDialog(self.trUtf8('Pushing bookmark to a remote Mercurial repository'),
335 res = dia.startProcess(args, repodir) 348 self.vcs)
336 if res: 349 res = dia.startProcess(args, repodir)
337 dia.exec_() 350 if res:
351 dia.exec_()

eric ide

mercurial