65 self.__project = rope.base.project.Project( |
65 self.__project = rope.base.project.Project( |
66 self.__projectpath, fscommands=self.__fsCommands) |
66 self.__projectpath, fscommands=self.__fsCommands) |
67 |
67 |
68 self.__progressHandle = None |
68 self.__progressHandle = None |
69 |
69 |
70 self.__changes = {} # dict storing the retrieved changes |
70 self.__changes = {} |
|
71 # dict storing the retrieved changes for various refactorings |
71 |
72 |
72 def handleCall(self, method, params): |
73 def handleCall(self, method, params): |
73 """ |
74 """ |
74 Public method to handle a method call from the server. |
75 Public method to handle a method call from the server. |
75 |
76 |
345 the server |
346 the server |
346 @type dict |
347 @type dict |
347 """ |
348 """ |
348 subcommand = params["Subcommand"] |
349 subcommand = params["Subcommand"] |
349 if subcommand == "Get": |
350 if subcommand == "Get": |
350 self.__changes = {} |
351 changes = {} |
351 if params["Filename"]: |
352 if params["Filename"]: |
352 # file history |
353 # file history |
353 resource = rope.base.libutils.path_to_resource( |
354 resource = rope.base.libutils.path_to_resource( |
354 self.__project, params["Filename"]) |
355 self.__project, params["Filename"]) |
355 undoList = [] |
356 undoList = [] |
366 redoList = self.__project.history.redo_list |
367 redoList = self.__project.history.redo_list |
367 |
368 |
368 result = {"Subcommand": "Histories"} |
369 result = {"Subcommand": "Histories"} |
369 result["Undo"] = [] |
370 result["Undo"] = [] |
370 for change in undoList: |
371 for change in undoList: |
371 self.__changes[id(change)] = change |
372 changes[id(change)] = change |
372 result["Undo"].append([str(change), id(change)]) |
373 result["Undo"].append([str(change), id(change)]) |
373 result["Redo"] = [] |
374 result["Redo"] = [] |
374 for change in redoList: |
375 for change in redoList: |
375 self.__changes[id(change)] = change |
376 changes[id(change)] = change |
376 result["Redo"].append([str(change), id(change)]) |
377 result["Redo"].append([str(change), id(change)]) |
|
378 |
|
379 self.__changes["History"] = changes |
377 |
380 |
378 self.sendJson("HistoryResult", result) |
381 self.sendJson("HistoryResult", result) |
379 |
382 |
380 elif subcommand == "GetChange": |
383 elif subcommand == "GetChange": |
381 result = { |
384 result = { |
382 "Subcommand": "ChangeDescription", |
385 "Subcommand": "ChangeDescription", |
383 "Description": self.__changes[params["Id"]].get_description() |
386 "Description": self.__changes["History"][params["Id"]]\ |
|
387 .get_description() |
384 } |
388 } |
385 |
389 |
386 self.sendJson("HistoryResult", result) |
390 self.sendJson("HistoryResult", result) |
387 |
391 |
388 elif subcommand in ["Undo", "Redo"]: |
392 elif subcommand in ["Undo", "Redo"]: |
389 change = self.__changes[params["Id"]] |
393 change = self.__changes["History"][params["Id"]] |
390 from ProgressHandle import ProgressHandle |
394 from ProgressHandle import ProgressHandle |
391 self.__progressHandle = ProgressHandle(self, change.description, |
395 self.__progressHandle = ProgressHandle(self, change.description, |
392 False) |
396 False) |
393 if subcommand == "Undo": |
397 if subcommand == "Undo": |
394 self.__project.history.undo( |
398 self.__project.history.undo( |
408 |
412 |
409 self.sendJson("HistoryResult", result) |
413 self.sendJson("HistoryResult", result) |
410 |
414 |
411 elif subcommand == "Clear": |
415 elif subcommand == "Clear": |
412 self.__project.history.clear() |
416 self.__project.history.clear() |
|
417 |
|
418 elif subcommand == "ClearChanges": |
|
419 try: |
|
420 del self.__changes["History"] |
|
421 except KeyError: |
|
422 pass |
413 |
423 |
414 if __name__ == '__main__': |
424 if __name__ == '__main__': |
415 if len(sys.argv) != 4: |
425 if len(sys.argv) != 4: |
416 print('Host, port and project path parameters are missing. Abort.') |
426 print('Host, port and project path parameters are missing. Abort.') |
417 sys.exit(1) |
427 sys.exit(1) |