eric6/Plugins/VcsPlugins/vcsMercurial/hg.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 7979
54b73174ab61
child 8142
43248bafe9b2
equal deleted inserted replaced
7991:866adc8c315b 8043:0acf98cd089a
328 args.append('--message') 328 args.append('--message')
329 args.append(msg) 329 args.append(msg)
330 dia = HgDialog( 330 dia = HgDialog(
331 self.tr('Initial commit to Mercurial repository'), 331 self.tr('Initial commit to Mercurial repository'),
332 self) 332 self)
333 res = dia.startProcess(args, projectDir) 333 res = dia.startProcess(args)
334 if res: 334 if res:
335 dia.exec() 335 dia.exec()
336 status = dia.normalExit() 336 status = dia.normalExit()
337 337
338 return status, False 338 return status, False
397 397
398 @param name file/directory name to be committed (string or list of 398 @param name file/directory name to be committed (string or list of
399 strings) 399 strings)
400 @param message message for this operation (string) 400 @param message message for this operation (string)
401 @param noDialog flag indicating quiet operations 401 @param noDialog flag indicating quiet operations
402 @keyparam closeBranch flag indicating a close branch commit (boolean) 402 @param closeBranch flag indicating a close branch commit (boolean)
403 @keyparam mq flag indicating a queue commit (boolean) 403 @param mq flag indicating a queue commit (boolean)
404 @keyparam merge flag indicating a merge commit (boolean) 404 @param merge flag indicating a merge commit (boolean)
405 """ 405 """
406 msg = message 406 msg = message
407 407
408 if mq or merge: 408 if mq or merge:
409 # ensure dialog is shown for a queue commit 409 # ensure dialog is shown for a queue commit
477 """ changes. Shall the commit be continued?"""), 477 """ changes. Shall the commit be continued?"""),
478 icon=E5MessageBox.Warning) 478 icon=E5MessageBox.Warning)
479 if not res: 479 if not res:
480 return 480 return
481 481
482 if isinstance(name, list):
483 dname, fnames = self.splitPathList(name)
484 else:
485 dname, fname = self.splitPath(name)
486
487 # find the root of the repo
488 repodir = dname
489 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
490 repodir = os.path.dirname(repodir)
491 if os.path.splitdrive(repodir)[1] == os.sep:
492 return
493
494 if self.__commitDialog is not None: 482 if self.__commitDialog is not None:
495 (msg, amend, commitSubrepositories, author, 483 (msg, amend, commitSubrepositories, author,
496 dateTime) = self.__commitDialog.getCommitData() 484 dateTime) = self.__commitDialog.getCommitData()
497 self.__commitDialog.deleteLater() 485 self.__commitDialog.deleteLater()
498 self.__commitDialog = None 486 self.__commitDialog = None
499 if amend and not msg: 487 if amend and not msg:
500 msg = self.__getMostRecentCommitMessage(repodir) 488 msg = self.__getMostRecentCommitMessage()
501 else: 489 else:
502 amend = False 490 amend = False
503 commitSubrepositories = False 491 commitSubrepositories = False
504 author = "" 492 author = ""
505 dateTime = "" 493 dateTime = ""
535 args.append("--message") 523 args.append("--message")
536 args.append(msg) 524 args.append(msg)
537 if isinstance(name, list): 525 if isinstance(name, list):
538 self.addArguments(args, name) 526 self.addArguments(args, name)
539 else: 527 else:
540 if dname != repodir or fname != ".": 528 args.append(name)
541 args.append(name)
542 529
543 dia = HgDialog( 530 dia = HgDialog(
544 self.tr('Committing changes to Mercurial repository'), 531 self.tr('Committing changes to Mercurial repository'),
545 self) 532 self)
546 res = dia.startProcess(args, dname) 533 res = dia.startProcess(args)
547 if res: 534 if res:
548 dia.exec() 535 dia.exec()
549 self.committed.emit() 536 self.committed.emit()
550 if self.__forgotNames: 537 if self.__forgotNames:
551 model = e5App().getObject("Project").getModel() 538 model = e5App().getObject("Project").getModel()
552 for name in self.__forgotNames: 539 for name in self.__forgotNames:
553 model.updateVCSStatus(name) 540 model.updateVCSStatus(name)
554 self.__forgotNames = [] 541 self.__forgotNames = []
555 self.checkVCSStatus() 542 self.checkVCSStatus()
556 543
557 def __getMostRecentCommitMessage(self, repodir): 544 def __getMostRecentCommitMessage(self):
558 """ 545 """
559 Private method to get the most recent commit message. 546 Private method to get the most recent commit message.
560 547
561 Note: This message is extracted from the parent commit of the 548 Note: This message is extracted from the parent commit of the
562 working directory. 549 working directory.
563 550
564 @param repodir path containing the repository
565 @type str
566 @return most recent commit message 551 @return most recent commit message
567 @rtype str 552 @rtype str
568 """ 553 """
569 args = self.initCommand("log") 554 args = self.initCommand("log")
570 args.append("--rev") 555 args.append("--rev")
574 559
575 output, error = self.__client.runcommand(args) 560 output, error = self.__client.runcommand(args)
576 561
577 return output 562 return output
578 563
579 def vcsUpdate(self, name, noDialog=False, revision=None): 564 def vcsUpdate(self, name=None, noDialog=False, revision=None):
580 """ 565 """
581 Public method used to update a file/directory with the Mercurial 566 Public method used to update a file/directory with the Mercurial
582 repository. 567 repository.
583 568
584 @param name file/directory name to be updated (string or list of 569 @param name file/directory name to be updated (not used)
585 strings)
586 @param noDialog flag indicating quiet operations (boolean) 570 @param noDialog flag indicating quiet operations (boolean)
587 @keyparam revision revision to update to (string) 571 @param revision revision to update to (string)
588 @return flag indicating, that the update contained an add 572 @return flag indicating, that the update contained an add
589 or delete (boolean) 573 or delete (boolean)
590 """ 574 """
591 args = self.initCommand("update") 575 args = self.initCommand("update")
592 if "-v" not in args and "--verbose" not in args: 576 if "-v" not in args and "--verbose" not in args:
593 args.append("-v") 577 args.append("-v")
594 if revision: 578 if revision:
595 args.append("-r") 579 args.append("-r")
596 args.append(revision) 580 args.append(revision)
597 581
598 if isinstance(name, list):
599 dname, fnames = self.splitPathList(name)
600 else:
601 dname, fname = self.splitPath(name)
602
603 # find the root of the repo
604 repodir = dname
605 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
606 repodir = os.path.dirname(repodir)
607 if os.path.splitdrive(repodir)[1] == os.sep:
608 return False
609
610 if noDialog: 582 if noDialog:
611 out, err = self.__client.runcommand(args) 583 out, err = self.__client.runcommand(args)
612 res = False 584 res = False
613 else: 585 else:
614 dia = HgDialog(self.tr( 586 dia = HgDialog(self.tr(
615 'Synchronizing with the Mercurial repository'), 587 'Synchronizing with the Mercurial repository'),
616 self) 588 self)
617 res = dia.startProcess(args, repodir) 589 res = dia.startProcess(args)
618 if res: 590 if res:
619 dia.exec() 591 dia.exec()
620 res = dia.hasAddOrDelete() 592 res = dia.hasAddOrDelete()
621 self.checkVCSStatus() 593 self.checkVCSStatus()
622 return res 594 return res
631 """ 603 """
632 args = self.initCommand("add") 604 args = self.initCommand("add")
633 args.append("-v") 605 args.append("-v")
634 606
635 if isinstance(name, list): 607 if isinstance(name, list):
636 if isDir:
637 dname, fname = os.path.split(name[0])
638 else:
639 dname, fnames = self.splitPathList(name)
640 else:
641 if isDir:
642 dname, fname = os.path.split(name)
643 else:
644 dname, fname = self.splitPath(name)
645
646 # find the root of the repo
647 repodir = dname
648 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
649 repodir = os.path.dirname(repodir)
650 if os.path.splitdrive(repodir)[1] == os.sep:
651 return
652
653 if isinstance(name, list):
654 self.addArguments(args, name) 608 self.addArguments(args, name)
655 else: 609 else:
656 args.append(name) 610 args.append(name)
657 611
658 if noDialog: 612 if noDialog:
660 else: 614 else:
661 dia = HgDialog( 615 dia = HgDialog(
662 self.tr( 616 self.tr(
663 'Adding files/directories to the Mercurial repository'), 617 'Adding files/directories to the Mercurial repository'),
664 self) 618 self)
665 res = dia.startProcess(args, repodir) 619 res = dia.startProcess(args)
666 if res: 620 if res:
667 dia.exec() 621 dia.exec()
668 622
669 def vcsAddBinary(self, name, isDir=False): 623 def vcsAddBinary(self, name, isDir=False):
670 """ 624 """
704 args.append("-v") 658 args.append("-v")
705 if noDialog and '--force' not in args: 659 if noDialog and '--force' not in args:
706 args.append('--force') 660 args.append('--force')
707 661
708 if isinstance(name, list): 662 if isinstance(name, list):
709 dname, fnames = self.splitPathList(name)
710 self.addArguments(args, name) 663 self.addArguments(args, name)
711 else: 664 else:
712 dname, fname = self.splitPath(name)
713 args.append(name) 665 args.append(name)
714
715 # find the root of the repo
716 repodir = dname
717 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
718 repodir = os.path.dirname(repodir)
719 if os.path.splitdrive(repodir)[1] == os.sep:
720 return False
721 666
722 if noDialog: 667 if noDialog:
723 out, err = self.__client.runcommand(args) 668 out, err = self.__client.runcommand(args)
724 res = err == "" 669 res = err == ""
725 else: 670 else:
726 dia = HgDialog( 671 dia = HgDialog(
727 self.tr( 672 self.tr(
728 'Removing files/directories from the Mercurial' 673 'Removing files/directories from the Mercurial'
729 ' repository'), 674 ' repository'),
730 self) 675 self)
731 res = dia.startProcess(args, repodir) 676 res = dia.startProcess(args)
732 if res: 677 if res:
733 dia.exec() 678 dia.exec()
734 res = dia.normalExitWithoutErrors() 679 res = dia.normalExitWithoutErrors()
735 680
736 return res 681 return res
766 if force: 711 if force:
767 args.append('--force') 712 args.append('--force')
768 args.append(name) 713 args.append(name)
769 args.append(target) 714 args.append(target)
770 715
771 dname, fname = self.splitPath(name)
772 # find the root of the repo
773 repodir = dname
774 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
775 repodir = os.path.dirname(repodir)
776 if os.path.splitdrive(repodir)[1] == os.sep:
777 return False
778
779 if noDialog: 716 if noDialog:
780 out, err = self.__client.runcommand(args) 717 out, err = self.__client.runcommand(args)
781 res = err == "" 718 res = err == ""
782 else: 719 else:
783 dia = HgDialog(self.tr('Renaming {0}').format(name), self) 720 dia = HgDialog(self.tr('Renaming {0}').format(name), self)
784 res = dia.startProcess(args, repodir) 721 res = dia.startProcess(args)
785 if res: 722 if res:
786 dia.exec() 723 dia.exec()
787 res = dia.normalExit() 724 res = dia.normalExit()
788 if res: 725 if res:
789 if target.startswith(project.getProjectPath()): 726 if target.startswith(project.getProjectPath()):
858 if self.summary is None: 795 if self.summary is None:
859 from .HgSummaryDialog import HgSummaryDialog 796 from .HgSummaryDialog import HgSummaryDialog
860 self.summary = HgSummaryDialog(self) 797 self.summary = HgSummaryDialog(self)
861 self.summary.show() 798 self.summary.show()
862 self.summary.raise_() 799 self.summary.raise_()
863 self.summary.start(self.__projectHelper.getProject().getProjectPath(), 800 self.summary.start(mq=mq, largefiles=largefiles)
864 mq=mq, largefiles=largefiles) 801
865 802 def vcsTag(self, name=None, revision=None, tagName=None):
866 def vcsTag(self, name, revision=None, tagName=None):
867 """ 803 """
868 Public method used to set/remove a tag in the Mercurial repository. 804 Public method used to set/remove a tag in the Mercurial repository.
869 805
870 @param name file/directory name to determine the repo root from 806 @param name file/directory name to determine the repo root from
871 (string) 807 (string)
872 @param revision revision to set tag for (string) 808 @param revision revision to set tag for (string)
873 @param tagName name of the tag (string) 809 @param tagName name of the tag (string)
874 @return flag indicating a performed tag action (boolean) 810 @return flag indicating a performed tag action (boolean)
875 """ 811 """
876 dname, fname = self.splitPath(name)
877
878 # find the root of the repo
879 repodir = dname
880 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
881 repodir = os.path.dirname(repodir)
882 if os.path.splitdrive(repodir)[1] == os.sep:
883 return False
884
885 from .HgTagDialog import HgTagDialog 812 from .HgTagDialog import HgTagDialog
886 dlg = HgTagDialog(self.hgGetTagsList(repodir, withType=True), 813 dlg = HgTagDialog(self.hgGetTagsList(withType=True),
887 revision, tagName) 814 revision, tagName)
888 if dlg.exec() == QDialog.Accepted: 815 if dlg.exec() == QDialog.Accepted:
889 tag, revision, tagOp, force = dlg.getParameters() 816 tag, revision, tagOp, force = dlg.getParameters()
890 else: 817 else:
891 return False 818 return False
913 args.append("Removed {1}tag <{0}>.".format(tag, msgPart)) 840 args.append("Removed {1}tag <{0}>.".format(tag, msgPart))
914 args.append(tag) 841 args.append(tag)
915 842
916 dia = HgDialog(self.tr('Tagging in the Mercurial repository'), 843 dia = HgDialog(self.tr('Tagging in the Mercurial repository'),
917 self) 844 self)
918 res = dia.startProcess(args, repodir) 845 res = dia.startProcess(args)
919 if res: 846 if res:
920 dia.exec() 847 dia.exec()
921 848
922 return True 849 return True
923 850
932 args = self.initCommand("revert") 859 args = self.initCommand("revert")
933 if not self.getPlugin().getPreferences("CreateBackup"): 860 if not self.getPlugin().getPreferences("CreateBackup"):
934 args.append("--no-backup") 861 args.append("--no-backup")
935 args.append("-v") 862 args.append("-v")
936 if isinstance(name, list): 863 if isinstance(name, list):
937 dname, fnames = self.splitPathList(name)
938 self.addArguments(args, name) 864 self.addArguments(args, name)
939 names = name[:] 865 names = name[:]
940 else: 866 else:
941 dname, fname = self.splitPath(name)
942 args.append(name) 867 args.append(name)
943 names = [name] 868 names = [name]
944
945 # find the root of the repo
946 repodir = dname
947 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
948 repodir = os.path.dirname(repodir)
949 if os.path.splitdrive(repodir)[1] == os.sep:
950 return False
951 869
952 project = e5App().getObject("Project") 870 project = e5App().getObject("Project")
953 names = [project.getRelativePath(nam) for nam in names] 871 names = [project.getRelativePath(nam) for nam in names]
954 if names[0]: 872 if names[0]:
955 from UI.DeleteFilesConfirmationDialog import ( 873 from UI.DeleteFilesConfirmationDialog import (
969 self.tr("Revert changes"), 887 self.tr("Revert changes"),
970 self.tr("""Do you really want to revert all changes of""" 888 self.tr("""Do you really want to revert all changes of"""
971 """ the project?""")) 889 """ the project?"""))
972 if yes: 890 if yes:
973 dia = HgDialog(self.tr('Reverting changes'), self) 891 dia = HgDialog(self.tr('Reverting changes'), self)
974 res = dia.startProcess(args, repodir) 892 res = dia.startProcess(args)
975 if res: 893 if res:
976 dia.exec() 894 dia.exec()
977 res = dia.hasAddOrDelete() 895 res = dia.hasAddOrDelete()
978 self.checkVCSStatus() 896 self.checkVCSStatus()
979 else: 897 else:
985 """ 903 """
986 Public method used to merge a URL/revision into the local project. 904 Public method used to merge a URL/revision into the local project.
987 905
988 @param name file/directory name to be merged 906 @param name file/directory name to be merged
989 @type str 907 @type str
990 @keyparam rev revision to merge with 908 @param rev revision to merge with
991 @type str 909 @type str
992 """ 910 """
993 dname, fname = self.splitPath(name)
994
995 # find the root of the repo
996 repodir = dname
997 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
998 repodir = os.path.dirname(repodir)
999 if os.path.splitdrive(repodir)[1] == os.sep:
1000 return
1001
1002 if not rev: 911 if not rev:
1003 from .HgMergeDialog import HgMergeDialog 912 from .HgMergeDialog import HgMergeDialog
1004 dlg = HgMergeDialog(self.hgGetTagsList(repodir), 913 dlg = HgMergeDialog(self.hgGetTagsList(),
1005 self.hgGetBranchesList(repodir), 914 self.hgGetBranchesList(),
1006 self.hgGetBookmarksList(repodir)) 915 self.hgGetBookmarksList())
1007 if dlg.exec() == QDialog.Accepted: 916 if dlg.exec() == QDialog.Accepted:
1008 rev, force = dlg.getParameters() 917 rev, force = dlg.getParameters()
1009 else: 918 else:
1010 return 919 return
1011 else: 920 else:
1019 args.append("internal:merge") 928 args.append("internal:merge")
1020 if rev: 929 if rev:
1021 args.append("--rev") 930 args.append("--rev")
1022 args.append(rev) 931 args.append(rev)
1023 932
1024 dia = HgDialog(self.tr('Merging').format(name), self) 933 dia = HgDialog(self.tr('Merging'), self)
1025 res = dia.startProcess(args, repodir) 934 res = dia.startProcess(args)
1026 if res: 935 if res:
1027 dia.exec() 936 dia.exec()
1028 self.checkVCSStatus() 937 self.checkVCSStatus()
1029 938
1030 def hgReMerge(self, name): 939 def hgReMerge(self, name):
1036 args = self.initCommand("resolve") 945 args = self.initCommand("resolve")
1037 if self.getPlugin().getPreferences("InternalMerge"): 946 if self.getPlugin().getPreferences("InternalMerge"):
1038 args.append("--tool") 947 args.append("--tool")
1039 args.append("internal:merge") 948 args.append("internal:merge")
1040 if isinstance(name, list): 949 if isinstance(name, list):
1041 dname, fnames = self.splitPathList(name)
1042 self.addArguments(args, name) 950 self.addArguments(args, name)
1043 names = name[:] 951 names = name[:]
1044 else: 952 else:
1045 dname, fname = self.splitPath(name)
1046 args.append(name) 953 args.append(name)
1047 names = [name] 954 names = [name]
1048
1049 # find the root of the repo
1050 repodir = dname
1051 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1052 repodir = os.path.dirname(repodir)
1053 if os.path.splitdrive(repodir)[1] == os.sep:
1054 return
1055 955
1056 project = e5App().getObject("Project") 956 project = e5App().getObject("Project")
1057 names = [project.getRelativePath(nam) for nam in names] 957 names = [project.getRelativePath(nam) for nam in names]
1058 if names[0]: 958 if names[0]:
1059 from UI.DeleteFilesConfirmationDialog import ( 959 from UI.DeleteFilesConfirmationDialog import (
1072 None, 972 None,
1073 self.tr("Re-Merge"), 973 self.tr("Re-Merge"),
1074 self.tr("""Do you really want to re-merge the project?""")) 974 self.tr("""Do you really want to re-merge the project?"""))
1075 if yes: 975 if yes:
1076 dia = HgDialog(self.tr('Re-Merging').format(name), self) 976 dia = HgDialog(self.tr('Re-Merging').format(name), self)
1077 res = dia.startProcess(args, repodir) 977 res = dia.startProcess(args)
1078 if res: 978 if res:
1079 dia.exec() 979 dia.exec()
1080 self.checkVCSStatus() 980 self.checkVCSStatus()
1081 981
1082 def vcsSwitch(self, name): 982 def vcsSwitch(self, name):
1086 986
1087 @param name directory name to be switched (string) 987 @param name directory name to be switched (string)
1088 @return flag indicating, that the switch contained an add 988 @return flag indicating, that the switch contained an add
1089 or delete (boolean) 989 or delete (boolean)
1090 """ 990 """
1091 dname, fname = self.splitPath(name)
1092
1093 # find the root of the repo
1094 repodir = dname
1095 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1096 repodir = os.path.dirname(repodir)
1097 if os.path.splitdrive(repodir)[1] == os.sep:
1098 return False
1099
1100 from .HgRevisionSelectionDialog import HgRevisionSelectionDialog 991 from .HgRevisionSelectionDialog import HgRevisionSelectionDialog
1101 dlg = HgRevisionSelectionDialog(self.hgGetTagsList(repodir), 992 dlg = HgRevisionSelectionDialog(self.hgGetTagsList(),
1102 self.hgGetBranchesList(repodir), 993 self.hgGetBranchesList(),
1103 self.hgGetBookmarksList(repodir), 994 self.hgGetBookmarksList(),
1104 self.tr("Current branch tip")) 995 self.tr("Current branch tip"))
1105 if dlg.exec() == QDialog.Accepted: 996 if dlg.exec() == QDialog.Accepted:
1106 rev = dlg.getRevision() 997 rev = dlg.getRevision()
1107 return self.vcsUpdate(name, revision=rev) 998 return self.vcsUpdate(name, revision=rev)
1108 999
1110 1001
1111 def vcsRegisteredState(self, name): 1002 def vcsRegisteredState(self, name):
1112 """ 1003 """
1113 Public method used to get the registered state of a file in the vcs. 1004 Public method used to get the registered state of a file in the vcs.
1114 1005
1115 @param name filename to check (string) 1006 @param name file or directory name to check
1007 @type str
1116 @return a combination of canBeCommited and canBeAdded 1008 @return a combination of canBeCommited and canBeAdded
1009 @rtype int
1117 """ 1010 """
1118 if name.endswith(os.sep): 1011 if name.endswith(os.sep):
1119 name = name[:-1] 1012 name = name[:-1]
1120 name = os.path.normcase(name) 1013 name = os.path.normcase(name)
1121 dname, fname = self.splitPath(name) 1014
1122 1015 if (
1123 if fname == '.' and os.path.isdir(os.path.join(dname, self.adminDir)): 1016 os.path.isdir(name) and
1017 os.path.isdir(os.path.join(name, self.adminDir))
1018 ):
1124 return self.canBeCommitted 1019 return self.canBeCommitted
1125 1020
1126 if name in self.statusCache: 1021 if name in self.statusCache:
1127 return self.statusCache[name] 1022 return self.statusCache[name]
1128
1129 # find the root of the repo
1130 repodir = dname
1131 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1132 repodir = os.path.dirname(repodir)
1133 if os.path.splitdrive(repodir)[1] == os.sep:
1134 return 0
1135
1136 args = self.initCommand("status") 1023 args = self.initCommand("status")
1137 args.append('--all') 1024 args.append('--all')
1138 args.append('--noninteractive') 1025 args.append('--noninteractive')
1139 1026
1140 output, error = self.__client.runcommand(args) 1027 output, error = self.__client.runcommand(args)
1141 1028
1142 if output: 1029 if output:
1030 repodir = self.getClient().getRepository()
1143 for line in output.splitlines(): 1031 for line in output.splitlines():
1144 if len(line) > 2 and line[0] in "MARC!?I" and line[1] == " ": 1032 if len(line) > 2 and line[0] in "MARC!?I" and line[1] == " ":
1145 flag, path = line.split(" ", 1) 1033 flag, path = line.split(" ", 1)
1146 absname = os.path.join(repodir, os.path.normcase(path)) 1034 absname = Utilities.normcasepath(
1147 if flag not in "?I": 1035 os.path.join(repodir, path))
1148 if fname == '.': 1036 if flag not in "?I" and absname == name:
1149 if absname.startswith(dname + os.path.sep): 1037 return self.canBeCommitted
1150 return self.canBeCommitted
1151 if absname == dname:
1152 return self.canBeCommitted
1153 else:
1154 if absname == name:
1155 return self.canBeCommitted
1156 1038
1157 return self.canBeAdded 1039 return self.canBeAdded
1158 1040
1159 def vcsAllRegisteredStates(self, names, dname, shortcut=True): 1041 def vcsAllRegisteredStates(self, names, dname, shortcut=True):
1160 """ 1042 """
1180 if name in names: 1062 if name in names:
1181 found = True 1063 found = True
1182 names[name] = self.statusCache[name] 1064 names[name] = self.statusCache[name]
1183 1065
1184 if not found: 1066 if not found:
1185 # find the root of the repo
1186 repodir = dname
1187 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1188 repodir = os.path.dirname(repodir)
1189 if os.path.splitdrive(repodir)[1] == os.sep:
1190 return names
1191
1192 args = self.initCommand("status") 1067 args = self.initCommand("status")
1193 args.append('--all') 1068 args.append('--all')
1194 args.append('--noninteractive') 1069 args.append('--noninteractive')
1195 1070
1196 output, error = self.__client.runcommand(args) 1071 output, error = self.__client.runcommand(args)
1197 1072
1198 if output: 1073 if output:
1074 repoPath = self.getClient().getRepository()
1199 dirs = [x for x in names.keys() if os.path.isdir(x)] 1075 dirs = [x for x in names.keys() if os.path.isdir(x)]
1200 for line in output.splitlines(): 1076 for line in output.splitlines():
1201 if line and line[0] in "MARC!?I": 1077 if line and line[0] in "MARC!?I":
1202 flag, path = line.split(" ", 1) 1078 flag, path = line.split(" ", 1)
1203 name = os.path.normcase(os.path.join(repodir, path)) 1079 name = os.path.normcase(os.path.join(repoPath, path))
1204 dirName = os.path.dirname(name) 1080 dirName = os.path.dirname(name)
1205 if name.startswith(dname): 1081 if name.startswith(dname):
1206 if flag not in "?I": 1082 if flag not in "?I":
1207 if name in names: 1083 if name in names:
1208 names[name] = self.canBeCommitted 1084 names[name] = self.canBeCommitted
1289 self.commandHistory.insert(0, command) 1165 self.commandHistory.insert(0, command)
1290 1166
1291 args = [] 1167 args = []
1292 self.addArguments(args, commandList) 1168 self.addArguments(args, commandList)
1293 1169
1294 # find the root of the repo
1295 repodir = name
1296 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1297 repodir = os.path.dirname(repodir)
1298 if os.path.splitdrive(repodir)[1] == os.sep:
1299 return
1300
1301 dia = HgDialog(self.tr('Mercurial command'), self) 1170 dia = HgDialog(self.tr('Mercurial command'), self)
1302 res = dia.startProcess(args, repodir) 1171 res = dia.startProcess(args)
1303 if res: 1172 if res:
1304 dia.exec() 1173 dia.exec()
1305 1174
1306 def vcsOptionsDialog(self, project, archive, editable=False, parent=None): 1175 def vcsOptionsDialog(self, project, archive, editable=False, parent=None):
1307 """ 1176 """
1449 args = self.initCommand("copy") 1318 args = self.initCommand("copy")
1450 args.append("-v") 1319 args.append("-v")
1451 args.append(name) 1320 args.append(name)
1452 args.append(target) 1321 args.append(target)
1453 1322
1454 dname, fname = self.splitPath(name)
1455 # find the root of the repo
1456 repodir = dname
1457 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1458 repodir = os.path.dirname(repodir)
1459 if os.path.splitdrive(repodir)[1] == os.sep:
1460 return False
1461
1462 dia = HgDialog( 1323 dia = HgDialog(
1463 self.tr('Copying {0}').format(name), self) 1324 self.tr('Copying {0}').format(name), self)
1464 res = dia.startProcess(args, repodir) 1325 res = dia.startProcess(args)
1465 if res: 1326 if res:
1466 dia.exec() 1327 dia.exec()
1467 res = dia.normalExit() 1328 res = dia.normalExit()
1468 if ( 1329 if (
1469 res and 1330 res and
1473 project.copyDirectory(name, target) 1334 project.copyDirectory(name, target)
1474 else: 1335 else:
1475 project.appendFile(target) 1336 project.appendFile(target)
1476 return res 1337 return res
1477 1338
1478 def hgGetTagsList(self, repodir, withType=False): 1339 def hgGetTagsList(self, withType=False):
1479 """ 1340 """
1480 Public method to get the list of tags. 1341 Public method to get the list of tags.
1481 1342
1482 @param repodir directory name of the repository (string)
1483 @param withType flag indicating to get the tag type as well (boolean) 1343 @param withType flag indicating to get the tag type as well (boolean)
1484 @return list of tags (list of string) or list of tuples of 1344 @return list of tags (list of string) or list of tuples of
1485 tag name and flag indicating a local tag (list of tuple of string 1345 tag name and flag indicating a local tag (list of tuple of string
1486 and boolean), if withType is True 1346 and boolean), if withType is True
1487 """ 1347 """
1513 else: 1373 else:
1514 if tagsList: 1374 if tagsList:
1515 self.tagsList = tagsList 1375 self.tagsList = tagsList
1516 return self.tagsList[:] 1376 return self.tagsList[:]
1517 1377
1518 def hgGetBranchesList(self, repodir): 1378 def hgGetBranchesList(self):
1519 """ 1379 """
1520 Public method to get the list of branches. 1380 Public method to get the list of branches.
1521 1381
1522 @param repodir directory name of the repository (string)
1523 @return list of branches (list of string) 1382 @return list of branches (list of string)
1524 """ 1383 """
1525 args = self.initCommand("branches") 1384 args = self.initCommand("branches")
1526 args.append('--closed') 1385 args.append('--closed')
1527 1386
1540 if name not in ["tip", "default"]: 1399 if name not in ["tip", "default"]:
1541 self.branchesList.append(name) 1400 self.branchesList.append(name)
1542 1401
1543 return self.branchesList[:] 1402 return self.branchesList[:]
1544 1403
1545 def hgListTagBranch(self, path, tags=True): 1404 def hgListTagBranch(self, tags=True):
1546 """ 1405 """
1547 Public method used to list the available tags or branches. 1406 Public method used to list the available tags or branches.
1548 1407
1549 @param path directory name of the project (string)
1550 @param tags flag indicating listing of branches or tags 1408 @param tags flag indicating listing of branches or tags
1551 (False = branches, True = tags) 1409 (False = branches, True = tags)
1552 """ 1410 """
1553 from .HgTagBranchListDialog import HgTagBranchListDialog 1411 from .HgTagBranchListDialog import HgTagBranchListDialog
1554 self.tagbranchList = HgTagBranchListDialog(self) 1412 self.tagbranchList = HgTagBranchListDialog(self)
1558 self.showedTags = True 1416 self.showedTags = True
1559 allTagsBranchesList = self.allTagsBranchesList 1417 allTagsBranchesList = self.allTagsBranchesList
1560 else: 1418 else:
1561 self.tagsList = [] 1419 self.tagsList = []
1562 allTagsBranchesList = None 1420 allTagsBranchesList = None
1563 self.tagbranchList.start(path, tags, 1421 self.tagbranchList.start(
1564 self.tagsList, allTagsBranchesList) 1422 tags, self.tagsList, allTagsBranchesList)
1565 else: 1423 else:
1566 if not self.showedBranches: 1424 if not self.showedBranches:
1567 self.showedBranches = True 1425 self.showedBranches = True
1568 allTagsBranchesList = self.allTagsBranchesList 1426 allTagsBranchesList = self.allTagsBranchesList
1569 else: 1427 else:
1570 self.branchesList = [] 1428 self.branchesList = []
1571 allTagsBranchesList = None 1429 allTagsBranchesList = None
1572 self.tagbranchList.start(path, tags, 1430 self.tagbranchList.start(
1573 self.branchesList, 1431 tags, self.branchesList, self.allTagsBranchesList)
1574 self.allTagsBranchesList)
1575 1432
1576 def hgAnnotate(self, name): 1433 def hgAnnotate(self, name):
1577 """ 1434 """
1578 Public method to show the output of the hg annotate command. 1435 Public method to show the output of the hg annotate command.
1579 1436
1599 This method gives the chance to enter the revisions to be compared. 1456 This method gives the chance to enter the revisions to be compared.
1600 1457
1601 @param name file/directory name to be diffed (string) 1458 @param name file/directory name to be diffed (string)
1602 """ 1459 """
1603 if isinstance(name, list): 1460 if isinstance(name, list):
1604 dname, fnames = self.splitPathList(name)
1605 names = name[:] 1461 names = name[:]
1606 else: 1462 else:
1607 dname, fname = self.splitPath(name)
1608 names = [name] 1463 names = [name]
1609 for nam in names: 1464 for nam in names:
1610 if os.path.isfile(nam): 1465 if os.path.isfile(nam):
1611 editor = e5App().getObject("ViewManager").getOpenEditor(nam) 1466 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
1612 if editor and not editor.checkDirty(): 1467 if editor and not editor.checkDirty():
1614 else: 1469 else:
1615 project = e5App().getObject("Project") 1470 project = e5App().getObject("Project")
1616 if nam == project.ppath and not project.saveAllScripts(): 1471 if nam == project.ppath and not project.saveAllScripts():
1617 return 1472 return
1618 1473
1619 # find the root of the repo
1620 repodir = dname
1621 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1622 repodir = os.path.dirname(repodir)
1623 if os.path.splitdrive(repodir)[1] == os.sep:
1624 return
1625
1626 from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog 1474 from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog
1627 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(repodir), 1475 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(),
1628 self.hgGetBranchesList(repodir), 1476 self.hgGetBranchesList(),
1629 self.hgGetBookmarksList(repodir)) 1477 self.hgGetBookmarksList())
1630 if dlg.exec() == QDialog.Accepted: 1478 if dlg.exec() == QDialog.Accepted:
1631 revisions = dlg.getRevisions() 1479 revisions = dlg.getRevisions()
1632 if self.diff is None: 1480 if self.diff is None:
1633 from .HgDiffDialog import HgDiffDialog 1481 from .HgDiffDialog import HgDiffDialog
1634 self.diff = HgDiffDialog(self) 1482 self.diff = HgDiffDialog(self)
1640 """ 1488 """
1641 Private method to get a file for a specific revision from the 1489 Private method to get a file for a specific revision from the
1642 repository. 1490 repository.
1643 1491
1644 @param name file name to get from the repository (string) 1492 @param name file name to get from the repository (string)
1645 @keyparam rev revision to retrieve (string) 1493 @param rev revision to retrieve (string)
1646 @return contents of the file (string) and an error message (string) 1494 @return contents of the file (string) and an error message (string)
1647 """ 1495 """
1648 args = self.initCommand("cat") 1496 args = self.initCommand("cat")
1649 if rev: 1497 if rev:
1650 args.append("--rev") 1498 args.append("--rev")
1660 """ 1508 """
1661 Public method used to view the difference of a file to the Mercurial 1509 Public method used to view the difference of a file to the Mercurial
1662 repository side-by-side. 1510 repository side-by-side.
1663 1511
1664 @param name file name to be diffed (string) 1512 @param name file name to be diffed (string)
1665 @keyparam extended flag indicating the extended variant (boolean) 1513 @param extended flag indicating the extended variant (boolean)
1666 @keyparam revisions tuple of two revisions (tuple of strings) 1514 @param revisions tuple of two revisions (tuple of strings)
1667 @exception ValueError raised to indicate an invalid name parameter 1515 @exception ValueError raised to indicate an invalid name parameter
1668 """ 1516 """
1669 if isinstance(name, list): 1517 if isinstance(name, list):
1670 raise ValueError("Wrong parameter type") 1518 raise ValueError("Wrong parameter type")
1671 1519
1672 if extended: 1520 if extended:
1673 # find the root of the repo
1674 repodir = self.splitPath(name)[0]
1675 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1676 repodir = os.path.dirname(repodir)
1677 if os.path.splitdrive(repodir)[1] == os.sep:
1678 return
1679
1680 from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog 1521 from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog
1681 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(repodir), 1522 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(),
1682 self.hgGetBranchesList(repodir), 1523 self.hgGetBranchesList(),
1683 self.hgGetBookmarksList(repodir)) 1524 self.hgGetBookmarksList())
1684 if dlg.exec() == QDialog.Accepted: 1525 if dlg.exec() == QDialog.Accepted:
1685 rev1, rev2 = dlg.getRevisions() 1526 rev1, rev2 = dlg.getRevisions()
1686 else: 1527 else:
1687 return 1528 return
1688 elif revisions: 1529 elif revisions:
1727 self.sbsDiff = CompareDialog() 1568 self.sbsDiff = CompareDialog()
1728 self.sbsDiff.show() 1569 self.sbsDiff.show()
1729 self.sbsDiff.raise_() 1570 self.sbsDiff.raise_()
1730 self.sbsDiff.compare(output1, output2, name1, name2) 1571 self.sbsDiff.compare(output1, output2, name1, name2)
1731 1572
1732 def vcsLogBrowser(self, name, isFile=False): 1573 def vcsLogBrowser(self, name=None, isFile=False):
1733 """ 1574 """
1734 Public method used to browse the log of a file/directory from the 1575 Public method used to browse the log of a file/directory from the
1735 Mercurial repository. 1576 Mercurial repository.
1736 1577
1737 @param name file/directory name to show the log of (string) 1578 @param name file/directory name to show the log of (string)
1738 @keyparam isFile flag indicating log for a file is to be shown 1579 @param isFile flag indicating log for a file is to be shown
1739 (boolean) 1580 (boolean)
1740 """ 1581 """
1582 if name == self.getClient().getRepository():
1583 name = None
1584
1741 if self.logBrowser is None: 1585 if self.logBrowser is None:
1742 from .HgLogBrowserDialog import HgLogBrowserDialog 1586 from .HgLogBrowserDialog import HgLogBrowserDialog
1743 self.logBrowser = HgLogBrowserDialog(self) 1587 self.logBrowser = HgLogBrowserDialog(self)
1744 self.logBrowser.show() 1588 self.logBrowser.show()
1745 self.logBrowser.raise_() 1589 self.logBrowser.raise_()
1746 self.logBrowser.start(name, isFile=isFile) 1590 self.logBrowser.start(name=name, isFile=isFile)
1747 1591
1748 def hgIncoming(self, name): 1592 def hgIncoming(self):
1749 """ 1593 """
1750 Public method used to view the log of incoming changes from the 1594 Public method used to view the log of incoming changes from the
1751 Mercurial repository. 1595 Mercurial repository.
1752
1753 @param name file/directory name to show the log of (string)
1754 """ 1596 """
1755 if self.logBrowserIncoming is None: 1597 if self.logBrowserIncoming is None:
1756 from .HgLogBrowserDialog import HgLogBrowserDialog 1598 from .HgLogBrowserDialog import HgLogBrowserDialog
1757 self.logBrowserIncoming = HgLogBrowserDialog( 1599 self.logBrowserIncoming = HgLogBrowserDialog(
1758 self, mode="incoming") 1600 self, mode="incoming")
1759 self.logBrowserIncoming.show() 1601 self.logBrowserIncoming.show()
1760 self.logBrowserIncoming.raise_() 1602 self.logBrowserIncoming.raise_()
1761 self.logBrowserIncoming.start(name) 1603 self.logBrowserIncoming.start()
1762 1604
1763 def hgOutgoing(self, name): 1605 def hgOutgoing(self):
1764 """ 1606 """
1765 Public method used to view the log of outgoing changes from the 1607 Public method used to view the log of outgoing changes from the
1766 Mercurial repository. 1608 Mercurial repository.
1767
1768 @param name file/directory name to show the log of (string)
1769 """ 1609 """
1770 if self.logBrowserOutgoing is None: 1610 if self.logBrowserOutgoing is None:
1771 from .HgLogBrowserDialog import HgLogBrowserDialog 1611 from .HgLogBrowserDialog import HgLogBrowserDialog
1772 self.logBrowserOutgoing = HgLogBrowserDialog( 1612 self.logBrowserOutgoing = HgLogBrowserDialog(
1773 self, mode="outgoing") 1613 self, mode="outgoing")
1774 self.logBrowserOutgoing.show() 1614 self.logBrowserOutgoing.show()
1775 self.logBrowserOutgoing.raise_() 1615 self.logBrowserOutgoing.raise_()
1776 self.logBrowserOutgoing.start(name) 1616 self.logBrowserOutgoing.start()
1777 1617
1778 def hgPull(self, name, revisions=None): 1618 def hgPull(self, revisions=None):
1779 """ 1619 """
1780 Public method used to pull changes from a remote Mercurial repository. 1620 Public method used to pull changes from a remote Mercurial repository.
1781 1621
1782 @param name directory name of the project to be pulled to
1783 @type str
1784 @param revisions list of revisions to be pulled 1622 @param revisions list of revisions to be pulled
1785 @type list of str 1623 @type list of str
1786 @return flag indicating, that the update contained an add 1624 @return flag indicating, that the update contained an add
1787 or delete 1625 or delete
1788 @rtype bool 1626 @rtype bool
1808 if revisions: 1646 if revisions:
1809 for rev in revisions: 1647 for rev in revisions:
1810 args.append("--rev") 1648 args.append("--rev")
1811 args.append(rev) 1649 args.append(rev)
1812 1650
1813 # find the root of the repo
1814 repodir = self.splitPath(name)[0]
1815 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1816 repodir = os.path.dirname(repodir)
1817 if os.path.splitdrive(repodir)[1] == os.sep:
1818 return False
1819
1820 dia = HgDialog(title, self) 1651 dia = HgDialog(title, self)
1821 res = dia.startProcess(args, repodir) 1652 res = dia.startProcess(args)
1822 if res: 1653 if res:
1823 dia.exec() 1654 dia.exec()
1824 res = dia.hasAddOrDelete() 1655 res = dia.hasAddOrDelete()
1825 if ( 1656 if (
1826 self.bundleFile and 1657 self.bundleFile and
1829 os.remove(self.bundleFile) 1660 os.remove(self.bundleFile)
1830 self.bundleFile = None 1661 self.bundleFile = None
1831 self.checkVCSStatus() 1662 self.checkVCSStatus()
1832 return res 1663 return res
1833 1664
1834 def hgPush(self, name, force=False, newBranch=False, rev=None): 1665 def hgPush(self, force=False, newBranch=False, rev=None):
1835 """ 1666 """
1836 Public method used to push changes to a remote Mercurial repository. 1667 Public method used to push changes to a remote Mercurial repository.
1837 1668
1838 @param name directory name of the project to be pushed from (string) 1669 @param force flag indicating a forced push (boolean)
1839 @keyparam force flag indicating a forced push (boolean) 1670 @param newBranch flag indicating to push a new branch (boolean)
1840 @keyparam newBranch flag indicating to push a new branch (boolean) 1671 @param rev revision to be pushed (including all ancestors) (string)
1841 @keyparam rev revision to be pushed (including all ancestors) (string)
1842 """ 1672 """
1843 args = self.initCommand("push") 1673 args = self.initCommand("push")
1844 args.append('-v') 1674 args.append('-v')
1845 if force: 1675 if force:
1846 args.append('-f') 1676 args.append('-f')
1848 args.append('--new-branch') 1678 args.append('--new-branch')
1849 if rev: 1679 if rev:
1850 args.append('--rev') 1680 args.append('--rev')
1851 args.append(rev) 1681 args.append(rev)
1852 1682
1853 # find the root of the repo
1854 repodir = self.splitPath(name)[0]
1855 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1856 repodir = os.path.dirname(repodir)
1857 if os.path.splitdrive(repodir)[1] == os.sep:
1858 return
1859
1860 dia = HgDialog( 1683 dia = HgDialog(
1861 self.tr('Pushing to a remote Mercurial repository'), self) 1684 self.tr('Pushing to a remote Mercurial repository'), self)
1862 res = dia.startProcess(args, repodir) 1685 res = dia.startProcess(args)
1863 if res: 1686 if res:
1864 dia.exec() 1687 dia.exec()
1865 self.checkVCSStatus() 1688 self.checkVCSStatus()
1866 1689
1867 def hgInfo(self, ppath, mode="heads"): 1690 def hgInfo(self, mode="heads"):
1868 """ 1691 """
1869 Public method to show information about the heads of the repository. 1692 Public method to show information about the heads of the repository.
1870 1693
1871 @param ppath local path to get the repository infos (string) 1694 @param mode mode of the operation (string, one of heads, parents,
1872 @keyparam mode mode of the operation (string, one of heads, parents,
1873 tip) 1695 tip)
1874 """ 1696 """
1875 if mode not in ("heads", "parents", "tip"): 1697 if mode not in ("heads", "parents", "tip"):
1876 mode = "heads" 1698 mode = "heads"
1877 1699
1939 .format(author, cdate, ctime)) 1761 .format(author, cdate, ctime))
1940 1762
1941 dlg = VcsRepositoryInfoDialog(None, "\n".join(info)) 1763 dlg = VcsRepositoryInfoDialog(None, "\n".join(info))
1942 dlg.exec() 1764 dlg.exec()
1943 1765
1944 def hgConflicts(self, name): 1766 def hgConflicts(self):
1945 """ 1767 """
1946 Public method used to show a list of files containing conflicts. 1768 Public method used to show a list of files containing conflicts.
1947
1948 @param name file/directory name to be resolved (string)
1949 """ 1769 """
1950 if self.conflictsDlg is None: 1770 if self.conflictsDlg is None:
1951 from .HgConflictsListDialog import HgConflictsListDialog 1771 from .HgConflictsListDialog import HgConflictsListDialog
1952 self.conflictsDlg = HgConflictsListDialog(self) 1772 self.conflictsDlg = HgConflictsListDialog(self)
1953 self.conflictsDlg.show() 1773 self.conflictsDlg.show()
1954 self.conflictsDlg.raise_() 1774 self.conflictsDlg.raise_()
1955 self.conflictsDlg.start(name) 1775 self.conflictsDlg.start()
1956 1776
1957 def hgResolved(self, name, unresolve=False): 1777 def hgResolved(self, name, unresolve=False):
1958 """ 1778 """
1959 Public method used to resolve conflicts of a file/directory. 1779 Public method used to resolve conflicts of a file/directory.
1960 1780
1967 args.append("--unmark") 1787 args.append("--unmark")
1968 else: 1788 else:
1969 args.append("--mark") 1789 args.append("--mark")
1970 1790
1971 if isinstance(name, list): 1791 if isinstance(name, list):
1972 dname, fnames = self.splitPathList(name)
1973 self.addArguments(args, name) 1792 self.addArguments(args, name)
1974 else: 1793 else:
1975 dname, fname = self.splitPath(name)
1976 args.append(name) 1794 args.append(name)
1977
1978 # find the root of the repo
1979 repodir = dname
1980 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1981 repodir = os.path.dirname(repodir)
1982 if os.path.splitdrive(repodir)[1] == os.sep:
1983 return
1984 1795
1985 if unresolve: 1796 if unresolve:
1986 title = self.tr("Marking as 'unresolved'") 1797 title = self.tr("Marking as 'unresolved'")
1987 else: 1798 else:
1988 title = self.tr("Marking as 'resolved'") 1799 title = self.tr("Marking as 'resolved'")
1989 dia = HgDialog(title, self) 1800 dia = HgDialog(title, self)
1990 res = dia.startProcess(args, repodir) 1801 res = dia.startProcess(args)
1991 if res: 1802 if res:
1992 dia.exec() 1803 dia.exec()
1993 self.checkVCSStatus() 1804 self.checkVCSStatus()
1994 1805
1995 def hgAbortMerge(self, name): 1806 def hgAbortMerge(self):
1996 """ 1807 """
1997 Public method to abort an uncommitted merge. 1808 Public method to abort an uncommitted merge.
1998 1809
1999 @param name file/directory name (string)
2000 @return flag indicating, that the abortion contained an add 1810 @return flag indicating, that the abortion contained an add
2001 or delete (boolean) 1811 or delete (boolean)
2002 """ 1812 """
2003 dname, fname = self.splitPath(name)
2004
2005 # find the root of the repo
2006 repodir = dname
2007 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2008 repodir = os.path.dirname(repodir)
2009 if os.path.splitdrive(repodir)[1] == os.sep:
2010 return False
2011
2012 if self.version >= (4, 5, 0): 1813 if self.version >= (4, 5, 0):
2013 args = self.initCommand("merge") 1814 args = self.initCommand("merge")
2014 args.append("--abort") 1815 args.append("--abort")
2015 else: 1816 else:
2016 args = self.initCommand("update") 1817 args = self.initCommand("update")
2017 args.append("--clean") 1818 args.append("--clean")
2018 1819
2019 dia = HgDialog( 1820 dia = HgDialog(
2020 self.tr('Aborting uncommitted merge'), 1821 self.tr('Aborting uncommitted merge'),
2021 self) 1822 self)
2022 res = dia.startProcess(args, repodir, False) 1823 res = dia.startProcess(args, showArgs=False)
2023 if res: 1824 if res:
2024 dia.exec() 1825 dia.exec()
2025 res = dia.hasAddOrDelete() 1826 res = dia.hasAddOrDelete()
2026 self.checkVCSStatus() 1827 self.checkVCSStatus()
2027 return res 1828 return res
2028 1829
2029 def hgBranch(self, name): 1830 def hgBranch(self):
2030 """ 1831 """
2031 Public method used to create a branch in the Mercurial repository. 1832 Public method used to create a branch in the Mercurial repository.
2032 1833 """
2033 @param name file/directory name to be branched (string)
2034 """
2035 dname, fname = self.splitPath(name)
2036
2037 # find the root of the repo
2038 repodir = dname
2039 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2040 repodir = os.path.dirname(repodir)
2041 if os.path.splitdrive(repodir)[1] == os.sep:
2042 return
2043
2044 from .HgBranchInputDialog import HgBranchInputDialog 1834 from .HgBranchInputDialog import HgBranchInputDialog
2045 dlg = HgBranchInputDialog(self.hgGetBranchesList(repodir)) 1835 dlg = HgBranchInputDialog(self.hgGetBranchesList())
2046 if dlg.exec() == QDialog.Accepted: 1836 if dlg.exec() == QDialog.Accepted:
2047 name, commit = dlg.getData() 1837 name, commit = dlg.getData()
2048 name = name.strip().replace(" ", "_") 1838 name = name.strip().replace(" ", "_")
2049 args = self.initCommand("branch") 1839 args = self.initCommand("branch")
2050 args.append(name) 1840 args.append(name)
2051 1841
2052 dia = HgDialog( 1842 dia = HgDialog(
2053 self.tr('Creating branch in the Mercurial repository'), 1843 self.tr('Creating branch in the Mercurial repository'),
2054 self) 1844 self)
2055 res = dia.startProcess(args, repodir) 1845 res = dia.startProcess(args)
2056 if res: 1846 if res:
2057 dia.exec() 1847 dia.exec()
2058 if commit: 1848 if commit:
2059 self.vcsCommit( 1849 self.vcsCommit(
2060 repodir, 1850 name,
2061 self.tr("Created new branch <{0}>.").format( 1851 self.tr("Created new branch <{0}>.").format(
2062 name)) 1852 name))
2063 1853
2064 def hgShowBranch(self, name): 1854 def hgShowBranch(self):
2065 """ 1855 """
2066 Public method used to show the current branch of the working directory. 1856 Public method used to show the current branch of the working directory.
2067 1857 """
2068 @param name file/directory name (string)
2069 """
2070 dname, fname = self.splitPath(name)
2071
2072 # find the root of the repo
2073 repodir = dname
2074 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2075 repodir = os.path.dirname(repodir)
2076 if os.path.splitdrive(repodir)[1] == os.sep:
2077 return
2078
2079 args = self.initCommand("branch") 1858 args = self.initCommand("branch")
2080 1859
2081 dia = HgDialog(self.tr('Showing current branch'), self) 1860 dia = HgDialog(self.tr('Showing current branch'), self)
2082 res = dia.startProcess(args, repodir, False) 1861 res = dia.startProcess(args, showArgs=False)
2083 if res: 1862 if res:
2084 dia.exec() 1863 dia.exec()
2085 1864
2086 def hgGetCurrentBranch(self, repodir): 1865 def hgGetCurrentBranch(self):
2087 """ 1866 """
2088 Public method to get the current branch of the working directory. 1867 Public method to get the current branch of the working directory.
2089 1868
2090 @param repodir directory name of the repository
2091 @type str
2092 @return name of the current branch 1869 @return name of the current branch
2093 @rtype str 1870 @rtype str
2094 """ 1871 """
2095 args = self.initCommand("branch") 1872 args = self.initCommand("branch")
2096 1873
2104 """ 1881 """
2105 from .HgUserConfigDialog import HgUserConfigDialog 1882 from .HgUserConfigDialog import HgUserConfigDialog
2106 dlg = HgUserConfigDialog(version=self.version) 1883 dlg = HgUserConfigDialog(version=self.version)
2107 dlg.exec() 1884 dlg.exec()
2108 1885
2109 def hgEditConfig(self, name, withLargefiles=True, largefilesData=None): 1886 def hgEditConfig(self, repoName=None,
1887 withLargefiles=True, largefilesData=None):
2110 """ 1888 """
2111 Public method used to edit the repository configuration file. 1889 Public method used to edit the repository configuration file.
2112 1890
2113 @param name file/directory name (string) 1891 @param repoName directory name containing the repository
1892 @type str
2114 @param withLargefiles flag indicating to configure the largefiles 1893 @param withLargefiles flag indicating to configure the largefiles
2115 section (boolean) 1894 section
1895 @type bool
2116 @param largefilesData dictionary with data for the largefiles 1896 @param largefilesData dictionary with data for the largefiles
2117 section of the data dialog (dict) 1897 section of the data dialog
2118 """ 1898 @type dict
2119 dname, fname = self.splitPath(name) 1899 """
2120 1900 if repoName is None:
2121 # find the root of the repo 1901 repoName = self.getClient().getRepository()
2122 repodir = dname 1902
2123 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1903 cfgFile = os.path.join(repoName, self.adminDir, "hgrc")
2124 repodir = os.path.dirname(repodir)
2125 if os.path.splitdrive(repodir)[1] == os.sep:
2126 return
2127
2128 cfgFile = os.path.join(repodir, self.adminDir, "hgrc")
2129 if not os.path.exists(cfgFile): 1904 if not os.path.exists(cfgFile):
2130 # open dialog to enter the initial data 1905 # open dialog to enter the initial data
2131 withLargefiles = (self.isExtensionActive("largefiles") and 1906 withLargefiles = (self.isExtensionActive("largefiles") and
2132 withLargefiles) 1907 withLargefiles)
2133 from .HgRepoConfigDataDialog import HgRepoConfigDataDialog 1908 from .HgRepoConfigDataDialog import HgRepoConfigDataDialog
2159 cfg.write("minsize = {0}\n".format(lfMinSize)) 1934 cfg.write("minsize = {0}\n".format(lfMinSize))
2160 if lfPattern is not None: 1935 if lfPattern is not None:
2161 cfg.write("patterns =\n") 1936 cfg.write("patterns =\n")
2162 cfg.write(" {0}\n".format( 1937 cfg.write(" {0}\n".format(
2163 "\n ".join(lfPattern))) 1938 "\n ".join(lfPattern)))
2164 self.__monitorRepoIniFile(repodir) 1939 self.__monitorRepoIniFile(repoName)
2165 self.__iniFileChanged(cfgFile) 1940 self.__iniFileChanged(cfgFile)
2166 except OSError: 1941 except OSError:
2167 pass 1942 pass
2168 self.repoEditor = MiniEditor(cfgFile, "Properties") 1943 self.repoEditor = MiniEditor(cfgFile, "Properties")
2169 self.repoEditor.show() 1944 self.repoEditor.show()
2170 1945
2171 def hgVerify(self, name): 1946 def hgVerify(self):
2172 """ 1947 """
2173 Public method to verify the integrity of the repository. 1948 Public method to verify the integrity of the repository.
2174 1949 """
2175 @param name file/directory name (string)
2176 """
2177 dname, fname = self.splitPath(name)
2178
2179 # find the root of the repo
2180 repodir = dname
2181 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2182 repodir = os.path.dirname(repodir)
2183 if os.path.splitdrive(repodir)[1] == os.sep:
2184 return
2185
2186 args = self.initCommand("verify") 1950 args = self.initCommand("verify")
2187 1951
2188 dia = HgDialog( 1952 dia = HgDialog(
2189 self.tr('Verifying the integrity of the Mercurial repository'), 1953 self.tr('Verifying the integrity of the Mercurial repository'),
2190 self) 1954 self)
2191 res = dia.startProcess(args, repodir) 1955 res = dia.startProcess(args)
2192 if res: 1956 if res:
2193 dia.exec() 1957 dia.exec()
2194 1958
2195 def hgShowConfig(self, name): 1959 def hgShowConfig(self):
2196 """ 1960 """
2197 Public method to show the combined configuration. 1961 Public method to show the combined configuration.
2198 1962 """
2199 @param name file/directory name (string)
2200 """
2201 dname, fname = self.splitPath(name)
2202
2203 # find the root of the repo
2204 repodir = dname
2205 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2206 repodir = os.path.dirname(repodir)
2207 if os.path.splitdrive(repodir)[1] == os.sep:
2208 return
2209
2210 args = self.initCommand("showconfig") 1963 args = self.initCommand("showconfig")
2211 args.append("--untrusted") 1964 args.append("--untrusted")
2212 1965
2213 dia = HgDialog( 1966 dia = HgDialog(
2214 self.tr('Showing the combined configuration settings'), 1967 self.tr('Showing the combined configuration settings'),
2215 self) 1968 self)
2216 res = dia.startProcess(args, repodir, False) 1969 res = dia.startProcess(args, showArgs=False)
2217 if res: 1970 if res:
2218 dia.exec() 1971 dia.exec()
2219 1972
2220 def hgShowPaths(self, name): 1973 def hgShowPaths(self):
2221 """ 1974 """
2222 Public method to show the path aliases for remote repositories. 1975 Public method to show the path aliases for remote repositories.
2223 1976 """
2224 @param name file/directory name (string)
2225 """
2226 dname, fname = self.splitPath(name)
2227
2228 # find the root of the repo
2229 repodir = dname
2230 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2231 repodir = os.path.dirname(repodir)
2232 if os.path.splitdrive(repodir)[1] == os.sep:
2233 return
2234
2235 args = self.initCommand("paths") 1977 args = self.initCommand("paths")
2236 1978
2237 dia = HgDialog( 1979 dia = HgDialog(
2238 self.tr('Showing aliases for remote repositories'), 1980 self.tr('Showing aliases for remote repositories'),
2239 self) 1981 self)
2240 res = dia.startProcess(args, repodir, False) 1982 res = dia.startProcess(args, showArgs=False)
2241 if res: 1983 if res:
2242 dia.exec() 1984 dia.exec()
2243 1985
2244 def hgRecover(self, name): 1986 def hgRecover(self):
2245 """ 1987 """
2246 Public method to recover an interrupted transaction. 1988 Public method to recover an interrupted transaction.
2247 1989 """
2248 @param name file/directory name (string)
2249 """
2250 dname, fname = self.splitPath(name)
2251
2252 # find the root of the repo
2253 repodir = dname
2254 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2255 repodir = os.path.dirname(repodir)
2256 if os.path.splitdrive(repodir)[1] == os.sep:
2257 return
2258
2259 args = self.initCommand("recover") 1990 args = self.initCommand("recover")
2260 1991
2261 dia = HgDialog( 1992 dia = HgDialog(
2262 self.tr('Recovering from interrupted transaction'), 1993 self.tr('Recovering from interrupted transaction'),
2263 self) 1994 self)
2264 res = dia.startProcess(args, repodir, False) 1995 res = dia.startProcess(args, showArgs=False)
2265 if res: 1996 if res:
2266 dia.exec() 1997 dia.exec()
2267 1998
2268 def hgIdentify(self, name): 1999 def hgIdentify(self):
2269 """ 2000 """
2270 Public method to identify the current working directory. 2001 Public method to identify the current working directory.
2271 2002 """
2272 @param name file/directory name (string)
2273 """
2274 dname, fname = self.splitPath(name)
2275
2276 # find the root of the repo
2277 repodir = dname
2278 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2279 repodir = os.path.dirname(repodir)
2280 if os.path.splitdrive(repodir)[1] == os.sep:
2281 return
2282
2283 args = self.initCommand("identify") 2003 args = self.initCommand("identify")
2284 2004
2285 dia = HgDialog(self.tr('Identifying project directory'), self) 2005 dia = HgDialog(self.tr('Identifying project directory'), self)
2286 res = dia.startProcess(args, repodir, False) 2006 res = dia.startProcess(args, showArgs=False)
2287 if res: 2007 if res:
2288 dia.exec() 2008 dia.exec()
2289 2009
2290 def hgCreateIgnoreFile(self, name, autoAdd=False): 2010 def hgCreateIgnoreFile(self, name, autoAdd=False):
2291 """ 2011 """
2337 project = e5App().getObject("Project") 2057 project = e5App().getObject("Project")
2338 project.appendFile(ignoreName) 2058 project.appendFile(ignoreName)
2339 2059
2340 return status 2060 return status
2341 2061
2342 def hgBundle(self, name, bundleData=None): 2062 def hgBundle(self, bundleData=None):
2343 """ 2063 """
2344 Public method to create a changegroup file. 2064 Public method to create a changegroup file.
2345 2065
2346 @param name file/directory name
2347 @type str
2348 @param bundleData dictionary containing the bundle creation information 2066 @param bundleData dictionary containing the bundle creation information
2349 @type dict 2067 @type dict
2350 """ 2068 """
2351 dname, fname = self.splitPath(name)
2352
2353 # find the root of the repo
2354 repodir = dname
2355 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2356 repodir = os.path.dirname(repodir)
2357 if os.path.splitdrive(repodir)[1] == os.sep:
2358 return
2359
2360 if bundleData is None: 2069 if bundleData is None:
2361 from .HgBundleDialog import HgBundleDialog 2070 from .HgBundleDialog import HgBundleDialog
2362 dlg = HgBundleDialog(self.hgGetTagsList(repodir), 2071 dlg = HgBundleDialog(self.hgGetTagsList(),
2363 self.hgGetBranchesList(repodir), 2072 self.hgGetBranchesList(),
2364 self.hgGetBookmarksList(repodir), 2073 self.hgGetBookmarksList(),
2365 version=self.version) 2074 version=self.version)
2366 if dlg.exec() != QDialog.Accepted: 2075 if dlg.exec() != QDialog.Accepted:
2367 return 2076 return
2368 2077
2369 revs, baseRevs, compression, bundleAll = dlg.getParameters() 2078 revs, baseRevs, compression, bundleAll = dlg.getParameters()
2377 bundleAll = bundleData["all"] 2086 bundleAll = bundleData["all"]
2378 2087
2379 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 2088 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
2380 None, 2089 None,
2381 self.tr("Create changegroup"), 2090 self.tr("Create changegroup"),
2382 self.__lastChangeGroupPath or repodir, 2091 self.__lastChangeGroupPath,
2383 self.tr("Mercurial Changegroup Files (*.hg)"), 2092 self.tr("Mercurial Changegroup Files (*.hg)"),
2384 None, 2093 None,
2385 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 2094 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
2386 2095
2387 if not fname: 2096 if not fname:
2418 args.append("--type") 2127 args.append("--type")
2419 args.append(compression) 2128 args.append(compression)
2420 args.append(fname) 2129 args.append(fname)
2421 2130
2422 dia = HgDialog(self.tr('Create changegroup'), self) 2131 dia = HgDialog(self.tr('Create changegroup'), self)
2423 res = dia.startProcess(args, repodir) 2132 res = dia.startProcess(args)
2424 if res: 2133 if res:
2425 dia.exec() 2134 dia.exec()
2426 2135
2427 def hgPreviewBundle(self, name): 2136 def hgPreviewBundle(self):
2428 """ 2137 """
2429 Public method used to view the log of incoming changes from a 2138 Public method used to view the log of incoming changes from a
2430 changegroup file. 2139 changegroup file.
2431 2140 """
2432 @param name directory name on which to base the changegroup (string)
2433 """
2434 dname, fname = self.splitPath(name)
2435
2436 # find the root of the repo
2437 repodir = dname
2438 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2439 repodir = os.path.dirname(repodir)
2440 if os.path.splitdrive(repodir)[1] == os.sep:
2441 return
2442
2443 file = E5FileDialog.getOpenFileName( 2141 file = E5FileDialog.getOpenFileName(
2444 None, 2142 None,
2445 self.tr("Preview changegroup"), 2143 self.tr("Preview changegroup"),
2446 self.__lastChangeGroupPath or repodir, 2144 self.__lastChangeGroupPath,
2447 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)")) 2145 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)"))
2448 if file: 2146 if file:
2449 self.__lastChangeGroupPath = os.path.dirname(file) 2147 self.__lastChangeGroupPath = os.path.dirname(file)
2450 2148
2451 if self.logBrowserIncoming is None: 2149 if self.logBrowserIncoming is None:
2452 from .HgLogBrowserDialog import HgLogBrowserDialog 2150 from .HgLogBrowserDialog import HgLogBrowserDialog
2453 self.logBrowserIncoming = HgLogBrowserDialog( 2151 self.logBrowserIncoming = HgLogBrowserDialog(
2454 self, mode="incoming") 2152 self, mode="incoming")
2455 self.logBrowserIncoming.show() 2153 self.logBrowserIncoming.show()
2456 self.logBrowserIncoming.raise_() 2154 self.logBrowserIncoming.raise_()
2457 self.logBrowserIncoming.start(name, bundle=file) 2155 self.logBrowserIncoming.start(bundle=file)
2458 2156
2459 def hgUnbundle(self, name, files=None): 2157 def hgUnbundle(self, files=None):
2460 """ 2158 """
2461 Public method to apply changegroup files. 2159 Public method to apply changegroup files.
2462 2160
2463 @param name directory name
2464 @type str
2465 @param files list of bundle files to be applied 2161 @param files list of bundle files to be applied
2466 @type list of str 2162 @type list of str
2467 @return flag indicating, that the update contained an add 2163 @return flag indicating, that the update contained an add
2468 or delete 2164 or delete
2469 @rtype bool 2165 @rtype bool
2470 """ 2166 """
2471 dname, fname = self.splitPath(name)
2472
2473 # find the root of the repo
2474 repodir = dname
2475 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2476 repodir = os.path.dirname(repodir)
2477 if os.path.splitdrive(repodir)[1] == os.sep:
2478 return False
2479
2480 res = False 2167 res = False
2481 if not files: 2168 if not files:
2482 files = E5FileDialog.getOpenFileNames( 2169 files = E5FileDialog.getOpenFileNames(
2483 None, 2170 None,
2484 self.tr("Apply changegroups"), 2171 self.tr("Apply changegroups"),
2485 self.__lastChangeGroupPath or repodir, 2172 self.__lastChangeGroupPath,
2486 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)")) 2173 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)"))
2487 2174
2488 if files: 2175 if files:
2489 self.__lastChangeGroupPath = os.path.dirname(files[0]) 2176 self.__lastChangeGroupPath = os.path.dirname(files[0])
2490 2177
2499 args.append("--update") 2186 args.append("--update")
2500 args.append("--verbose") 2187 args.append("--verbose")
2501 args.extend(files) 2188 args.extend(files)
2502 2189
2503 dia = HgDialog(self.tr('Apply changegroups'), self) 2190 dia = HgDialog(self.tr('Apply changegroups'), self)
2504 res = dia.startProcess(args, repodir) 2191 res = dia.startProcess(args)
2505 if res: 2192 if res:
2506 dia.exec() 2193 dia.exec()
2507 res = dia.hasAddOrDelete() 2194 res = dia.hasAddOrDelete()
2508 self.checkVCSStatus() 2195 self.checkVCSStatus()
2509 2196
2510 return res 2197 return res
2511 2198
2512 def hgBisect(self, name, subcommand): 2199 def hgBisect(self, subcommand):
2513 """ 2200 """
2514 Public method to perform bisect commands. 2201 Public method to perform bisect commands.
2515 2202
2516 @param name file/directory name (string) 2203 @param subcommand name of the subcommand (one of 'good', 'bad',
2517 @param subcommand name of the subcommand (string, one of 'good', 'bad',
2518 'skip' or 'reset') 2204 'skip' or 'reset')
2205 @type str
2519 @exception ValueError raised to indicate an invalid bisect subcommand 2206 @exception ValueError raised to indicate an invalid bisect subcommand
2520 """ 2207 """
2521 if subcommand not in ("good", "bad", "skip", "reset"): 2208 if subcommand not in ("good", "bad", "skip", "reset"):
2522 raise ValueError( 2209 raise ValueError(
2523 self.tr("Bisect subcommand ({0}) invalid.") 2210 self.tr("Bisect subcommand ({0}) invalid.")
2524 .format(subcommand)) 2211 .format(subcommand))
2525 2212
2526 dname, fname = self.splitPath(name)
2527
2528 # find the root of the repo
2529 repodir = dname
2530 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2531 repodir = os.path.dirname(repodir)
2532 if os.path.splitdrive(repodir)[1] == os.sep:
2533 return
2534
2535 rev = "" 2213 rev = ""
2536 if subcommand in ("good", "bad", "skip"): 2214 if subcommand in ("good", "bad", "skip"):
2537 from .HgRevisionSelectionDialog import HgRevisionSelectionDialog 2215 from .HgRevisionSelectionDialog import HgRevisionSelectionDialog
2538 dlg = HgRevisionSelectionDialog(self.hgGetTagsList(repodir), 2216 dlg = HgRevisionSelectionDialog(self.hgGetTagsList(),
2539 self.hgGetBranchesList(repodir), 2217 self.hgGetBranchesList(),
2540 self.hgGetBookmarksList(repodir)) 2218 self.hgGetBookmarksList())
2541 if dlg.exec() == QDialog.Accepted: 2219 if dlg.exec() == QDialog.Accepted:
2542 rev = dlg.getRevision() 2220 rev = dlg.getRevision()
2543 else: 2221 else:
2544 return 2222 return
2545 2223
2548 if rev: 2226 if rev:
2549 args.append(rev) 2227 args.append(rev)
2550 2228
2551 dia = HgDialog( 2229 dia = HgDialog(
2552 self.tr('Mercurial Bisect ({0})').format(subcommand), self) 2230 self.tr('Mercurial Bisect ({0})').format(subcommand), self)
2553 res = dia.startProcess(args, repodir) 2231 res = dia.startProcess(args)
2554 if res: 2232 if res:
2555 dia.exec() 2233 dia.exec()
2556 2234
2557 def hgForget(self, name): 2235 def hgForget(self, name):
2558 """ 2236 """
2565 """ 2243 """
2566 args = self.initCommand("forget") 2244 args = self.initCommand("forget")
2567 args.append('-v') 2245 args.append('-v')
2568 2246
2569 if isinstance(name, list): 2247 if isinstance(name, list):
2570 dname, fnames = self.splitPathList(name)
2571 self.addArguments(args, name) 2248 self.addArguments(args, name)
2572 else: 2249 else:
2573 dname, fname = self.splitPath(name)
2574 args.append(name) 2250 args.append(name)
2575
2576 # find the root of the repo
2577 repodir = dname
2578 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2579 repodir = os.path.dirname(repodir)
2580 if os.path.splitdrive(repodir)[1] == os.sep:
2581 return
2582 2251
2583 dia = HgDialog( 2252 dia = HgDialog(
2584 self.tr('Removing files from the Mercurial repository only'), 2253 self.tr('Removing files from the Mercurial repository only'),
2585 self) 2254 self)
2586 res = dia.startProcess(args, repodir) 2255 res = dia.startProcess(args)
2587 if res: 2256 if res:
2588 dia.exec() 2257 dia.exec()
2589 if isinstance(name, list): 2258 if isinstance(name, list):
2590 self.__forgotNames.extend(name) 2259 self.__forgotNames.extend(name)
2591 else: 2260 else:
2592 self.__forgotNames.append(name) 2261 self.__forgotNames.append(name)
2593 2262
2594 def hgBackout(self, name): 2263 def hgBackout(self):
2595 """ 2264 """
2596 Public method used to backout an earlier changeset from the Mercurial 2265 Public method used to backout an earlier changeset from the Mercurial
2597 repository. 2266 repository.
2598 2267 """
2599 @param name directory name (string or list of strings)
2600 """
2601 dname, fname = self.splitPath(name)
2602
2603 # find the root of the repo
2604 repodir = dname
2605 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2606 repodir = os.path.dirname(repodir)
2607 if os.path.splitdrive(repodir)[1] == os.sep:
2608 return
2609
2610 from .HgBackoutDialog import HgBackoutDialog 2268 from .HgBackoutDialog import HgBackoutDialog
2611 dlg = HgBackoutDialog(self.hgGetTagsList(repodir), 2269 dlg = HgBackoutDialog(self.hgGetTagsList(),
2612 self.hgGetBranchesList(repodir), 2270 self.hgGetBranchesList(),
2613 self.hgGetBookmarksList(repodir)) 2271 self.hgGetBookmarksList())
2614 if dlg.exec() == QDialog.Accepted: 2272 if dlg.exec() == QDialog.Accepted:
2615 rev, merge, date, user, message = dlg.getParameters() 2273 rev, merge, date, user, message = dlg.getParameters()
2616 if not rev: 2274 if not rev:
2617 E5MessageBox.warning( 2275 E5MessageBox.warning(
2618 self.__ui, 2276 self.__ui,
2633 args.append('--message') 2291 args.append('--message')
2634 args.append(message) 2292 args.append(message)
2635 args.append(rev) 2293 args.append(rev)
2636 2294
2637 dia = HgDialog(self.tr('Backing out changeset'), self) 2295 dia = HgDialog(self.tr('Backing out changeset'), self)
2638 res = dia.startProcess(args, repodir) 2296 res = dia.startProcess(args)
2639 if res: 2297 if res:
2640 dia.exec() 2298 dia.exec()
2641 2299
2642 def hgRollback(self, name): 2300 def hgRollback(self):
2643 """ 2301 """
2644 Public method used to rollback the last transaction. 2302 Public method used to rollback the last transaction.
2645 2303 """
2646 @param name directory name (string or list of strings)
2647 """
2648 dname, fname = self.splitPath(name)
2649
2650 # find the root of the repo
2651 repodir = dname
2652 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2653 repodir = os.path.dirname(repodir)
2654 if os.path.splitdrive(repodir)[1] == os.sep:
2655 return
2656
2657 res = E5MessageBox.yesNo( 2304 res = E5MessageBox.yesNo(
2658 None, 2305 None,
2659 self.tr("Rollback last transaction"), 2306 self.tr("Rollback last transaction"),
2660 self.tr("""Are you sure you want to rollback the last""" 2307 self.tr("""Are you sure you want to rollback the last"""
2661 """ transaction?"""), 2308 """ transaction?"""),
2662 icon=E5MessageBox.Warning) 2309 icon=E5MessageBox.Warning)
2663 if res: 2310 if res:
2664 dia = HgDialog(self.tr('Rollback last transaction'), self) 2311 dia = HgDialog(self.tr('Rollback last transaction'), self)
2665 res = dia.startProcess(["rollback"], repodir) 2312 res = dia.startProcess(["rollback"])
2666 if res: 2313 if res:
2667 dia.exec() 2314 dia.exec()
2668 2315
2669 def hgServe(self, name): 2316 def hgServe(self, repoPath):
2670 """ 2317 """
2671 Public method used to serve the project. 2318 Public method used to serve the project.
2672 2319
2673 @param name directory name (string) 2320 @param repoPath directory containing the repository
2674 """ 2321 @type str
2675 dname, fname = self.splitPath(name) 2322 """
2676
2677 # find the root of the repo
2678 repodir = dname
2679 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2680 repodir = os.path.dirname(repodir)
2681 if os.path.splitdrive(repodir)[1] == os.sep:
2682 return
2683
2684 from .HgServeDialog import HgServeDialog 2323 from .HgServeDialog import HgServeDialog
2685 self.serveDlg = HgServeDialog(self, repodir) 2324 self.serveDlg = HgServeDialog(self, repoPath)
2686 self.serveDlg.show() 2325 self.serveDlg.show()
2687 2326
2688 def hgImport(self, name): 2327 def hgImport(self):
2689 """ 2328 """
2690 Public method to import a patch file. 2329 Public method to import a patch file.
2691 2330
2692 @param name directory name of the project to import into (string)
2693 @return flag indicating, that the import contained an add, a delete 2331 @return flag indicating, that the import contained an add, a delete
2694 or a change to the project file (boolean) 2332 or a change to the project file (boolean)
2695 """ 2333 """
2696 dname, fname = self.splitPath(name)
2697
2698 # find the root of the repo
2699 repodir = dname
2700 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2701 repodir = os.path.dirname(repodir)
2702 if os.path.splitdrive(repodir)[1] == os.sep:
2703 return False
2704
2705 from .HgImportDialog import HgImportDialog 2334 from .HgImportDialog import HgImportDialog
2706 dlg = HgImportDialog(self) 2335 dlg = HgImportDialog(self)
2707 if dlg.exec() == QDialog.Accepted: 2336 if dlg.exec() == QDialog.Accepted:
2708 (patchFile, noCommit, message, date, user, withSecret, stripCount, 2337 (patchFile, noCommit, message, date, user, withSecret, stripCount,
2709 force) = dlg.getParameters() 2338 force) = dlg.getParameters()
2730 if withSecret: 2359 if withSecret:
2731 args.append("--secret") 2360 args.append("--secret")
2732 args.append(patchFile) 2361 args.append(patchFile)
2733 2362
2734 dia = HgDialog(self.tr("Import Patch"), self) 2363 dia = HgDialog(self.tr("Import Patch"), self)
2735 res = dia.startProcess(args, repodir) 2364 res = dia.startProcess(args)
2736 if res: 2365 if res:
2737 dia.exec() 2366 dia.exec()
2738 res = dia.hasAddOrDelete() 2367 res = dia.hasAddOrDelete()
2739 self.checkVCSStatus() 2368 self.checkVCSStatus()
2740 else: 2369 else:
2741 res = False 2370 res = False
2742 2371
2743 return res 2372 return res
2744 2373
2745 def hgExport(self, name): 2374 def hgExport(self):
2746 """ 2375 """
2747 Public method to export patches to files. 2376 Public method to export patches to files.
2748 2377 """
2749 @param name directory name of the project to export from (string)
2750 """
2751 dname, fname = self.splitPath(name)
2752
2753 # find the root of the repo
2754 repodir = dname
2755 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2756 repodir = os.path.dirname(repodir)
2757 if os.path.splitdrive(repodir)[1] == os.sep:
2758 return
2759
2760 from .HgExportDialog import HgExportDialog 2378 from .HgExportDialog import HgExportDialog
2761 dlg = HgExportDialog(self.hgGetBookmarksList(repodir), 2379 dlg = HgExportDialog(self.hgGetBookmarksList(),
2762 self.version >= (4, 7, 0)) 2380 self.version >= (4, 7, 0))
2763 if dlg.exec() == QDialog.Accepted: 2381 if dlg.exec() == QDialog.Accepted:
2764 (filePattern, revisions, bookmark, switchParent, allText, 2382 (filePattern, revisions, bookmark, switchParent, allText,
2765 noDates, git) = dlg.getParameters() 2383 noDates, git) = dlg.getParameters()
2766 2384
2782 else: 2400 else:
2783 for rev in revisions: 2401 for rev in revisions:
2784 args.append(rev) 2402 args.append(rev)
2785 2403
2786 dia = HgDialog(self.tr("Export Patches"), self) 2404 dia = HgDialog(self.tr("Export Patches"), self)
2787 res = dia.startProcess(args, repodir) 2405 res = dia.startProcess(args)
2788 if res: 2406 if res:
2789 dia.exec() 2407 dia.exec()
2790 2408
2791 def hgPhase(self, name, data=None): 2409 def hgPhase(self, data=None):
2792 """ 2410 """
2793 Public method to change the phase of revisions. 2411 Public method to change the phase of revisions.
2794 2412
2795 @param name directory name of the project to export from (string)
2796 @param data tuple giving phase data (list of revisions, phase, flag 2413 @param data tuple giving phase data (list of revisions, phase, flag
2797 indicating a forced operation) (list of strings, string, boolean) 2414 indicating a forced operation) (list of strings, string, boolean)
2798 @return flag indicating success (boolean) 2415 @return flag indicating success (boolean)
2799 @exception ValueError raised to indicate an invalid phase 2416 @exception ValueError raised to indicate an invalid phase
2800 """ 2417 """
2801 dname, fname = self.splitPath(name)
2802
2803 # find the root of the repo
2804 repodir = dname
2805 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2806 repodir = os.path.dirname(repodir)
2807 if os.path.splitdrive(repodir)[1] == os.sep:
2808 return False
2809
2810 if data is None: 2418 if data is None:
2811 from .HgPhaseDialog import HgPhaseDialog 2419 from .HgPhaseDialog import HgPhaseDialog
2812 dlg = HgPhaseDialog() 2420 dlg = HgPhaseDialog()
2813 if dlg.exec() == QDialog.Accepted: 2421 if dlg.exec() == QDialog.Accepted:
2814 data = dlg.getData() 2422 data = dlg.getData()
2829 args.append("--force") 2437 args.append("--force")
2830 for rev in revs: 2438 for rev in revs:
2831 args.append(rev) 2439 args.append(rev)
2832 2440
2833 dia = HgDialog(self.tr("Change Phase"), self) 2441 dia = HgDialog(self.tr("Change Phase"), self)
2834 res = dia.startProcess(args, repodir) 2442 res = dia.startProcess(args)
2835 if res: 2443 if res:
2836 dia.exec() 2444 dia.exec()
2837 res = dia.normalExitWithoutErrors() 2445 res = dia.normalExitWithoutErrors()
2838 else: 2446 else:
2839 res = False 2447 res = False
2840 2448
2841 return res 2449 return res
2842 2450
2843 def hgGraft(self, path, revs=None): 2451 def hgGraft(self, revs=None):
2844 """ 2452 """
2845 Public method to copy changesets from another branch. 2453 Public method to copy changesets from another branch.
2846 2454
2847 @param path directory name of the project (string)
2848 @param revs list of revisions to show in the revisions pane (list of 2455 @param revs list of revisions to show in the revisions pane (list of
2849 strings) 2456 strings)
2850 @return flag indicating that the project should be reread (boolean) 2457 @return flag indicating that the project should be reread (boolean)
2851 """ 2458 """
2852 # find the root of the repo
2853 repodir = self.splitPath(path)[0]
2854 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2855 repodir = os.path.dirname(repodir)
2856 if os.path.splitdrive(repodir)[1] == os.sep:
2857 return False
2858
2859 from .HgGraftDialog import HgGraftDialog 2459 from .HgGraftDialog import HgGraftDialog
2860 res = False 2460 res = False
2861 dlg = HgGraftDialog(self, revs) 2461 dlg = HgGraftDialog(self, revs)
2862 if dlg.exec() == QDialog.Accepted: 2462 if dlg.exec() == QDialog.Accepted:
2863 (revs, 2463 (revs,
2886 if noCommit: 2486 if noCommit:
2887 args.append("--no-commit") 2487 args.append("--no-commit")
2888 args.extend(revs) 2488 args.extend(revs)
2889 2489
2890 dia = HgDialog(self.tr('Copy Changesets'), self) 2490 dia = HgDialog(self.tr('Copy Changesets'), self)
2891 res = dia.startProcess(args, repodir) 2491 res = dia.startProcess(args)
2892 if res: 2492 if res:
2893 dia.exec() 2493 dia.exec()
2894 res = dia.hasAddOrDelete() 2494 res = dia.hasAddOrDelete()
2895 self.checkVCSStatus() 2495 self.checkVCSStatus()
2896 return res 2496 return res
2897 2497
2898 def __hgGraftSubCommand(self, path, subcommand, title): 2498 def __hgGraftSubCommand(self, subcommand, title):
2899 """ 2499 """
2900 Private method to perform a Mercurial graft subcommand. 2500 Private method to perform a Mercurial graft subcommand.
2901 2501
2902 @param path directory name of the project
2903 @type str
2904 @param subcommand subcommand flag 2502 @param subcommand subcommand flag
2905 @type str 2503 @type str
2906 @param title tirle of the dialog 2504 @param title tirle of the dialog
2907 @type str 2505 @type str
2908 @return flag indicating that the project should be reread 2506 @return flag indicating that the project should be reread
2909 @rtype bool 2507 @rtype bool
2910 """ 2508 """
2911 # find the root of the repo
2912 repodir = self.splitPath(path)[0]
2913 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2914 repodir = os.path.dirname(repodir)
2915 if os.path.splitdrive(repodir)[1] == os.sep:
2916 return False
2917
2918 args = self.initCommand("graft") 2509 args = self.initCommand("graft")
2919 args.append(subcommand) 2510 args.append(subcommand)
2920 args.append("--verbose") 2511 args.append("--verbose")
2921 2512
2922 dia = HgDialog(title, self) 2513 dia = HgDialog(title, self)
2923 res = dia.startProcess(args, repodir) 2514 res = dia.startProcess(args)
2924 if res: 2515 if res:
2925 dia.exec() 2516 dia.exec()
2926 res = dia.hasAddOrDelete() 2517 res = dia.hasAddOrDelete()
2927 self.checkVCSStatus() 2518 self.checkVCSStatus()
2928 return res 2519 return res
2935 @type str 2526 @type str
2936 @return flag indicating that the project should be reread 2527 @return flag indicating that the project should be reread
2937 @rtype bool 2528 @rtype bool
2938 """ 2529 """
2939 return self.__hgGraftSubCommand( 2530 return self.__hgGraftSubCommand(
2940 path, "--continue", self.tr('Copy Changesets (Continue)')) 2531 "--continue", self.tr('Copy Changesets (Continue)'))
2941 2532
2942 def hgGraftStop(self, path): 2533 def hgGraftStop(self, path):
2943 """ 2534 """
2944 Public method to stop an interrupted copying session. 2535 Public method to stop an interrupted copying session.
2945 2536
2947 @type str 2538 @type str
2948 @return flag indicating that the project should be reread 2539 @return flag indicating that the project should be reread
2949 @rtype bool 2540 @rtype bool
2950 """ 2541 """
2951 return self.__hgGraftSubCommand( 2542 return self.__hgGraftSubCommand(
2952 path, "--stop", self.tr('Copy Changesets (Stop)')) 2543 "--stop", self.tr('Copy Changesets (Stop)'))
2953 2544
2954 def hgGraftAbort(self, path): 2545 def hgGraftAbort(self, path):
2955 """ 2546 """
2956 Public method to abort an interrupted copying session and perform 2547 Public method to abort an interrupted copying session and perform
2957 a rollback. 2548 a rollback.
2960 @type str 2551 @type str
2961 @return flag indicating that the project should be reread 2552 @return flag indicating that the project should be reread
2962 @rtype bool 2553 @rtype bool
2963 """ 2554 """
2964 return self.__hgGraftSubCommand( 2555 return self.__hgGraftSubCommand(
2965 path, "--abort", self.tr('Copy Changesets (Abort)')) 2556 "--abort", self.tr('Copy Changesets (Abort)'))
2966 2557
2967 def hgArchive(self): 2558 def hgArchive(self):
2968 """ 2559 """
2969 Public method to create an unversioned archive from the repository. 2560 Public method to create an unversioned archive from the repository.
2970 """ 2561 """
2971 # find the root of the repo
2972 repodir = self.__projectHelper.getProject().getProjectPath()
2973 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2974 repodir = os.path.dirname(repodir)
2975 if os.path.splitdrive(repodir)[1] == os.sep:
2976 return
2977
2978 from .HgArchiveDialog import HgArchiveDialog 2562 from .HgArchiveDialog import HgArchiveDialog
2979 dlg = HgArchiveDialog(self) 2563 dlg = HgArchiveDialog(self)
2980 if dlg.exec() == QDialog.Accepted: 2564 if dlg.exec() == QDialog.Accepted:
2981 archive, type_, prefix, subrepos = dlg.getData() 2565 archive, type_, prefix, subrepos = dlg.getData()
2982 2566
2990 if subrepos: 2574 if subrepos:
2991 args.append("--subrepos") 2575 args.append("--subrepos")
2992 args.append(archive) 2576 args.append(archive)
2993 2577
2994 dia = HgDialog(self.tr("Create Unversioned Archive"), self) 2578 dia = HgDialog(self.tr("Create Unversioned Archive"), self)
2995 res = dia.startProcess(args, repodir) 2579 res = dia.startProcess(args)
2996 if res: 2580 if res:
2997 dia.exec() 2581 dia.exec()
2998 2582
2999 def hgDeleteBackups(self): 2583 def hgDeleteBackups(self):
3000 """ 2584 """
3001 Public method to delete all backup bundles in the backup area. 2585 Public method to delete all backup bundles in the backup area.
3002 """ 2586 """
3003 # find the root of the repo 2587 backupdir = os.path.join(self.getClient().getRepository(),
3004 repodir = self.__projectHelper.getProject().getProjectPath() 2588 self.adminDir, "strip-backup")
3005 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3006 repodir = os.path.dirname(repodir)
3007 if os.path.splitdrive(repodir)[1] == os.sep:
3008 return
3009
3010 backupdir = os.path.join(repodir, self.adminDir, "strip-backup")
3011 yes = E5MessageBox.yesNo( 2589 yes = E5MessageBox.yesNo(
3012 self.__ui, 2590 self.__ui,
3013 self.tr("Delete All Backups"), 2591 self.tr("Delete All Backups"),
3014 self.tr("""<p>Do you really want to delete all backup bundles""" 2592 self.tr("""<p>Do you really want to delete all backup bundles"""
3015 """ stored the backup area <b>{0}</b>?</p>""").format( 2593 """ stored the backup area <b>{0}</b>?</p>""").format(
3016 backupdir)) 2594 backupdir))
3017 if yes: 2595 if yes:
3018 shutil.rmtree(backupdir, True) 2596 shutil.rmtree(backupdir, True)
3019 2597
3020 ########################################################################### 2598 ###########################################################################
3021 ## Methods to deal with subrepositories are below. 2599 ## Methods to deal with sub-repositories are below.
3022 ########################################################################### 2600 ###########################################################################
3023 2601
3024 def getHgSubPath(self): 2602 def getHgSubPath(self):
3025 """ 2603 """
3026 Public method to get the path to the .hgsub file containing the 2604 Public method to get the path to the .hgsub file containing the
3187 line.startswith("paths.default-push=") and 2765 line.startswith("paths.default-push=") and
3188 not line.endswith("=") 2766 not line.endswith("=")
3189 ): 2767 ):
3190 self.__defaultPushConfigured = True 2768 self.__defaultPushConfigured = True
3191 2769
3192 def canCommitMerge(self, name): 2770 def canCommitMerge(self):
3193 """ 2771 """
3194 Public method to check, if the working directory is an uncommitted 2772 Public method to check, if the working directory is an uncommitted
3195 merge. 2773 merge.
3196 2774
3197 @param name file/directory name
3198 @type str
3199 @return flag indicating commit merge capability 2775 @return flag indicating commit merge capability
3200 @rtype bool 2776 @rtype bool
3201 """ 2777 """
3202 dname, fname = self.splitPath(name)
3203
3204 # find the root of the repo
3205 repodir = dname
3206 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3207 repodir = os.path.dirname(repodir)
3208 if os.path.splitdrive(repodir)[1] == os.sep:
3209 return False
3210
3211 args = self.initCommand("identify") 2778 args = self.initCommand("identify")
3212 2779
3213 output, error = self.__client.runcommand(args) 2780 output, error = self.__client.runcommand(args)
3214 2781
3215 return output.count('+') == 2 2782 return output.count('+') == 2
3251 if self.__repoIniFile and path == self.__repoIniFile: 2818 if self.__repoIniFile and path == self.__repoIniFile:
3252 self.__checkDefaults() 2819 self.__checkDefaults()
3253 2820
3254 self.iniFileChanged.emit() 2821 self.iniFileChanged.emit()
3255 2822
3256 def __monitorRepoIniFile(self, name): 2823 def __monitorRepoIniFile(self, repodir):
3257 """ 2824 """
3258 Private slot to add a repository configuration file to the list of 2825 Private slot to add a repository configuration file to the list of
3259 monitored files. 2826 monitored files.
3260 2827
3261 @param name directory name pointing into the repository (string) 2828 @param repodir directory name of the repository
3262 """ 2829 @type str
3263 dname, fname = self.splitPath(name) 2830 """
3264
3265 # find the root of the repo
3266 repodir = dname
3267 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3268 repodir = os.path.dirname(repodir)
3269 if not repodir or os.path.splitdrive(repodir)[1] == os.sep:
3270 return
3271
3272 cfgFile = os.path.join(repodir, self.adminDir, "hgrc") 2831 cfgFile = os.path.join(repodir, self.adminDir, "hgrc")
3273 if os.path.exists(cfgFile): 2832 if os.path.exists(cfgFile):
3274 self.__iniWatcher.addPath(cfgFile) 2833 self.__iniWatcher.addPath(cfgFile)
3275 self.__repoIniFile = cfgFile 2834 self.__repoIniFile = cfgFile
3276 self.__checkDefaults() 2835 self.__checkDefaults()
3410 if self.__client is not None: 2969 if self.__client is not None:
3411 self.__client.stopServer() 2970 self.__client.stopServer()
3412 self.__client = None 2971 self.__client = None
3413 2972
3414 ########################################################################### 2973 ###########################################################################
3415 ## Status Monitor Thread methods 2974 ## Status Monitor Thread methods
3416 ########################################################################### 2975 ###########################################################################
3417 2976
3418 def _createStatusMonitorThread(self, interval, project): 2977 def _createStatusMonitorThread(self, interval, project):
3419 """ 2978 """
3420 Protected method to create an instance of the VCS status monitor 2979 Protected method to create an instance of the VCS status monitor
3427 """ 2986 """
3428 from .HgStatusMonitorThread import HgStatusMonitorThread 2987 from .HgStatusMonitorThread import HgStatusMonitorThread
3429 return HgStatusMonitorThread(interval, project, self) 2988 return HgStatusMonitorThread(interval, project, self)
3430 2989
3431 ########################################################################### 2990 ###########################################################################
3432 ## Bookmarks methods 2991 ## Bookmarks methods
3433 ########################################################################### 2992 ###########################################################################
3434 2993
3435 def hgListBookmarks(self, path): 2994 def hgListBookmarks(self):
3436 """ 2995 """
3437 Public method used to list the available bookmarks. 2996 Public method used to list the available bookmarks.
3438
3439 @param path directory name of the project (string)
3440 """ 2997 """
3441 self.bookmarksList = [] 2998 self.bookmarksList = []
3442 2999
3443 if self.bookmarksListDlg is None: 3000 if self.bookmarksListDlg is None:
3444 from .HgBookmarksListDialog import HgBookmarksListDialog 3001 from .HgBookmarksListDialog import HgBookmarksListDialog
3445 self.bookmarksListDlg = HgBookmarksListDialog(self) 3002 self.bookmarksListDlg = HgBookmarksListDialog(self)
3446 self.bookmarksListDlg.show() 3003 self.bookmarksListDlg.show()
3447 self.bookmarksListDlg.raise_() 3004 self.bookmarksListDlg.raise_()
3448 self.bookmarksListDlg.start(path, self.bookmarksList) 3005 self.bookmarksListDlg.start(self.bookmarksList)
3449 3006
3450 def hgGetBookmarksList(self, repodir): 3007 def hgGetBookmarksList(self):
3451 """ 3008 """
3452 Public method to get the list of bookmarks. 3009 Public method to get the list of bookmarks.
3453 3010
3454 @param repodir directory name of the repository (string)
3455 @return list of bookmarks (list of string) 3011 @return list of bookmarks (list of string)
3456 """ 3012 """
3457 args = self.initCommand("bookmarks") 3013 args = self.initCommand("bookmarks")
3458 3014
3459 client = self.getClient() 3015 client = self.getClient()
3470 name = " ".join(li) 3026 name = " ".join(li)
3471 self.bookmarksList.append(name) 3027 self.bookmarksList.append(name)
3472 3028
3473 return self.bookmarksList[:] 3029 return self.bookmarksList[:]
3474 3030
3475 def hgBookmarkDefine(self, name, revision=None, bookmark=None): 3031 def hgBookmarkDefine(self, revision=None, bookmark=None):
3476 """ 3032 """
3477 Public method to define a bookmark. 3033 Public method to define a bookmark.
3478 3034
3479 @param name file/directory name (string)
3480 @param revision revision to set bookmark for (string) 3035 @param revision revision to set bookmark for (string)
3481 @param bookmark name of the bookmark (string) 3036 @param bookmark name of the bookmark (string)
3482 """ 3037 """
3483 # find the root of the repo
3484 repodir = self.splitPath(name)[0]
3485 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3486 repodir = os.path.dirname(repodir)
3487 if os.path.splitdrive(repodir)[1] == os.sep:
3488 return
3489
3490 if bool(revision) and bool(bookmark): 3038 if bool(revision) and bool(bookmark):
3491 ok = True 3039 ok = True
3492 else: 3040 else:
3493 from .HgBookmarkDialog import HgBookmarkDialog 3041 from .HgBookmarkDialog import HgBookmarkDialog
3494 dlg = HgBookmarkDialog(HgBookmarkDialog.DEFINE_MODE, 3042 dlg = HgBookmarkDialog(HgBookmarkDialog.DEFINE_MODE,
3495 self.hgGetTagsList(repodir), 3043 self.hgGetTagsList(),
3496 self.hgGetBranchesList(repodir), 3044 self.hgGetBranchesList(),
3497 self.hgGetBookmarksList(repodir)) 3045 self.hgGetBookmarksList())
3498 if dlg.exec() == QDialog.Accepted: 3046 if dlg.exec() == QDialog.Accepted:
3499 revision, bookmark = dlg.getData() 3047 revision, bookmark = dlg.getData()
3500 ok = True 3048 ok = True
3501 else: 3049 else:
3502 ok = False 3050 ok = False
3507 args.append("--rev") 3055 args.append("--rev")
3508 args.append(revision) 3056 args.append(revision)
3509 args.append(bookmark) 3057 args.append(bookmark)
3510 3058
3511 dia = HgDialog(self.tr('Mercurial Bookmark'), self) 3059 dia = HgDialog(self.tr('Mercurial Bookmark'), self)
3512 res = dia.startProcess(args, repodir) 3060 res = dia.startProcess(args)
3513 if res: 3061 if res:
3514 dia.exec() 3062 dia.exec()
3515 3063
3516 def hgBookmarkDelete(self, name, bookmark=None): 3064 def hgBookmarkDelete(self, bookmark=None):
3517 """ 3065 """
3518 Public method to delete a bookmark. 3066 Public method to delete a bookmark.
3519 3067
3520 @param name file/directory name (string)
3521 @param bookmark name of the bookmark (string) 3068 @param bookmark name of the bookmark (string)
3522 """ 3069 """
3523 # find the root of the repo
3524 repodir = self.splitPath(name)[0]
3525 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3526 repodir = os.path.dirname(repodir)
3527 if os.path.splitdrive(repodir)[1] == os.sep:
3528 return
3529
3530 if bookmark: 3070 if bookmark:
3531 ok = True 3071 ok = True
3532 else: 3072 else:
3533 bookmark, ok = QInputDialog.getItem( 3073 bookmark, ok = QInputDialog.getItem(
3534 None, 3074 None,
3535 self.tr("Delete Bookmark"), 3075 self.tr("Delete Bookmark"),
3536 self.tr("Select the bookmark to be deleted:"), 3076 self.tr("Select the bookmark to be deleted:"),
3537 [""] + sorted(self.hgGetBookmarksList(repodir)), 3077 [""] + sorted(self.hgGetBookmarksList()),
3538 0, True) 3078 0, True)
3539 if ok and bookmark: 3079 if ok and bookmark:
3540 args = self.initCommand("bookmarks") 3080 args = self.initCommand("bookmarks")
3541 args.append("--delete") 3081 args.append("--delete")
3542 args.append(bookmark) 3082 args.append(bookmark)
3543 3083
3544 dia = HgDialog(self.tr('Delete Mercurial Bookmark'), self) 3084 dia = HgDialog(self.tr('Delete Mercurial Bookmark'), self)
3545 res = dia.startProcess(args, repodir) 3085 res = dia.startProcess(args)
3546 if res: 3086 if res:
3547 dia.exec() 3087 dia.exec()
3548 3088
3549 def hgBookmarkRename(self, name, renameInfo=None): 3089 def hgBookmarkRename(self, renameInfo=None):
3550 """ 3090 """
3551 Public method to rename a bookmark. 3091 Public method to rename a bookmark.
3552 3092
3553 @param name file/directory name
3554 @type str
3555 @param renameInfo old and new names of the bookmark 3093 @param renameInfo old and new names of the bookmark
3556 @type tuple of str and str 3094 @type tuple of str and str
3557 """ 3095 """
3558 # find the root of the repo
3559 repodir = self.splitPath(name)[0]
3560 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3561 repodir = os.path.dirname(repodir)
3562 if os.path.splitdrive(repodir)[1] == os.sep:
3563 return
3564
3565 if not renameInfo: 3096 if not renameInfo:
3566 from .HgBookmarkRenameDialog import HgBookmarkRenameDialog 3097 from .HgBookmarkRenameDialog import HgBookmarkRenameDialog
3567 dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList(repodir)) 3098 dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList())
3568 if dlg.exec() == QDialog.Accepted: 3099 if dlg.exec() == QDialog.Accepted:
3569 renameInfo = dlg.getData() 3100 renameInfo = dlg.getData()
3570 3101
3571 if renameInfo: 3102 if renameInfo:
3572 args = self.initCommand("bookmarks") 3103 args = self.initCommand("bookmarks")
3573 args.append("--rename") 3104 args.append("--rename")
3574 args.append(renameInfo[0]) 3105 args.append(renameInfo[0])
3575 args.append(renameInfo[1]) 3106 args.append(renameInfo[1])
3576 3107
3577 dia = HgDialog(self.tr('Rename Mercurial Bookmark'), self) 3108 dia = HgDialog(self.tr('Rename Mercurial Bookmark'), self)
3578 res = dia.startProcess(args, repodir) 3109 res = dia.startProcess(args)
3579 if res: 3110 if res:
3580 dia.exec() 3111 dia.exec()
3581 3112
3582 def hgBookmarkMove(self, name, revision=None, bookmark=None): 3113 def hgBookmarkMove(self, revision=None, bookmark=None):
3583 """ 3114 """
3584 Public method to move a bookmark. 3115 Public method to move a bookmark.
3585 3116
3586 @param name file/directory name (string)
3587 @param revision revision to set bookmark for (string) 3117 @param revision revision to set bookmark for (string)
3588 @param bookmark name of the bookmark (string) 3118 @param bookmark name of the bookmark (string)
3589 """ 3119 """
3590 # find the root of the repo
3591 repodir = self.splitPath(name)[0]
3592 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3593 repodir = os.path.dirname(repodir)
3594 if os.path.splitdrive(repodir)[1] == os.sep:
3595 return
3596
3597 if bool(revision) and bool(bookmark): 3120 if bool(revision) and bool(bookmark):
3598 ok = True 3121 ok = True
3599 else: 3122 else:
3600 from .HgBookmarkDialog import HgBookmarkDialog 3123 from .HgBookmarkDialog import HgBookmarkDialog
3601 dlg = HgBookmarkDialog(HgBookmarkDialog.MOVE_MODE, 3124 dlg = HgBookmarkDialog(HgBookmarkDialog.MOVE_MODE,
3602 self.hgGetTagsList(repodir), 3125 self.hgGetTagsList(),
3603 self.hgGetBranchesList(repodir), 3126 self.hgGetBranchesList(),
3604 self.hgGetBookmarksList(repodir)) 3127 self.hgGetBookmarksList())
3605 if dlg.exec() == QDialog.Accepted: 3128 if dlg.exec() == QDialog.Accepted:
3606 revision, bookmark = dlg.getData() 3129 revision, bookmark = dlg.getData()
3607 ok = True 3130 ok = True
3608 else: 3131 else:
3609 ok = False 3132 ok = False
3615 args.append("--rev") 3138 args.append("--rev")
3616 args.append(revision) 3139 args.append(revision)
3617 args.append(bookmark) 3140 args.append(bookmark)
3618 3141
3619 dia = HgDialog(self.tr('Move Mercurial Bookmark'), self) 3142 dia = HgDialog(self.tr('Move Mercurial Bookmark'), self)
3620 res = dia.startProcess(args, repodir) 3143 res = dia.startProcess(args)
3621 if res: 3144 if res:
3622 dia.exec() 3145 dia.exec()
3623 3146
3624 def hgBookmarkIncoming(self, name): 3147 def hgBookmarkIncoming(self):
3625 """ 3148 """
3626 Public method to show a list of incoming bookmarks. 3149 Public method to show a list of incoming bookmarks.
3627
3628 @param name file/directory name (string)
3629 """ 3150 """
3630 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog 3151 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog
3631 self.bookmarksInOutDlg = HgBookmarksInOutDialog( 3152 self.bookmarksInOutDlg = HgBookmarksInOutDialog(
3632 self, HgBookmarksInOutDialog.INCOMING) 3153 self, HgBookmarksInOutDialog.INCOMING)
3633 self.bookmarksInOutDlg.show() 3154 self.bookmarksInOutDlg.show()
3634 self.bookmarksInOutDlg.start(name) 3155 self.bookmarksInOutDlg.start()
3635 3156
3636 def hgBookmarkOutgoing(self, name): 3157 def hgBookmarkOutgoing(self):
3637 """ 3158 """
3638 Public method to show a list of outgoing bookmarks. 3159 Public method to show a list of outgoing bookmarks.
3639
3640 @param name file/directory name (string)
3641 """ 3160 """
3642 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog 3161 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog
3643 self.bookmarksInOutDlg = HgBookmarksInOutDialog( 3162 self.bookmarksInOutDlg = HgBookmarksInOutDialog(
3644 self, HgBookmarksInOutDialog.OUTGOING) 3163 self, HgBookmarksInOutDialog.OUTGOING)
3645 self.bookmarksInOutDlg.show() 3164 self.bookmarksInOutDlg.show()
3646 self.bookmarksInOutDlg.start(name) 3165 self.bookmarksInOutDlg.start()
3647 3166
3648 def __getInOutBookmarks(self, repodir, incoming): 3167 def __getInOutBookmarks(self, incoming):
3649 """ 3168 """
3650 Private method to get the list of incoming or outgoing bookmarks. 3169 Private method to get the list of incoming or outgoing bookmarks.
3651 3170
3652 @param repodir directory name of the repository (string)
3653 @param incoming flag indicating to get incoming bookmarks (boolean) 3171 @param incoming flag indicating to get incoming bookmarks (boolean)
3654 @return list of bookmarks (list of string) 3172 @return list of bookmarks (list of string)
3655 """ 3173 """
3656 bookmarksList = [] 3174 bookmarksList = []
3657 3175
3671 name = " ".join(li) 3189 name = " ".join(li)
3672 bookmarksList.append(name) 3190 bookmarksList.append(name)
3673 3191
3674 return bookmarksList 3192 return bookmarksList
3675 3193
3676 def hgBookmarkPull(self, name, current=False, bookmark=None): 3194 def hgBookmarkPull(self, current=False, bookmark=None):
3677 """ 3195 """
3678 Public method to pull a bookmark from a remote repository. 3196 Public method to pull a bookmark from a remote repository.
3679 3197
3680 @param name file/directory name
3681 @type str
3682 @param current flag indicating to pull the current bookmark 3198 @param current flag indicating to pull the current bookmark
3683 @type bool 3199 @type bool
3684 @param bookmark name of the bookmark 3200 @param bookmark name of the bookmark
3685 @type str 3201 @type str
3686 """ 3202 """
3687 # find the root of the repo
3688 repodir = self.splitPath(name)[0]
3689 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3690 repodir = os.path.dirname(repodir)
3691 if os.path.splitdrive(repodir)[1] == os.sep:
3692 return
3693
3694 if current: 3203 if current:
3695 bookmark = "." 3204 bookmark = "."
3696 ok = True 3205 ok = True
3697 elif bookmark: 3206 elif bookmark:
3698 ok = True 3207 ok = True
3699 else: 3208 else:
3700 bookmarks = self.__getInOutBookmarks(repodir, True) 3209 bookmarks = self.__getInOutBookmarks(True)
3701 bookmark, ok = QInputDialog.getItem( 3210 bookmark, ok = QInputDialog.getItem(
3702 None, 3211 None,
3703 self.tr("Pull Bookmark"), 3212 self.tr("Pull Bookmark"),
3704 self.tr("Select the bookmark to be pulled:"), 3213 self.tr("Select the bookmark to be pulled:"),
3705 [""] + sorted(bookmarks), 3214 [""] + sorted(bookmarks),
3711 args.append(bookmark) 3220 args.append(bookmark)
3712 3221
3713 dia = HgDialog(self.tr( 3222 dia = HgDialog(self.tr(
3714 'Pulling bookmark from a remote Mercurial repository'), 3223 'Pulling bookmark from a remote Mercurial repository'),
3715 self) 3224 self)
3716 res = dia.startProcess(args, repodir) 3225 res = dia.startProcess(args)
3717 if res: 3226 if res:
3718 dia.exec() 3227 dia.exec()
3719 3228
3720 def hgBookmarkPush(self, name, current=False, bookmark=None): 3229 def hgBookmarkPush(self, current=False, bookmark=None):
3721 """ 3230 """
3722 Public method to push a bookmark to a remote repository. 3231 Public method to push a bookmark to a remote repository.
3723 3232
3724 @param name file/directory name
3725 @type str
3726 @param current flag indicating to push the current bookmark 3233 @param current flag indicating to push the current bookmark
3727 @type bool 3234 @type bool
3728 @param bookmark name of the bookmark 3235 @param bookmark name of the bookmark
3729 @type str 3236 @type str
3730 """ 3237 """
3731 # find the root of the repo
3732 repodir = self.splitPath(name)[0]
3733 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3734 repodir = os.path.dirname(repodir)
3735 if os.path.splitdrive(repodir)[1] == os.sep:
3736 return
3737
3738 if current: 3238 if current:
3739 bookmark = "." 3239 bookmark = "."
3740 ok = True 3240 ok = True
3741 elif bookmark: 3241 elif bookmark:
3742 ok = True 3242 ok = True
3743 else: 3243 else:
3744 bookmarks = self.__getInOutBookmarks(repodir, False) 3244 bookmarks = self.__getInOutBookmarks(False)
3745 bookmark, ok = QInputDialog.getItem( 3245 bookmark, ok = QInputDialog.getItem(
3746 None, 3246 None,
3747 self.tr("Push Bookmark"), 3247 self.tr("Push Bookmark"),
3748 self.tr("Select the bookmark to be push:"), 3248 self.tr("Select the bookmark to be push:"),
3749 [""] + sorted(bookmarks), 3249 [""] + sorted(bookmarks),
3755 args.append(bookmark) 3255 args.append(bookmark)
3756 3256
3757 dia = HgDialog(self.tr( 3257 dia = HgDialog(self.tr(
3758 'Pushing bookmark to a remote Mercurial repository'), 3258 'Pushing bookmark to a remote Mercurial repository'),
3759 self) 3259 self)
3760 res = dia.startProcess(args, repodir) 3260 res = dia.startProcess(args)
3761 if res: 3261 if res:
3762 dia.exec() 3262 dia.exec()

eric ide

mercurial