Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

changeset 203
0bd3912f3c5f
parent 201
a434e007ab9a
child 204
61552f56788a
equal deleted inserted replaced
202:6854bb0beda5 203:0bd3912f3c5f
383 except ValueError: 383 except ValueError:
384 self.__lastRev = 0 384 self.__lastRev = 0
385 385
386 return itm 386 return itm
387 387
388 def __generateFileItem(self, action, path): 388 def __generateFileItem(self, action, path, copyfrom):
389 """ 389 """
390 Private method to generate a changed files tree entry. 390 Private method to generate a changed files tree entry.
391 391
392 @param action indicator for the change action ("A", "D" or "M") 392 @param action indicator for the change action ("A", "D" or "M")
393 @param path path of the file in the repository (string) 393 @param path path of the file in the repository (string)
394 @param copyfrom path the file was copied from (string)
394 @return reference to the generated item (QTreeWidgetItem) 395 @return reference to the generated item (QTreeWidgetItem)
395 """ 396 """
396 itm = QTreeWidgetItem(self.filesTree, [ 397 itm = QTreeWidgetItem(self.filesTree, [
397 self.flags[action], 398 self.flags[action],
398 path, 399 path,
400 copyfrom,
399 ]) 401 ])
400 402
401 return itm 403 return itm
402 404
403 def __getLogEntries(self, startRev = None): 405 def __getLogEntries(self, startRev = None):
437 args.append('{0}:0'.format(startRev)) 439 args.append('{0}:0'.format(startRev))
438 if not self.projectMode and \ 440 if not self.projectMode and \
439 not self.fname == "." and \ 441 not self.fname == "." and \
440 not self.stopCheckBox.isChecked(): 442 not self.stopCheckBox.isChecked():
441 args.append('--follow') 443 args.append('--follow')
442 args.append('--template') 444 args.append('--copies')
443 args.append("change|{rev}:{node|short}\n" 445 args.append('--style')
444 "user|{author|email}\n" 446 args.append(os.path.join(os.path.dirname(__file__), "styles", "logBrowser.style"))
445 "parents|{parents}\n"
446 "date|{date|isodate}\n"
447 "description|{desc}\n"
448 "file_adds|{file_adds}\n"
449 "files_mods|{file_mods}\n"
450 "file_dels|{file_dels}\n"
451 "branches|{branches}\n"
452 "tags|{tags}\n"
453 "@@@\n")
454 if not self.projectMode: 447 if not self.projectMode:
455 args.append(self.filename) 448 args.append(self.filename)
456 449
457 self.process.setWorkingDirectory(self.repodir) 450 self.process.setWorkingDirectory(self.repodir)
458 451
530 """ 523 """
531 noEntries = 0 524 noEntries = 0
532 log = {"message" : []} 525 log = {"message" : []}
533 changedPaths = [] 526 changedPaths = []
534 initialText = True 527 initialText = True
528 fileCopies = {}
535 for s in self.buf: 529 for s in self.buf:
536 if s != "@@@\n": 530 if s != "@@@\n":
537 try: 531 try:
538 key, value = s.split("|", 1) 532 key, value = s.split("|", 1)
539 except ValueError: 533 except ValueError:
551 log["date"] = " ".join(value.strip().split()[:2]) 545 log["date"] = " ".join(value.strip().split()[:2])
552 elif key == "description": 546 elif key == "description":
553 log["message"].append(value.strip()) 547 log["message"].append(value.strip())
554 elif key == "file_adds": 548 elif key == "file_adds":
555 if value.strip(): 549 if value.strip():
556 for f in value.strip().split(): 550 for f in value.strip().split(", "):
557 changedPaths.append({\ 551 if f in fileCopies:
558 "action" : "A", 552 changedPaths.append({
559 "path" : f, 553 "action" : "A",
560 }) 554 "path" : f,
555 "copyfrom" : fileCopies[f],
556 })
557 else:
558 changedPaths.append({
559 "action" : "A",
560 "path" : f,
561 "copyfrom" : "",
562 })
561 elif key == "files_mods": 563 elif key == "files_mods":
562 if value.strip(): 564 if value.strip():
563 for f in value.strip().split(): 565 for f in value.strip().split(", "):
564 changedPaths.append({\ 566 changedPaths.append({
565 "action" : "M", 567 "action" : "M",
566 "path" : f, 568 "path" : f,
569 "copyfrom" : "",
567 }) 570 })
568 elif key == "file_dels": 571 elif key == "file_dels":
569 if value.strip(): 572 if value.strip():
570 for f in value.strip().split(): 573 for f in value.strip().split(", "):
571 changedPaths.append({\ 574 changedPaths.append({
572 "action" : "D", 575 "action" : "D",
573 "path" : f, 576 "path" : f,
577 "copyfrom" : "",
574 }) 578 })
579 elif key == "file_copies":
580 if value.strip():
581 for entry in value.strip().split(", "):
582 newName, oldName = entry[:-1].split(" (")
583 fileCopies[newName] = oldName
575 elif key == "branches": 584 elif key == "branches":
576 if value.strip(): 585 if value.strip():
577 log["branches"] = value.strip().split() 586 log["branches"] = value.strip().split(", ")
578 else: 587 else:
579 log["branches"] = ["default"] 588 log["branches"] = ["default"]
580 elif key == "tags": 589 elif key == "tags":
581 log["tags"] = value.strip().split() 590 log["tags"] = value.strip().split(", ")
582 else: 591 else:
583 if initialText: 592 if initialText:
584 continue 593 continue
585 if value.strip(): 594 if value.strip():
586 log["message"].append(value.strip()) 595 log["message"].append(value.strip())
599 if self.__minDate > dt: 608 if self.__minDate > dt:
600 self.__minDate = dt 609 self.__minDate = dt
601 noEntries += 1 610 noEntries += 1
602 log = {"message" : []} 611 log = {"message" : []}
603 changedPaths = [] 612 changedPaths = []
613 fileCopies = {}
604 614
605 self.logTree.doItemsLayout() 615 self.logTree.doItemsLayout()
606 self.__resizeColumnsLog() 616 self.__resizeColumnsLog()
607 617
608 if self.__started: 618 if self.__started:
692 702
693 self.filesTree.clear() 703 self.filesTree.clear()
694 changes = current.data(0, self.__changesRole) 704 changes = current.data(0, self.__changesRole)
695 if len(changes) > 0: 705 if len(changes) > 0:
696 for change in changes: 706 for change in changes:
697 self.__generateFileItem(change["action"], change["path"]) 707 self.__generateFileItem(
708 change["action"], change["path"], change["copyfrom"])
698 self.__resizeColumnsFiles() 709 self.__resizeColumnsFiles()
699 self.__resortFiles() 710 self.__resortFiles()
700 711
701 self.diffPreviousButton.setEnabled(current is not None) 712 self.diffPreviousButton.setEnabled(current is not None)
702 713

eric ide

mercurial