eric6/Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 7970
c4ee8a81584c
parent 7923
91e843545d9a
child 7971
ff2971513d6d
equal deleted inserted replaced
7969:62eff8b34a8d 7970:c4ee8a81584c
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 @param 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 """
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:
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 @param 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
1289 self.commandHistory.insert(0, command) 1180 self.commandHistory.insert(0, command)
1290 1181
1291 args = [] 1182 args = []
1292 self.addArguments(args, commandList) 1183 self.addArguments(args, commandList)
1293 1184
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) 1185 dia = HgDialog(self.tr('Mercurial command'), self)
1302 res = dia.startProcess(args, repodir) 1186 res = dia.startProcess(args)
1303 if res: 1187 if res:
1304 dia.exec() 1188 dia.exec()
1305 1189
1306 def vcsOptionsDialog(self, project, archive, editable=False, parent=None): 1190 def vcsOptionsDialog(self, project, archive, editable=False, parent=None):
1307 """ 1191 """
1449 args = self.initCommand("copy") 1333 args = self.initCommand("copy")
1450 args.append("-v") 1334 args.append("-v")
1451 args.append(name) 1335 args.append(name)
1452 args.append(target) 1336 args.append(target)
1453 1337
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( 1338 dia = HgDialog(
1463 self.tr('Copying {0}').format(name), self) 1339 self.tr('Copying {0}').format(name), self)
1464 res = dia.startProcess(args, repodir) 1340 res = dia.startProcess(args)
1465 if res: 1341 if res:
1466 dia.exec() 1342 dia.exec()
1467 res = dia.normalExit() 1343 res = dia.normalExit()
1468 if ( 1344 if (
1469 res and 1345 res and
1473 project.copyDirectory(name, target) 1349 project.copyDirectory(name, target)
1474 else: 1350 else:
1475 project.appendFile(target) 1351 project.appendFile(target)
1476 return res 1352 return res
1477 1353
1478 def hgGetTagsList(self, repodir, withType=False): 1354 def hgGetTagsList(self, withType=False):
1479 """ 1355 """
1480 Public method to get the list of tags. 1356 Public method to get the list of tags.
1481 1357
1482 @param repodir directory name of the repository (string)
1483 @param withType flag indicating to get the tag type as well (boolean) 1358 @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 1359 @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 1360 tag name and flag indicating a local tag (list of tuple of string
1486 and boolean), if withType is True 1361 and boolean), if withType is True
1487 """ 1362 """
1513 else: 1388 else:
1514 if tagsList: 1389 if tagsList:
1515 self.tagsList = tagsList 1390 self.tagsList = tagsList
1516 return self.tagsList[:] 1391 return self.tagsList[:]
1517 1392
1518 def hgGetBranchesList(self, repodir): 1393 def hgGetBranchesList(self):
1519 """ 1394 """
1520 Public method to get the list of branches. 1395 Public method to get the list of branches.
1521 1396
1522 @param repodir directory name of the repository (string)
1523 @return list of branches (list of string) 1397 @return list of branches (list of string)
1524 """ 1398 """
1525 args = self.initCommand("branches") 1399 args = self.initCommand("branches")
1526 args.append('--closed') 1400 args.append('--closed')
1527 1401
1540 if name not in ["tip", "default"]: 1414 if name not in ["tip", "default"]:
1541 self.branchesList.append(name) 1415 self.branchesList.append(name)
1542 1416
1543 return self.branchesList[:] 1417 return self.branchesList[:]
1544 1418
1545 def hgListTagBranch(self, path, tags=True): 1419 def hgListTagBranch(self, tags=True):
1546 """ 1420 """
1547 Public method used to list the available tags or branches. 1421 Public method used to list the available tags or branches.
1548 1422
1549 @param path directory name of the project (string)
1550 @param tags flag indicating listing of branches or tags 1423 @param tags flag indicating listing of branches or tags
1551 (False = branches, True = tags) 1424 (False = branches, True = tags)
1552 """ 1425 """
1553 from .HgTagBranchListDialog import HgTagBranchListDialog 1426 from .HgTagBranchListDialog import HgTagBranchListDialog
1554 self.tagbranchList = HgTagBranchListDialog(self) 1427 self.tagbranchList = HgTagBranchListDialog(self)
1558 self.showedTags = True 1431 self.showedTags = True
1559 allTagsBranchesList = self.allTagsBranchesList 1432 allTagsBranchesList = self.allTagsBranchesList
1560 else: 1433 else:
1561 self.tagsList = [] 1434 self.tagsList = []
1562 allTagsBranchesList = None 1435 allTagsBranchesList = None
1563 self.tagbranchList.start(path, tags, 1436 self.tagbranchList.start(
1564 self.tagsList, allTagsBranchesList) 1437 tags, self.tagsList, allTagsBranchesList)
1565 else: 1438 else:
1566 if not self.showedBranches: 1439 if not self.showedBranches:
1567 self.showedBranches = True 1440 self.showedBranches = True
1568 allTagsBranchesList = self.allTagsBranchesList 1441 allTagsBranchesList = self.allTagsBranchesList
1569 else: 1442 else:
1570 self.branchesList = [] 1443 self.branchesList = []
1571 allTagsBranchesList = None 1444 allTagsBranchesList = None
1572 self.tagbranchList.start(path, tags, 1445 self.tagbranchList.start(
1573 self.branchesList, 1446 tags, self.branchesList, self.allTagsBranchesList)
1574 self.allTagsBranchesList)
1575 1447
1576 def hgAnnotate(self, name): 1448 def hgAnnotate(self, name):
1577 """ 1449 """
1578 Public method to show the output of the hg annotate command. 1450 Public method to show the output of the hg annotate command.
1579 1451
1599 This method gives the chance to enter the revisions to be compared. 1471 This method gives the chance to enter the revisions to be compared.
1600 1472
1601 @param name file/directory name to be diffed (string) 1473 @param name file/directory name to be diffed (string)
1602 """ 1474 """
1603 if isinstance(name, list): 1475 if isinstance(name, list):
1604 dname, fnames = self.splitPathList(name)
1605 names = name[:] 1476 names = name[:]
1606 else: 1477 else:
1607 dname, fname = self.splitPath(name)
1608 names = [name] 1478 names = [name]
1609 for nam in names: 1479 for nam in names:
1610 if os.path.isfile(nam): 1480 if os.path.isfile(nam):
1611 editor = e5App().getObject("ViewManager").getOpenEditor(nam) 1481 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
1612 if editor and not editor.checkDirty(): 1482 if editor and not editor.checkDirty():
1614 else: 1484 else:
1615 project = e5App().getObject("Project") 1485 project = e5App().getObject("Project")
1616 if nam == project.ppath and not project.saveAllScripts(): 1486 if nam == project.ppath and not project.saveAllScripts():
1617 return 1487 return
1618 1488
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 1489 from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog
1627 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(repodir), 1490 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(),
1628 self.hgGetBranchesList(repodir), 1491 self.hgGetBranchesList(),
1629 self.hgGetBookmarksList(repodir)) 1492 self.hgGetBookmarksList())
1630 if dlg.exec() == QDialog.Accepted: 1493 if dlg.exec() == QDialog.Accepted:
1631 revisions = dlg.getRevisions() 1494 revisions = dlg.getRevisions()
1632 if self.diff is None: 1495 if self.diff is None:
1633 from .HgDiffDialog import HgDiffDialog 1496 from .HgDiffDialog import HgDiffDialog
1634 self.diff = HgDiffDialog(self) 1497 self.diff = HgDiffDialog(self)
1668 """ 1531 """
1669 if isinstance(name, list): 1532 if isinstance(name, list):
1670 raise ValueError("Wrong parameter type") 1533 raise ValueError("Wrong parameter type")
1671 1534
1672 if extended: 1535 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 1536 from .HgRevisionsSelectionDialog import HgRevisionsSelectionDialog
1681 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(repodir), 1537 dlg = HgRevisionsSelectionDialog(self.hgGetTagsList(),
1682 self.hgGetBranchesList(repodir), 1538 self.hgGetBranchesList(),
1683 self.hgGetBookmarksList(repodir)) 1539 self.hgGetBookmarksList())
1684 if dlg.exec() == QDialog.Accepted: 1540 if dlg.exec() == QDialog.Accepted:
1685 rev1, rev2 = dlg.getRevisions() 1541 rev1, rev2 = dlg.getRevisions()
1686 else: 1542 else:
1687 return 1543 return
1688 elif revisions: 1544 elif revisions:
1727 self.sbsDiff = CompareDialog() 1583 self.sbsDiff = CompareDialog()
1728 self.sbsDiff.show() 1584 self.sbsDiff.show()
1729 self.sbsDiff.raise_() 1585 self.sbsDiff.raise_()
1730 self.sbsDiff.compare(output1, output2, name1, name2) 1586 self.sbsDiff.compare(output1, output2, name1, name2)
1731 1587
1732 def vcsLogBrowser(self, name, isFile=False): 1588 def vcsLogBrowser(self, name=None, isFile=False):
1733 """ 1589 """
1734 Public method used to browse the log of a file/directory from the 1590 Public method used to browse the log of a file/directory from the
1735 Mercurial repository. 1591 Mercurial repository.
1736 1592
1737 @param name file/directory name to show the log of (string) 1593 @param name file/directory name to show the log of (string)
1741 if self.logBrowser is None: 1597 if self.logBrowser is None:
1742 from .HgLogBrowserDialog import HgLogBrowserDialog 1598 from .HgLogBrowserDialog import HgLogBrowserDialog
1743 self.logBrowser = HgLogBrowserDialog(self) 1599 self.logBrowser = HgLogBrowserDialog(self)
1744 self.logBrowser.show() 1600 self.logBrowser.show()
1745 self.logBrowser.raise_() 1601 self.logBrowser.raise_()
1746 self.logBrowser.start(name, isFile=isFile) 1602 self.logBrowser.start(name=name, isFile=isFile)
1747 1603
1748 def hgIncoming(self, name): 1604 def hgIncoming(self):
1749 """ 1605 """
1750 Public method used to view the log of incoming changes from the 1606 Public method used to view the log of incoming changes from the
1751 Mercurial repository. 1607 Mercurial repository.
1752
1753 @param name file/directory name to show the log of (string)
1754 """ 1608 """
1755 if self.logBrowserIncoming is None: 1609 if self.logBrowserIncoming is None:
1756 from .HgLogBrowserDialog import HgLogBrowserDialog 1610 from .HgLogBrowserDialog import HgLogBrowserDialog
1757 self.logBrowserIncoming = HgLogBrowserDialog( 1611 self.logBrowserIncoming = HgLogBrowserDialog(
1758 self, mode="incoming") 1612 self, mode="incoming")
1759 self.logBrowserIncoming.show() 1613 self.logBrowserIncoming.show()
1760 self.logBrowserIncoming.raise_() 1614 self.logBrowserIncoming.raise_()
1761 self.logBrowserIncoming.start(name) 1615 self.logBrowserIncoming.start()
1762 1616
1763 def hgOutgoing(self, name): 1617 def hgOutgoing(self):
1764 """ 1618 """
1765 Public method used to view the log of outgoing changes from the 1619 Public method used to view the log of outgoing changes from the
1766 Mercurial repository. 1620 Mercurial repository.
1767
1768 @param name file/directory name to show the log of (string)
1769 """ 1621 """
1770 if self.logBrowserOutgoing is None: 1622 if self.logBrowserOutgoing is None:
1771 from .HgLogBrowserDialog import HgLogBrowserDialog 1623 from .HgLogBrowserDialog import HgLogBrowserDialog
1772 self.logBrowserOutgoing = HgLogBrowserDialog( 1624 self.logBrowserOutgoing = HgLogBrowserDialog(
1773 self, mode="outgoing") 1625 self, mode="outgoing")
1774 self.logBrowserOutgoing.show() 1626 self.logBrowserOutgoing.show()
1775 self.logBrowserOutgoing.raise_() 1627 self.logBrowserOutgoing.raise_()
1776 self.logBrowserOutgoing.start(name) 1628 self.logBrowserOutgoing.start()
1777 1629
1778 def hgPull(self, name, revisions=None): 1630 def hgPull(self, revisions=None):
1779 """ 1631 """
1780 Public method used to pull changes from a remote Mercurial repository. 1632 Public method used to pull changes from a remote Mercurial repository.
1781 1633
1782 @param name directory name of the project to be pulled to
1783 @type str
1784 @param revisions list of revisions to be pulled 1634 @param revisions list of revisions to be pulled
1785 @type list of str 1635 @type list of str
1786 @return flag indicating, that the update contained an add 1636 @return flag indicating, that the update contained an add
1787 or delete 1637 or delete
1788 @rtype bool 1638 @rtype bool
1808 if revisions: 1658 if revisions:
1809 for rev in revisions: 1659 for rev in revisions:
1810 args.append("--rev") 1660 args.append("--rev")
1811 args.append(rev) 1661 args.append(rev)
1812 1662
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) 1663 dia = HgDialog(title, self)
1821 res = dia.startProcess(args, repodir) 1664 res = dia.startProcess(args)
1822 if res: 1665 if res:
1823 dia.exec() 1666 dia.exec()
1824 res = dia.hasAddOrDelete() 1667 res = dia.hasAddOrDelete()
1825 if ( 1668 if (
1826 self.bundleFile and 1669 self.bundleFile and
1829 os.remove(self.bundleFile) 1672 os.remove(self.bundleFile)
1830 self.bundleFile = None 1673 self.bundleFile = None
1831 self.checkVCSStatus() 1674 self.checkVCSStatus()
1832 return res 1675 return res
1833 1676
1834 def hgPush(self, name, force=False, newBranch=False, rev=None): 1677 def hgPush(self, force=False, newBranch=False, rev=None):
1835 """ 1678 """
1836 Public method used to push changes to a remote Mercurial repository. 1679 Public method used to push changes to a remote Mercurial repository.
1837 1680
1838 @param name directory name of the project to be pushed from (string)
1839 @param force flag indicating a forced push (boolean) 1681 @param force flag indicating a forced push (boolean)
1840 @param newBranch flag indicating to push a new branch (boolean) 1682 @param newBranch flag indicating to push a new branch (boolean)
1841 @param rev revision to be pushed (including all ancestors) (string) 1683 @param rev revision to be pushed (including all ancestors) (string)
1842 """ 1684 """
1843 args = self.initCommand("push") 1685 args = self.initCommand("push")
1848 args.append('--new-branch') 1690 args.append('--new-branch')
1849 if rev: 1691 if rev:
1850 args.append('--rev') 1692 args.append('--rev')
1851 args.append(rev) 1693 args.append(rev)
1852 1694
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( 1695 dia = HgDialog(
1861 self.tr('Pushing to a remote Mercurial repository'), self) 1696 self.tr('Pushing to a remote Mercurial repository'), self)
1862 res = dia.startProcess(args, repodir) 1697 res = dia.startProcess(args)
1863 if res: 1698 if res:
1864 dia.exec() 1699 dia.exec()
1865 self.checkVCSStatus() 1700 self.checkVCSStatus()
1866 1701
1867 def hgInfo(self, ppath, mode="heads"): 1702 def hgInfo(self, mode="heads"):
1868 """ 1703 """
1869 Public method to show information about the heads of the repository. 1704 Public method to show information about the heads of the repository.
1870 1705
1871 @param ppath local path to get the repository infos (string)
1872 @param mode mode of the operation (string, one of heads, parents, 1706 @param mode mode of the operation (string, one of heads, parents,
1873 tip) 1707 tip)
1874 """ 1708 """
1875 if mode not in ("heads", "parents", "tip"): 1709 if mode not in ("heads", "parents", "tip"):
1876 mode = "heads" 1710 mode = "heads"
1939 .format(author, cdate, ctime)) 1773 .format(author, cdate, ctime))
1940 1774
1941 dlg = VcsRepositoryInfoDialog(None, "\n".join(info)) 1775 dlg = VcsRepositoryInfoDialog(None, "\n".join(info))
1942 dlg.exec() 1776 dlg.exec()
1943 1777
1944 def hgConflicts(self, name): 1778 def hgConflicts(self):
1945 """ 1779 """
1946 Public method used to show a list of files containing conflicts. 1780 Public method used to show a list of files containing conflicts.
1947
1948 @param name file/directory name to be resolved (string)
1949 """ 1781 """
1950 if self.conflictsDlg is None: 1782 if self.conflictsDlg is None:
1951 from .HgConflictsListDialog import HgConflictsListDialog 1783 from .HgConflictsListDialog import HgConflictsListDialog
1952 self.conflictsDlg = HgConflictsListDialog(self) 1784 self.conflictsDlg = HgConflictsListDialog(self)
1953 self.conflictsDlg.show() 1785 self.conflictsDlg.show()
1954 self.conflictsDlg.raise_() 1786 self.conflictsDlg.raise_()
1955 self.conflictsDlg.start(name) 1787 self.conflictsDlg.start()
1956 1788
1957 def hgResolved(self, name, unresolve=False): 1789 def hgResolved(self, name, unresolve=False):
1958 """ 1790 """
1959 Public method used to resolve conflicts of a file/directory. 1791 Public method used to resolve conflicts of a file/directory.
1960 1792
1967 args.append("--unmark") 1799 args.append("--unmark")
1968 else: 1800 else:
1969 args.append("--mark") 1801 args.append("--mark")
1970 1802
1971 if isinstance(name, list): 1803 if isinstance(name, list):
1972 dname, fnames = self.splitPathList(name)
1973 self.addArguments(args, name) 1804 self.addArguments(args, name)
1974 else: 1805 else:
1975 dname, fname = self.splitPath(name)
1976 args.append(name) 1806 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 1807
1985 if unresolve: 1808 if unresolve:
1986 title = self.tr("Marking as 'unresolved'") 1809 title = self.tr("Marking as 'unresolved'")
1987 else: 1810 else:
1988 title = self.tr("Marking as 'resolved'") 1811 title = self.tr("Marking as 'resolved'")
1989 dia = HgDialog(title, self) 1812 dia = HgDialog(title, self)
1990 res = dia.startProcess(args, repodir) 1813 res = dia.startProcess(args)
1991 if res: 1814 if res:
1992 dia.exec() 1815 dia.exec()
1993 self.checkVCSStatus() 1816 self.checkVCSStatus()
1994 1817
1995 def hgAbortMerge(self, name): 1818 def hgAbortMerge(self):
1996 """ 1819 """
1997 Public method to abort an uncommitted merge. 1820 Public method to abort an uncommitted merge.
1998 1821
1999 @param name file/directory name (string)
2000 @return flag indicating, that the abortion contained an add 1822 @return flag indicating, that the abortion contained an add
2001 or delete (boolean) 1823 or delete (boolean)
2002 """ 1824 """
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): 1825 if self.version >= (4, 5, 0):
2013 args = self.initCommand("merge") 1826 args = self.initCommand("merge")
2014 args.append("--abort") 1827 args.append("--abort")
2015 else: 1828 else:
2016 args = self.initCommand("update") 1829 args = self.initCommand("update")
2017 args.append("--clean") 1830 args.append("--clean")
2018 1831
2019 dia = HgDialog( 1832 dia = HgDialog(
2020 self.tr('Aborting uncommitted merge'), 1833 self.tr('Aborting uncommitted merge'),
2021 self) 1834 self)
2022 res = dia.startProcess(args, repodir, False) 1835 res = dia.startProcess(args, showArgs=False)
2023 if res: 1836 if res:
2024 dia.exec() 1837 dia.exec()
2025 res = dia.hasAddOrDelete() 1838 res = dia.hasAddOrDelete()
2026 self.checkVCSStatus() 1839 self.checkVCSStatus()
2027 return res 1840 return res
2028 1841
2029 def hgBranch(self, name): 1842 def hgBranch(self):
2030 """ 1843 """
2031 Public method used to create a branch in the Mercurial repository. 1844 Public method used to create a branch in the Mercurial repository.
2032 1845 """
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 1846 from .HgBranchInputDialog import HgBranchInputDialog
2045 dlg = HgBranchInputDialog(self.hgGetBranchesList(repodir)) 1847 dlg = HgBranchInputDialog(self.hgGetBranchesList())
2046 if dlg.exec() == QDialog.Accepted: 1848 if dlg.exec() == QDialog.Accepted:
2047 name, commit = dlg.getData() 1849 name, commit = dlg.getData()
2048 name = name.strip().replace(" ", "_") 1850 name = name.strip().replace(" ", "_")
2049 args = self.initCommand("branch") 1851 args = self.initCommand("branch")
2050 args.append(name) 1852 args.append(name)
2051 1853
2052 dia = HgDialog( 1854 dia = HgDialog(
2053 self.tr('Creating branch in the Mercurial repository'), 1855 self.tr('Creating branch in the Mercurial repository'),
2054 self) 1856 self)
2055 res = dia.startProcess(args, repodir) 1857 res = dia.startProcess(args)
2056 if res: 1858 if res:
2057 dia.exec() 1859 dia.exec()
2058 if commit: 1860 if commit:
2059 self.vcsCommit( 1861 self.vcsCommit(
2060 repodir, 1862 name,
2061 self.tr("Created new branch <{0}>.").format( 1863 self.tr("Created new branch <{0}>.").format(
2062 name)) 1864 name))
2063 1865
2064 def hgShowBranch(self, name): 1866 def hgShowBranch(self):
2065 """ 1867 """
2066 Public method used to show the current branch of the working directory. 1868 Public method used to show the current branch of the working directory.
2067 1869 """
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") 1870 args = self.initCommand("branch")
2080 1871
2081 dia = HgDialog(self.tr('Showing current branch'), self) 1872 dia = HgDialog(self.tr('Showing current branch'), self)
2082 res = dia.startProcess(args, repodir, False) 1873 res = dia.startProcess(args, showArgs=False)
2083 if res: 1874 if res:
2084 dia.exec() 1875 dia.exec()
2085 1876
2086 def hgGetCurrentBranch(self, repodir): 1877 def hgGetCurrentBranch(self):
2087 """ 1878 """
2088 Public method to get the current branch of the working directory. 1879 Public method to get the current branch of the working directory.
2089 1880
2090 @param repodir directory name of the repository
2091 @type str
2092 @return name of the current branch 1881 @return name of the current branch
2093 @rtype str 1882 @rtype str
2094 """ 1883 """
2095 args = self.initCommand("branch") 1884 args = self.initCommand("branch")
2096 1885
2166 except OSError: 1955 except OSError:
2167 pass 1956 pass
2168 self.repoEditor = MiniEditor(cfgFile, "Properties") 1957 self.repoEditor = MiniEditor(cfgFile, "Properties")
2169 self.repoEditor.show() 1958 self.repoEditor.show()
2170 1959
2171 def hgVerify(self, name): 1960 def hgVerify(self):
2172 """ 1961 """
2173 Public method to verify the integrity of the repository. 1962 Public method to verify the integrity of the repository.
2174 1963 """
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") 1964 args = self.initCommand("verify")
2187 1965
2188 dia = HgDialog( 1966 dia = HgDialog(
2189 self.tr('Verifying the integrity of the Mercurial repository'), 1967 self.tr('Verifying the integrity of the Mercurial repository'),
2190 self) 1968 self)
2191 res = dia.startProcess(args, repodir) 1969 res = dia.startProcess(args)
2192 if res: 1970 if res:
2193 dia.exec() 1971 dia.exec()
2194 1972
2195 def hgShowConfig(self, name): 1973 def hgShowConfig(self):
2196 """ 1974 """
2197 Public method to show the combined configuration. 1975 Public method to show the combined configuration.
2198 1976 """
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") 1977 args = self.initCommand("showconfig")
2211 args.append("--untrusted") 1978 args.append("--untrusted")
2212 1979
2213 dia = HgDialog( 1980 dia = HgDialog(
2214 self.tr('Showing the combined configuration settings'), 1981 self.tr('Showing the combined configuration settings'),
2215 self) 1982 self)
2216 res = dia.startProcess(args, repodir, False) 1983 res = dia.startProcess(args, showArgs=False)
2217 if res: 1984 if res:
2218 dia.exec() 1985 dia.exec()
2219 1986
2220 def hgShowPaths(self, name): 1987 def hgShowPaths(self):
2221 """ 1988 """
2222 Public method to show the path aliases for remote repositories. 1989 Public method to show the path aliases for remote repositories.
2223 1990 """
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") 1991 args = self.initCommand("paths")
2236 1992
2237 dia = HgDialog( 1993 dia = HgDialog(
2238 self.tr('Showing aliases for remote repositories'), 1994 self.tr('Showing aliases for remote repositories'),
2239 self) 1995 self)
2240 res = dia.startProcess(args, repodir, False) 1996 res = dia.startProcess(args, showArgs=False)
2241 if res: 1997 if res:
2242 dia.exec() 1998 dia.exec()
2243 1999
2244 def hgRecover(self, name): 2000 def hgRecover(self):
2245 """ 2001 """
2246 Public method to recover an interrupted transaction. 2002 Public method to recover an interrupted transaction.
2247 2003 """
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") 2004 args = self.initCommand("recover")
2260 2005
2261 dia = HgDialog( 2006 dia = HgDialog(
2262 self.tr('Recovering from interrupted transaction'), 2007 self.tr('Recovering from interrupted transaction'),
2263 self) 2008 self)
2264 res = dia.startProcess(args, repodir, False) 2009 res = dia.startProcess(args, showArgs=False)
2265 if res: 2010 if res:
2266 dia.exec() 2011 dia.exec()
2267 2012
2268 def hgIdentify(self, name): 2013 def hgIdentify(self):
2269 """ 2014 """
2270 Public method to identify the current working directory. 2015 Public method to identify the current working directory.
2271 2016 """
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") 2017 args = self.initCommand("identify")
2284 2018
2285 dia = HgDialog(self.tr('Identifying project directory'), self) 2019 dia = HgDialog(self.tr('Identifying project directory'), self)
2286 res = dia.startProcess(args, repodir, False) 2020 res = dia.startProcess(args, showArgs=False)
2287 if res: 2021 if res:
2288 dia.exec() 2022 dia.exec()
2289 2023
2290 def hgCreateIgnoreFile(self, name, autoAdd=False): 2024 def hgCreateIgnoreFile(self, name, autoAdd=False):
2291 """ 2025 """
2337 project = e5App().getObject("Project") 2071 project = e5App().getObject("Project")
2338 project.appendFile(ignoreName) 2072 project.appendFile(ignoreName)
2339 2073
2340 return status 2074 return status
2341 2075
2342 def hgBundle(self, name, bundleData=None): 2076 def hgBundle(self, bundleData=None):
2343 """ 2077 """
2344 Public method to create a changegroup file. 2078 Public method to create a changegroup file.
2345 2079
2346 @param name file/directory name
2347 @type str
2348 @param bundleData dictionary containing the bundle creation information 2080 @param bundleData dictionary containing the bundle creation information
2349 @type dict 2081 @type dict
2350 """ 2082 """
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: 2083 if bundleData is None:
2361 from .HgBundleDialog import HgBundleDialog 2084 from .HgBundleDialog import HgBundleDialog
2362 dlg = HgBundleDialog(self.hgGetTagsList(repodir), 2085 dlg = HgBundleDialog(self.hgGetTagsList(),
2363 self.hgGetBranchesList(repodir), 2086 self.hgGetBranchesList(),
2364 self.hgGetBookmarksList(repodir), 2087 self.hgGetBookmarksList(),
2365 version=self.version) 2088 version=self.version)
2366 if dlg.exec() != QDialog.Accepted: 2089 if dlg.exec() != QDialog.Accepted:
2367 return 2090 return
2368 2091
2369 revs, baseRevs, compression, bundleAll = dlg.getParameters() 2092 revs, baseRevs, compression, bundleAll = dlg.getParameters()
2377 bundleAll = bundleData["all"] 2100 bundleAll = bundleData["all"]
2378 2101
2379 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 2102 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
2380 None, 2103 None,
2381 self.tr("Create changegroup"), 2104 self.tr("Create changegroup"),
2382 self.__lastChangeGroupPath or repodir, 2105 self.__lastChangeGroupPath,
2383 self.tr("Mercurial Changegroup Files (*.hg)"), 2106 self.tr("Mercurial Changegroup Files (*.hg)"),
2384 None, 2107 None,
2385 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 2108 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
2386 2109
2387 if not fname: 2110 if not fname:
2418 args.append("--type") 2141 args.append("--type")
2419 args.append(compression) 2142 args.append(compression)
2420 args.append(fname) 2143 args.append(fname)
2421 2144
2422 dia = HgDialog(self.tr('Create changegroup'), self) 2145 dia = HgDialog(self.tr('Create changegroup'), self)
2423 res = dia.startProcess(args, repodir) 2146 res = dia.startProcess(args)
2424 if res: 2147 if res:
2425 dia.exec() 2148 dia.exec()
2426 2149
2427 def hgPreviewBundle(self, name): 2150 def hgPreviewBundle(self):
2428 """ 2151 """
2429 Public method used to view the log of incoming changes from a 2152 Public method used to view the log of incoming changes from a
2430 changegroup file. 2153 changegroup file.
2431 2154 """
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( 2155 file = E5FileDialog.getOpenFileName(
2444 None, 2156 None,
2445 self.tr("Preview changegroup"), 2157 self.tr("Preview changegroup"),
2446 self.__lastChangeGroupPath or repodir, 2158 self.__lastChangeGroupPath,
2447 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)")) 2159 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)"))
2448 if file: 2160 if file:
2449 self.__lastChangeGroupPath = os.path.dirname(file) 2161 self.__lastChangeGroupPath = os.path.dirname(file)
2450 2162
2451 if self.logBrowserIncoming is None: 2163 if self.logBrowserIncoming is None:
2452 from .HgLogBrowserDialog import HgLogBrowserDialog 2164 from .HgLogBrowserDialog import HgLogBrowserDialog
2453 self.logBrowserIncoming = HgLogBrowserDialog( 2165 self.logBrowserIncoming = HgLogBrowserDialog(
2454 self, mode="incoming") 2166 self, mode="incoming")
2455 self.logBrowserIncoming.show() 2167 self.logBrowserIncoming.show()
2456 self.logBrowserIncoming.raise_() 2168 self.logBrowserIncoming.raise_()
2457 self.logBrowserIncoming.start(name, bundle=file) 2169 self.logBrowserIncoming.start(bundle=file)
2458 2170
2459 def hgUnbundle(self, name, files=None): 2171 def hgUnbundle(self, files=None):
2460 """ 2172 """
2461 Public method to apply changegroup files. 2173 Public method to apply changegroup files.
2462 2174
2463 @param name directory name
2464 @type str
2465 @param files list of bundle files to be applied 2175 @param files list of bundle files to be applied
2466 @type list of str 2176 @type list of str
2467 @return flag indicating, that the update contained an add 2177 @return flag indicating, that the update contained an add
2468 or delete 2178 or delete
2469 @rtype bool 2179 @rtype bool
2470 """ 2180 """
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 2181 res = False
2481 if not files: 2182 if not files:
2482 files = E5FileDialog.getOpenFileNames( 2183 files = E5FileDialog.getOpenFileNames(
2483 None, 2184 None,
2484 self.tr("Apply changegroups"), 2185 self.tr("Apply changegroups"),
2485 self.__lastChangeGroupPath or repodir, 2186 self.__lastChangeGroupPath,
2486 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)")) 2187 self.tr("Mercurial Changegroup Files (*.hg);;All Files (*)"))
2487 2188
2488 if files: 2189 if files:
2489 self.__lastChangeGroupPath = os.path.dirname(files[0]) 2190 self.__lastChangeGroupPath = os.path.dirname(files[0])
2490 2191
2499 args.append("--update") 2200 args.append("--update")
2500 args.append("--verbose") 2201 args.append("--verbose")
2501 args.extend(files) 2202 args.extend(files)
2502 2203
2503 dia = HgDialog(self.tr('Apply changegroups'), self) 2204 dia = HgDialog(self.tr('Apply changegroups'), self)
2504 res = dia.startProcess(args, repodir) 2205 res = dia.startProcess(args)
2505 if res: 2206 if res:
2506 dia.exec() 2207 dia.exec()
2507 res = dia.hasAddOrDelete() 2208 res = dia.hasAddOrDelete()
2508 self.checkVCSStatus() 2209 self.checkVCSStatus()
2509 2210
2510 return res 2211 return res
2511 2212
2512 def hgBisect(self, name, subcommand): 2213 def hgBisect(self, subcommand):
2513 """ 2214 """
2514 Public method to perform bisect commands. 2215 Public method to perform bisect commands.
2515 2216
2516 @param name file/directory name (string) 2217 @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') 2218 'skip' or 'reset')
2219 @type str
2519 @exception ValueError raised to indicate an invalid bisect subcommand 2220 @exception ValueError raised to indicate an invalid bisect subcommand
2520 """ 2221 """
2521 if subcommand not in ("good", "bad", "skip", "reset"): 2222 if subcommand not in ("good", "bad", "skip", "reset"):
2522 raise ValueError( 2223 raise ValueError(
2523 self.tr("Bisect subcommand ({0}) invalid.") 2224 self.tr("Bisect subcommand ({0}) invalid.")
2524 .format(subcommand)) 2225 .format(subcommand))
2525 2226
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 = "" 2227 rev = ""
2536 if subcommand in ("good", "bad", "skip"): 2228 if subcommand in ("good", "bad", "skip"):
2537 from .HgRevisionSelectionDialog import HgRevisionSelectionDialog 2229 from .HgRevisionSelectionDialog import HgRevisionSelectionDialog
2538 dlg = HgRevisionSelectionDialog(self.hgGetTagsList(repodir), 2230 dlg = HgRevisionSelectionDialog(self.hgGetTagsList(),
2539 self.hgGetBranchesList(repodir), 2231 self.hgGetBranchesList(),
2540 self.hgGetBookmarksList(repodir)) 2232 self.hgGetBookmarksList())
2541 if dlg.exec() == QDialog.Accepted: 2233 if dlg.exec() == QDialog.Accepted:
2542 rev = dlg.getRevision() 2234 rev = dlg.getRevision()
2543 else: 2235 else:
2544 return 2236 return
2545 2237
2548 if rev: 2240 if rev:
2549 args.append(rev) 2241 args.append(rev)
2550 2242
2551 dia = HgDialog( 2243 dia = HgDialog(
2552 self.tr('Mercurial Bisect ({0})').format(subcommand), self) 2244 self.tr('Mercurial Bisect ({0})').format(subcommand), self)
2553 res = dia.startProcess(args, repodir) 2245 res = dia.startProcess(args)
2554 if res: 2246 if res:
2555 dia.exec() 2247 dia.exec()
2556 2248
2557 def hgForget(self, name): 2249 def hgForget(self, name):
2558 """ 2250 """
2565 """ 2257 """
2566 args = self.initCommand("forget") 2258 args = self.initCommand("forget")
2567 args.append('-v') 2259 args.append('-v')
2568 2260
2569 if isinstance(name, list): 2261 if isinstance(name, list):
2570 dname, fnames = self.splitPathList(name)
2571 self.addArguments(args, name) 2262 self.addArguments(args, name)
2572 else: 2263 else:
2573 dname, fname = self.splitPath(name)
2574 args.append(name) 2264 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 2265
2583 dia = HgDialog( 2266 dia = HgDialog(
2584 self.tr('Removing files from the Mercurial repository only'), 2267 self.tr('Removing files from the Mercurial repository only'),
2585 self) 2268 self)
2586 res = dia.startProcess(args, repodir) 2269 res = dia.startProcess(args)
2587 if res: 2270 if res:
2588 dia.exec() 2271 dia.exec()
2589 if isinstance(name, list): 2272 if isinstance(name, list):
2590 self.__forgotNames.extend(name) 2273 self.__forgotNames.extend(name)
2591 else: 2274 else:
2592 self.__forgotNames.append(name) 2275 self.__forgotNames.append(name)
2593 2276
2594 def hgBackout(self, name): 2277 def hgBackout(self):
2595 """ 2278 """
2596 Public method used to backout an earlier changeset from the Mercurial 2279 Public method used to backout an earlier changeset from the Mercurial
2597 repository. 2280 repository.
2598 2281 """
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 2282 from .HgBackoutDialog import HgBackoutDialog
2611 dlg = HgBackoutDialog(self.hgGetTagsList(repodir), 2283 dlg = HgBackoutDialog(self.hgGetTagsList(),
2612 self.hgGetBranchesList(repodir), 2284 self.hgGetBranchesList(),
2613 self.hgGetBookmarksList(repodir)) 2285 self.hgGetBookmarksList())
2614 if dlg.exec() == QDialog.Accepted: 2286 if dlg.exec() == QDialog.Accepted:
2615 rev, merge, date, user, message = dlg.getParameters() 2287 rev, merge, date, user, message = dlg.getParameters()
2616 if not rev: 2288 if not rev:
2617 E5MessageBox.warning( 2289 E5MessageBox.warning(
2618 self.__ui, 2290 self.__ui,
2633 args.append('--message') 2305 args.append('--message')
2634 args.append(message) 2306 args.append(message)
2635 args.append(rev) 2307 args.append(rev)
2636 2308
2637 dia = HgDialog(self.tr('Backing out changeset'), self) 2309 dia = HgDialog(self.tr('Backing out changeset'), self)
2638 res = dia.startProcess(args, repodir) 2310 res = dia.startProcess(args)
2639 if res: 2311 if res:
2640 dia.exec() 2312 dia.exec()
2641 2313
2642 def hgRollback(self, name): 2314 def hgRollback(self):
2643 """ 2315 """
2644 Public method used to rollback the last transaction. 2316 Public method used to rollback the last transaction.
2645 2317 """
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( 2318 res = E5MessageBox.yesNo(
2658 None, 2319 None,
2659 self.tr("Rollback last transaction"), 2320 self.tr("Rollback last transaction"),
2660 self.tr("""Are you sure you want to rollback the last""" 2321 self.tr("""Are you sure you want to rollback the last"""
2661 """ transaction?"""), 2322 """ transaction?"""),
2662 icon=E5MessageBox.Warning) 2323 icon=E5MessageBox.Warning)
2663 if res: 2324 if res:
2664 dia = HgDialog(self.tr('Rollback last transaction'), self) 2325 dia = HgDialog(self.tr('Rollback last transaction'), self)
2665 res = dia.startProcess(["rollback"], repodir) 2326 res = dia.startProcess(["rollback"])
2666 if res: 2327 if res:
2667 dia.exec() 2328 dia.exec()
2668 2329
2669 def hgServe(self, name): 2330 def hgServe(self, name):
2670 """ 2331 """
2683 2344
2684 from .HgServeDialog import HgServeDialog 2345 from .HgServeDialog import HgServeDialog
2685 self.serveDlg = HgServeDialog(self, repodir) 2346 self.serveDlg = HgServeDialog(self, repodir)
2686 self.serveDlg.show() 2347 self.serveDlg.show()
2687 2348
2688 def hgImport(self, name): 2349 def hgImport(self):
2689 """ 2350 """
2690 Public method to import a patch file. 2351 Public method to import a patch file.
2691 2352
2692 @param name directory name of the project to import into (string)
2693 @return flag indicating, that the import contained an add, a delete 2353 @return flag indicating, that the import contained an add, a delete
2694 or a change to the project file (boolean) 2354 or a change to the project file (boolean)
2695 """ 2355 """
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 2356 from .HgImportDialog import HgImportDialog
2706 dlg = HgImportDialog(self) 2357 dlg = HgImportDialog(self)
2707 if dlg.exec() == QDialog.Accepted: 2358 if dlg.exec() == QDialog.Accepted:
2708 (patchFile, noCommit, message, date, user, withSecret, stripCount, 2359 (patchFile, noCommit, message, date, user, withSecret, stripCount,
2709 force) = dlg.getParameters() 2360 force) = dlg.getParameters()
2730 if withSecret: 2381 if withSecret:
2731 args.append("--secret") 2382 args.append("--secret")
2732 args.append(patchFile) 2383 args.append(patchFile)
2733 2384
2734 dia = HgDialog(self.tr("Import Patch"), self) 2385 dia = HgDialog(self.tr("Import Patch"), self)
2735 res = dia.startProcess(args, repodir) 2386 res = dia.startProcess(args)
2736 if res: 2387 if res:
2737 dia.exec() 2388 dia.exec()
2738 res = dia.hasAddOrDelete() 2389 res = dia.hasAddOrDelete()
2739 self.checkVCSStatus() 2390 self.checkVCSStatus()
2740 else: 2391 else:
2741 res = False 2392 res = False
2742 2393
2743 return res 2394 return res
2744 2395
2745 def hgExport(self, name): 2396 def hgExport(self):
2746 """ 2397 """
2747 Public method to export patches to files. 2398 Public method to export patches to files.
2748 2399 """
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 2400 from .HgExportDialog import HgExportDialog
2761 dlg = HgExportDialog(self.hgGetBookmarksList(repodir), 2401 dlg = HgExportDialog(self.hgGetBookmarksList(),
2762 self.version >= (4, 7, 0)) 2402 self.version >= (4, 7, 0))
2763 if dlg.exec() == QDialog.Accepted: 2403 if dlg.exec() == QDialog.Accepted:
2764 (filePattern, revisions, bookmark, switchParent, allText, 2404 (filePattern, revisions, bookmark, switchParent, allText,
2765 noDates, git) = dlg.getParameters() 2405 noDates, git) = dlg.getParameters()
2766 2406
2782 else: 2422 else:
2783 for rev in revisions: 2423 for rev in revisions:
2784 args.append(rev) 2424 args.append(rev)
2785 2425
2786 dia = HgDialog(self.tr("Export Patches"), self) 2426 dia = HgDialog(self.tr("Export Patches"), self)
2787 res = dia.startProcess(args, repodir) 2427 res = dia.startProcess(args)
2788 if res: 2428 if res:
2789 dia.exec() 2429 dia.exec()
2790 2430
2791 def hgPhase(self, name, data=None): 2431 def hgPhase(self, data=None):
2792 """ 2432 """
2793 Public method to change the phase of revisions. 2433 Public method to change the phase of revisions.
2794 2434
2795 @param name directory name of the project to export from (string)
2796 @param data tuple giving phase data (list of revisions, phase, flag 2435 @param data tuple giving phase data (list of revisions, phase, flag
2797 indicating a forced operation) (list of strings, string, boolean) 2436 indicating a forced operation) (list of strings, string, boolean)
2798 @return flag indicating success (boolean) 2437 @return flag indicating success (boolean)
2799 @exception ValueError raised to indicate an invalid phase 2438 @exception ValueError raised to indicate an invalid phase
2800 """ 2439 """
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: 2440 if data is None:
2811 from .HgPhaseDialog import HgPhaseDialog 2441 from .HgPhaseDialog import HgPhaseDialog
2812 dlg = HgPhaseDialog() 2442 dlg = HgPhaseDialog()
2813 if dlg.exec() == QDialog.Accepted: 2443 if dlg.exec() == QDialog.Accepted:
2814 data = dlg.getData() 2444 data = dlg.getData()
2829 args.append("--force") 2459 args.append("--force")
2830 for rev in revs: 2460 for rev in revs:
2831 args.append(rev) 2461 args.append(rev)
2832 2462
2833 dia = HgDialog(self.tr("Change Phase"), self) 2463 dia = HgDialog(self.tr("Change Phase"), self)
2834 res = dia.startProcess(args, repodir) 2464 res = dia.startProcess(args)
2835 if res: 2465 if res:
2836 dia.exec() 2466 dia.exec()
2837 res = dia.normalExitWithoutErrors() 2467 res = dia.normalExitWithoutErrors()
2838 else: 2468 else:
2839 res = False 2469 res = False
2840 2470
2841 return res 2471 return res
2842 2472
2843 def hgGraft(self, path, revs=None): 2473 def hgGraft(self, revs=None):
2844 """ 2474 """
2845 Public method to copy changesets from another branch. 2475 Public method to copy changesets from another branch.
2846 2476
2847 @param path directory name of the project (string)
2848 @param revs list of revisions to show in the revisions pane (list of 2477 @param revs list of revisions to show in the revisions pane (list of
2849 strings) 2478 strings)
2850 @return flag indicating that the project should be reread (boolean) 2479 @return flag indicating that the project should be reread (boolean)
2851 """ 2480 """
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 2481 from .HgGraftDialog import HgGraftDialog
2860 res = False 2482 res = False
2861 dlg = HgGraftDialog(self, revs) 2483 dlg = HgGraftDialog(self, revs)
2862 if dlg.exec() == QDialog.Accepted: 2484 if dlg.exec() == QDialog.Accepted:
2863 (revs, 2485 (revs,
2886 if noCommit: 2508 if noCommit:
2887 args.append("--no-commit") 2509 args.append("--no-commit")
2888 args.extend(revs) 2510 args.extend(revs)
2889 2511
2890 dia = HgDialog(self.tr('Copy Changesets'), self) 2512 dia = HgDialog(self.tr('Copy Changesets'), self)
2891 res = dia.startProcess(args, repodir) 2513 res = dia.startProcess(args)
2892 if res: 2514 if res:
2893 dia.exec() 2515 dia.exec()
2894 res = dia.hasAddOrDelete() 2516 res = dia.hasAddOrDelete()
2895 self.checkVCSStatus() 2517 self.checkVCSStatus()
2896 return res 2518 return res
2897 2519
2898 def __hgGraftSubCommand(self, path, subcommand, title): 2520 def __hgGraftSubCommand(self, subcommand, title):
2899 """ 2521 """
2900 Private method to perform a Mercurial graft subcommand. 2522 Private method to perform a Mercurial graft subcommand.
2901 2523
2902 @param path directory name of the project
2903 @type str
2904 @param subcommand subcommand flag 2524 @param subcommand subcommand flag
2905 @type str 2525 @type str
2906 @param title tirle of the dialog 2526 @param title tirle of the dialog
2907 @type str 2527 @type str
2908 @return flag indicating that the project should be reread 2528 @return flag indicating that the project should be reread
2909 @rtype bool 2529 @rtype bool
2910 """ 2530 """
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") 2531 args = self.initCommand("graft")
2919 args.append(subcommand) 2532 args.append(subcommand)
2920 args.append("--verbose") 2533 args.append("--verbose")
2921 2534
2922 dia = HgDialog(title, self) 2535 dia = HgDialog(title, self)
2923 res = dia.startProcess(args, repodir) 2536 res = dia.startProcess(args)
2924 if res: 2537 if res:
2925 dia.exec() 2538 dia.exec()
2926 res = dia.hasAddOrDelete() 2539 res = dia.hasAddOrDelete()
2927 self.checkVCSStatus() 2540 self.checkVCSStatus()
2928 return res 2541 return res
2935 @type str 2548 @type str
2936 @return flag indicating that the project should be reread 2549 @return flag indicating that the project should be reread
2937 @rtype bool 2550 @rtype bool
2938 """ 2551 """
2939 return self.__hgGraftSubCommand( 2552 return self.__hgGraftSubCommand(
2940 path, "--continue", self.tr('Copy Changesets (Continue)')) 2553 "--continue", self.tr('Copy Changesets (Continue)'))
2941 2554
2942 def hgGraftStop(self, path): 2555 def hgGraftStop(self, path):
2943 """ 2556 """
2944 Public method to stop an interrupted copying session. 2557 Public method to stop an interrupted copying session.
2945 2558
2947 @type str 2560 @type str
2948 @return flag indicating that the project should be reread 2561 @return flag indicating that the project should be reread
2949 @rtype bool 2562 @rtype bool
2950 """ 2563 """
2951 return self.__hgGraftSubCommand( 2564 return self.__hgGraftSubCommand(
2952 path, "--stop", self.tr('Copy Changesets (Stop)')) 2565 "--stop", self.tr('Copy Changesets (Stop)'))
2953 2566
2954 def hgGraftAbort(self, path): 2567 def hgGraftAbort(self, path):
2955 """ 2568 """
2956 Public method to abort an interrupted copying session and perform 2569 Public method to abort an interrupted copying session and perform
2957 a rollback. 2570 a rollback.
2960 @type str 2573 @type str
2961 @return flag indicating that the project should be reread 2574 @return flag indicating that the project should be reread
2962 @rtype bool 2575 @rtype bool
2963 """ 2576 """
2964 return self.__hgGraftSubCommand( 2577 return self.__hgGraftSubCommand(
2965 path, "--abort", self.tr('Copy Changesets (Abort)')) 2578 "--abort", self.tr('Copy Changesets (Abort)'))
2966 2579
2967 def hgArchive(self): 2580 def hgArchive(self):
2968 """ 2581 """
2969 Public method to create an unversioned archive from the repository. 2582 Public method to create an unversioned archive from the repository.
2970 """ 2583 """
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 2584 from .HgArchiveDialog import HgArchiveDialog
2979 dlg = HgArchiveDialog(self) 2585 dlg = HgArchiveDialog(self)
2980 if dlg.exec() == QDialog.Accepted: 2586 if dlg.exec() == QDialog.Accepted:
2981 archive, type_, prefix, subrepos = dlg.getData() 2587 archive, type_, prefix, subrepos = dlg.getData()
2982 2588
2990 if subrepos: 2596 if subrepos:
2991 args.append("--subrepos") 2597 args.append("--subrepos")
2992 args.append(archive) 2598 args.append(archive)
2993 2599
2994 dia = HgDialog(self.tr("Create Unversioned Archive"), self) 2600 dia = HgDialog(self.tr("Create Unversioned Archive"), self)
2995 res = dia.startProcess(args, repodir) 2601 res = dia.startProcess(args)
2996 if res: 2602 if res:
2997 dia.exec() 2603 dia.exec()
2998 2604
2999 def hgDeleteBackups(self): 2605 def hgDeleteBackups(self):
3000 """ 2606 """
3016 backupdir)) 2622 backupdir))
3017 if yes: 2623 if yes:
3018 shutil.rmtree(backupdir, True) 2624 shutil.rmtree(backupdir, True)
3019 2625
3020 ########################################################################### 2626 ###########################################################################
3021 ## Methods to deal with subrepositories are below. 2627 ## Methods to deal with sub-repositories are below.
3022 ########################################################################### 2628 ###########################################################################
3023 2629
3024 def getHgSubPath(self): 2630 def getHgSubPath(self):
3025 """ 2631 """
3026 Public method to get the path to the .hgsub file containing the 2632 Public method to get the path to the .hgsub file containing the
3187 line.startswith("paths.default-push=") and 2793 line.startswith("paths.default-push=") and
3188 not line.endswith("=") 2794 not line.endswith("=")
3189 ): 2795 ):
3190 self.__defaultPushConfigured = True 2796 self.__defaultPushConfigured = True
3191 2797
3192 def canCommitMerge(self, name): 2798 def canCommitMerge(self):
3193 """ 2799 """
3194 Public method to check, if the working directory is an uncommitted 2800 Public method to check, if the working directory is an uncommitted
3195 merge. 2801 merge.
3196 2802
3197 @param name file/directory name
3198 @type str
3199 @return flag indicating commit merge capability 2803 @return flag indicating commit merge capability
3200 @rtype bool 2804 @rtype bool
3201 """ 2805 """
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") 2806 args = self.initCommand("identify")
3212 2807
3213 output, error = self.__client.runcommand(args) 2808 output, error = self.__client.runcommand(args)
3214 2809
3215 return output.count('+') == 2 2810 return output.count('+') == 2
3410 if self.__client is not None: 3005 if self.__client is not None:
3411 self.__client.stopServer() 3006 self.__client.stopServer()
3412 self.__client = None 3007 self.__client = None
3413 3008
3414 ########################################################################### 3009 ###########################################################################
3415 ## Status Monitor Thread methods 3010 ## Status Monitor Thread methods
3416 ########################################################################### 3011 ###########################################################################
3417 3012
3418 def _createStatusMonitorThread(self, interval, project): 3013 def _createStatusMonitorThread(self, interval, project):
3419 """ 3014 """
3420 Protected method to create an instance of the VCS status monitor 3015 Protected method to create an instance of the VCS status monitor
3427 """ 3022 """
3428 from .HgStatusMonitorThread import HgStatusMonitorThread 3023 from .HgStatusMonitorThread import HgStatusMonitorThread
3429 return HgStatusMonitorThread(interval, project, self) 3024 return HgStatusMonitorThread(interval, project, self)
3430 3025
3431 ########################################################################### 3026 ###########################################################################
3432 ## Bookmarks methods 3027 ## Bookmarks methods
3433 ########################################################################### 3028 ###########################################################################
3434 3029
3435 def hgListBookmarks(self, path): 3030 def hgListBookmarks(self):
3436 """ 3031 """
3437 Public method used to list the available bookmarks. 3032 Public method used to list the available bookmarks.
3438
3439 @param path directory name of the project (string)
3440 """ 3033 """
3441 self.bookmarksList = [] 3034 self.bookmarksList = []
3442 3035
3443 if self.bookmarksListDlg is None: 3036 if self.bookmarksListDlg is None:
3444 from .HgBookmarksListDialog import HgBookmarksListDialog 3037 from .HgBookmarksListDialog import HgBookmarksListDialog
3445 self.bookmarksListDlg = HgBookmarksListDialog(self) 3038 self.bookmarksListDlg = HgBookmarksListDialog(self)
3446 self.bookmarksListDlg.show() 3039 self.bookmarksListDlg.show()
3447 self.bookmarksListDlg.raise_() 3040 self.bookmarksListDlg.raise_()
3448 self.bookmarksListDlg.start(path, self.bookmarksList) 3041 self.bookmarksListDlg.start(self.bookmarksList)
3449 3042
3450 def hgGetBookmarksList(self, repodir): 3043 def hgGetBookmarksList(self):
3451 """ 3044 """
3452 Public method to get the list of bookmarks. 3045 Public method to get the list of bookmarks.
3453 3046
3454 @param repodir directory name of the repository (string)
3455 @return list of bookmarks (list of string) 3047 @return list of bookmarks (list of string)
3456 """ 3048 """
3457 args = self.initCommand("bookmarks") 3049 args = self.initCommand("bookmarks")
3458 3050
3459 client = self.getClient() 3051 client = self.getClient()
3470 name = " ".join(li) 3062 name = " ".join(li)
3471 self.bookmarksList.append(name) 3063 self.bookmarksList.append(name)
3472 3064
3473 return self.bookmarksList[:] 3065 return self.bookmarksList[:]
3474 3066
3475 def hgBookmarkDefine(self, name, revision=None, bookmark=None): 3067 def hgBookmarkDefine(self, revision=None, bookmark=None):
3476 """ 3068 """
3477 Public method to define a bookmark. 3069 Public method to define a bookmark.
3478 3070
3479 @param name file/directory name (string)
3480 @param revision revision to set bookmark for (string) 3071 @param revision revision to set bookmark for (string)
3481 @param bookmark name of the bookmark (string) 3072 @param bookmark name of the bookmark (string)
3482 """ 3073 """
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): 3074 if bool(revision) and bool(bookmark):
3491 ok = True 3075 ok = True
3492 else: 3076 else:
3493 from .HgBookmarkDialog import HgBookmarkDialog 3077 from .HgBookmarkDialog import HgBookmarkDialog
3494 dlg = HgBookmarkDialog(HgBookmarkDialog.DEFINE_MODE, 3078 dlg = HgBookmarkDialog(HgBookmarkDialog.DEFINE_MODE,
3495 self.hgGetTagsList(repodir), 3079 self.hgGetTagsList(),
3496 self.hgGetBranchesList(repodir), 3080 self.hgGetBranchesList(),
3497 self.hgGetBookmarksList(repodir)) 3081 self.hgGetBookmarksList())
3498 if dlg.exec() == QDialog.Accepted: 3082 if dlg.exec() == QDialog.Accepted:
3499 revision, bookmark = dlg.getData() 3083 revision, bookmark = dlg.getData()
3500 ok = True 3084 ok = True
3501 else: 3085 else:
3502 ok = False 3086 ok = False
3507 args.append("--rev") 3091 args.append("--rev")
3508 args.append(revision) 3092 args.append(revision)
3509 args.append(bookmark) 3093 args.append(bookmark)
3510 3094
3511 dia = HgDialog(self.tr('Mercurial Bookmark'), self) 3095 dia = HgDialog(self.tr('Mercurial Bookmark'), self)
3512 res = dia.startProcess(args, repodir) 3096 res = dia.startProcess(args)
3513 if res: 3097 if res:
3514 dia.exec() 3098 dia.exec()
3515 3099
3516 def hgBookmarkDelete(self, name, bookmark=None): 3100 def hgBookmarkDelete(self, bookmark=None):
3517 """ 3101 """
3518 Public method to delete a bookmark. 3102 Public method to delete a bookmark.
3519 3103
3520 @param name file/directory name (string)
3521 @param bookmark name of the bookmark (string) 3104 @param bookmark name of the bookmark (string)
3522 """ 3105 """
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: 3106 if bookmark:
3531 ok = True 3107 ok = True
3532 else: 3108 else:
3533 bookmark, ok = QInputDialog.getItem( 3109 bookmark, ok = QInputDialog.getItem(
3534 None, 3110 None,
3535 self.tr("Delete Bookmark"), 3111 self.tr("Delete Bookmark"),
3536 self.tr("Select the bookmark to be deleted:"), 3112 self.tr("Select the bookmark to be deleted:"),
3537 [""] + sorted(self.hgGetBookmarksList(repodir)), 3113 [""] + sorted(self.hgGetBookmarksList()),
3538 0, True) 3114 0, True)
3539 if ok and bookmark: 3115 if ok and bookmark:
3540 args = self.initCommand("bookmarks") 3116 args = self.initCommand("bookmarks")
3541 args.append("--delete") 3117 args.append("--delete")
3542 args.append(bookmark) 3118 args.append(bookmark)
3543 3119
3544 dia = HgDialog(self.tr('Delete Mercurial Bookmark'), self) 3120 dia = HgDialog(self.tr('Delete Mercurial Bookmark'), self)
3545 res = dia.startProcess(args, repodir) 3121 res = dia.startProcess(args)
3546 if res: 3122 if res:
3547 dia.exec() 3123 dia.exec()
3548 3124
3549 def hgBookmarkRename(self, name, renameInfo=None): 3125 def hgBookmarkRename(self, renameInfo=None):
3550 """ 3126 """
3551 Public method to rename a bookmark. 3127 Public method to rename a bookmark.
3552 3128
3553 @param name file/directory name
3554 @type str
3555 @param renameInfo old and new names of the bookmark 3129 @param renameInfo old and new names of the bookmark
3556 @type tuple of str and str 3130 @type tuple of str and str
3557 """ 3131 """
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: 3132 if not renameInfo:
3566 from .HgBookmarkRenameDialog import HgBookmarkRenameDialog 3133 from .HgBookmarkRenameDialog import HgBookmarkRenameDialog
3567 dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList(repodir)) 3134 dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList())
3568 if dlg.exec() == QDialog.Accepted: 3135 if dlg.exec() == QDialog.Accepted:
3569 renameInfo = dlg.getData() 3136 renameInfo = dlg.getData()
3570 3137
3571 if renameInfo: 3138 if renameInfo:
3572 args = self.initCommand("bookmarks") 3139 args = self.initCommand("bookmarks")
3573 args.append("--rename") 3140 args.append("--rename")
3574 args.append(renameInfo[0]) 3141 args.append(renameInfo[0])
3575 args.append(renameInfo[1]) 3142 args.append(renameInfo[1])
3576 3143
3577 dia = HgDialog(self.tr('Rename Mercurial Bookmark'), self) 3144 dia = HgDialog(self.tr('Rename Mercurial Bookmark'), self)
3578 res = dia.startProcess(args, repodir) 3145 res = dia.startProcess(args)
3579 if res: 3146 if res:
3580 dia.exec() 3147 dia.exec()
3581 3148
3582 def hgBookmarkMove(self, name, revision=None, bookmark=None): 3149 def hgBookmarkMove(self, revision=None, bookmark=None):
3583 """ 3150 """
3584 Public method to move a bookmark. 3151 Public method to move a bookmark.
3585 3152
3586 @param name file/directory name (string)
3587 @param revision revision to set bookmark for (string) 3153 @param revision revision to set bookmark for (string)
3588 @param bookmark name of the bookmark (string) 3154 @param bookmark name of the bookmark (string)
3589 """ 3155 """
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): 3156 if bool(revision) and bool(bookmark):
3598 ok = True 3157 ok = True
3599 else: 3158 else:
3600 from .HgBookmarkDialog import HgBookmarkDialog 3159 from .HgBookmarkDialog import HgBookmarkDialog
3601 dlg = HgBookmarkDialog(HgBookmarkDialog.MOVE_MODE, 3160 dlg = HgBookmarkDialog(HgBookmarkDialog.MOVE_MODE,
3602 self.hgGetTagsList(repodir), 3161 self.hgGetTagsList(),
3603 self.hgGetBranchesList(repodir), 3162 self.hgGetBranchesList(),
3604 self.hgGetBookmarksList(repodir)) 3163 self.hgGetBookmarksList())
3605 if dlg.exec() == QDialog.Accepted: 3164 if dlg.exec() == QDialog.Accepted:
3606 revision, bookmark = dlg.getData() 3165 revision, bookmark = dlg.getData()
3607 ok = True 3166 ok = True
3608 else: 3167 else:
3609 ok = False 3168 ok = False
3615 args.append("--rev") 3174 args.append("--rev")
3616 args.append(revision) 3175 args.append(revision)
3617 args.append(bookmark) 3176 args.append(bookmark)
3618 3177
3619 dia = HgDialog(self.tr('Move Mercurial Bookmark'), self) 3178 dia = HgDialog(self.tr('Move Mercurial Bookmark'), self)
3620 res = dia.startProcess(args, repodir) 3179 res = dia.startProcess(args)
3621 if res: 3180 if res:
3622 dia.exec() 3181 dia.exec()
3623 3182
3624 def hgBookmarkIncoming(self, name): 3183 def hgBookmarkIncoming(self):
3625 """ 3184 """
3626 Public method to show a list of incoming bookmarks. 3185 Public method to show a list of incoming bookmarks.
3627
3628 @param name file/directory name (string)
3629 """ 3186 """
3630 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog 3187 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog
3631 self.bookmarksInOutDlg = HgBookmarksInOutDialog( 3188 self.bookmarksInOutDlg = HgBookmarksInOutDialog(
3632 self, HgBookmarksInOutDialog.INCOMING) 3189 self, HgBookmarksInOutDialog.INCOMING)
3633 self.bookmarksInOutDlg.show() 3190 self.bookmarksInOutDlg.show()
3634 self.bookmarksInOutDlg.start(name) 3191 self.bookmarksInOutDlg.start()
3635 3192
3636 def hgBookmarkOutgoing(self, name): 3193 def hgBookmarkOutgoing(self):
3637 """ 3194 """
3638 Public method to show a list of outgoing bookmarks. 3195 Public method to show a list of outgoing bookmarks.
3639
3640 @param name file/directory name (string)
3641 """ 3196 """
3642 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog 3197 from .HgBookmarksInOutDialog import HgBookmarksInOutDialog
3643 self.bookmarksInOutDlg = HgBookmarksInOutDialog( 3198 self.bookmarksInOutDlg = HgBookmarksInOutDialog(
3644 self, HgBookmarksInOutDialog.OUTGOING) 3199 self, HgBookmarksInOutDialog.OUTGOING)
3645 self.bookmarksInOutDlg.show() 3200 self.bookmarksInOutDlg.show()
3646 self.bookmarksInOutDlg.start(name) 3201 self.bookmarksInOutDlg.start()
3647 3202
3648 def __getInOutBookmarks(self, repodir, incoming): 3203 def __getInOutBookmarks(self, incoming):
3649 """ 3204 """
3650 Private method to get the list of incoming or outgoing bookmarks. 3205 Private method to get the list of incoming or outgoing bookmarks.
3651 3206
3652 @param repodir directory name of the repository (string)
3653 @param incoming flag indicating to get incoming bookmarks (boolean) 3207 @param incoming flag indicating to get incoming bookmarks (boolean)
3654 @return list of bookmarks (list of string) 3208 @return list of bookmarks (list of string)
3655 """ 3209 """
3656 bookmarksList = [] 3210 bookmarksList = []
3657 3211
3671 name = " ".join(li) 3225 name = " ".join(li)
3672 bookmarksList.append(name) 3226 bookmarksList.append(name)
3673 3227
3674 return bookmarksList 3228 return bookmarksList
3675 3229
3676 def hgBookmarkPull(self, name, current=False, bookmark=None): 3230 def hgBookmarkPull(self, current=False, bookmark=None):
3677 """ 3231 """
3678 Public method to pull a bookmark from a remote repository. 3232 Public method to pull a bookmark from a remote repository.
3679 3233
3680 @param name file/directory name
3681 @type str
3682 @param current flag indicating to pull the current bookmark 3234 @param current flag indicating to pull the current bookmark
3683 @type bool 3235 @type bool
3684 @param bookmark name of the bookmark 3236 @param bookmark name of the bookmark
3685 @type str 3237 @type str
3686 """ 3238 """
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: 3239 if current:
3695 bookmark = "." 3240 bookmark = "."
3696 ok = True 3241 ok = True
3697 elif bookmark: 3242 elif bookmark:
3698 ok = True 3243 ok = True
3699 else: 3244 else:
3700 bookmarks = self.__getInOutBookmarks(repodir, True) 3245 bookmarks = self.__getInOutBookmarks(True)
3701 bookmark, ok = QInputDialog.getItem( 3246 bookmark, ok = QInputDialog.getItem(
3702 None, 3247 None,
3703 self.tr("Pull Bookmark"), 3248 self.tr("Pull Bookmark"),
3704 self.tr("Select the bookmark to be pulled:"), 3249 self.tr("Select the bookmark to be pulled:"),
3705 [""] + sorted(bookmarks), 3250 [""] + sorted(bookmarks),
3711 args.append(bookmark) 3256 args.append(bookmark)
3712 3257
3713 dia = HgDialog(self.tr( 3258 dia = HgDialog(self.tr(
3714 'Pulling bookmark from a remote Mercurial repository'), 3259 'Pulling bookmark from a remote Mercurial repository'),
3715 self) 3260 self)
3716 res = dia.startProcess(args, repodir) 3261 res = dia.startProcess(args)
3717 if res: 3262 if res:
3718 dia.exec() 3263 dia.exec()
3719 3264
3720 def hgBookmarkPush(self, name, current=False, bookmark=None): 3265 def hgBookmarkPush(self, current=False, bookmark=None):
3721 """ 3266 """
3722 Public method to push a bookmark to a remote repository. 3267 Public method to push a bookmark to a remote repository.
3723 3268
3724 @param name file/directory name
3725 @type str
3726 @param current flag indicating to push the current bookmark 3269 @param current flag indicating to push the current bookmark
3727 @type bool 3270 @type bool
3728 @param bookmark name of the bookmark 3271 @param bookmark name of the bookmark
3729 @type str 3272 @type str
3730 """ 3273 """
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: 3274 if current:
3739 bookmark = "." 3275 bookmark = "."
3740 ok = True 3276 ok = True
3741 elif bookmark: 3277 elif bookmark:
3742 ok = True 3278 ok = True
3743 else: 3279 else:
3744 bookmarks = self.__getInOutBookmarks(repodir, False) 3280 bookmarks = self.__getInOutBookmarks(False)
3745 bookmark, ok = QInputDialog.getItem( 3281 bookmark, ok = QInputDialog.getItem(
3746 None, 3282 None,
3747 self.tr("Push Bookmark"), 3283 self.tr("Push Bookmark"),
3748 self.tr("Select the bookmark to be push:"), 3284 self.tr("Select the bookmark to be push:"),
3749 [""] + sorted(bookmarks), 3285 [""] + sorted(bookmarks),
3755 args.append(bookmark) 3291 args.append(bookmark)
3756 3292
3757 dia = HgDialog(self.tr( 3293 dia = HgDialog(self.tr(
3758 'Pushing bookmark to a remote Mercurial repository'), 3294 'Pushing bookmark to a remote Mercurial repository'),
3759 self) 3295 self)
3760 res = dia.startProcess(args, repodir) 3296 res = dia.startProcess(args)
3761 if res: 3297 if res:
3762 dia.exec() 3298 dia.exec()

eric ide

mercurial