Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 5328
9c11e9285a46
parent 5322
c2cabdca0734
child 5329
ebec303b4e50
equal deleted inserted replaced
5327:1bf444289f77 5328:9c11e9285a46
3627 dia = HgDialog(self.tr('Mercurial Bookmark'), self) 3627 dia = HgDialog(self.tr('Mercurial Bookmark'), self)
3628 res = dia.startProcess(args, repodir) 3628 res = dia.startProcess(args, repodir)
3629 if res: 3629 if res:
3630 dia.exec_() 3630 dia.exec_()
3631 3631
3632 def hgBookmarkDelete(self, name): 3632 def hgBookmarkDelete(self, name, bookmark=None):
3633 """ 3633 """
3634 Public method to delete a bookmark. 3634 Public method to delete a bookmark.
3635 3635
3636 @param name file/directory name (string) 3636 @param name file/directory name (string)
3637 @param bookmark name of the bookmark (string)
3637 """ 3638 """
3638 # find the root of the repo 3639 # find the root of the repo
3639 repodir = self.splitPath(name)[0] 3640 repodir = self.splitPath(name)[0]
3640 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3641 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3641 repodir = os.path.dirname(repodir) 3642 repodir = os.path.dirname(repodir)
3642 if os.path.splitdrive(repodir)[1] == os.sep: 3643 if os.path.splitdrive(repodir)[1] == os.sep:
3643 return 3644 return
3644 3645
3645 bookmark, ok = QInputDialog.getItem( 3646 if bookmark:
3646 None, 3647 ok = True
3647 self.tr("Delete Bookmark"), 3648 else:
3648 self.tr("Select the bookmark to be deleted:"), 3649 bookmark, ok = QInputDialog.getItem(
3649 [""] + sorted(self.hgGetBookmarksList(repodir)), 3650 None,
3650 0, True) 3651 self.tr("Delete Bookmark"),
3652 self.tr("Select the bookmark to be deleted:"),
3653 [""] + sorted(self.hgGetBookmarksList(repodir)),
3654 0, True)
3651 if ok and bookmark: 3655 if ok and bookmark:
3652 args = self.initCommand("bookmarks") 3656 args = self.initCommand("bookmarks")
3653 args.append("--delete") 3657 args.append("--delete")
3654 args.append(bookmark) 3658 args.append(bookmark)
3655 3659
3656 dia = HgDialog(self.tr('Delete Mercurial Bookmark'), self) 3660 dia = HgDialog(self.tr('Delete Mercurial Bookmark'), self)
3657 res = dia.startProcess(args, repodir) 3661 res = dia.startProcess(args, repodir)
3658 if res: 3662 if res:
3659 dia.exec_() 3663 dia.exec_()
3660 3664
3661 def hgBookmarkRename(self, name): 3665 def hgBookmarkRename(self, name, renameInfo=None):
3662 """ 3666 """
3663 Public method to rename a bookmark. 3667 Public method to rename a bookmark.
3664 3668
3665 @param name file/directory name (string) 3669 @param name file/directory name
3670 @type str
3671 @param renameInfo old and new names of the bookmark
3672 @type tuple of str and str
3666 """ 3673 """
3667 # find the root of the repo 3674 # find the root of the repo
3668 repodir = self.splitPath(name)[0] 3675 repodir = self.splitPath(name)[0]
3669 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3676 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3670 repodir = os.path.dirname(repodir) 3677 repodir = os.path.dirname(repodir)
3671 if os.path.splitdrive(repodir)[1] == os.sep: 3678 if os.path.splitdrive(repodir)[1] == os.sep:
3672 return 3679 return
3673 3680
3674 from .HgBookmarkRenameDialog import HgBookmarkRenameDialog 3681 if not renameInfo:
3675 dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList(repodir)) 3682 from .HgBookmarkRenameDialog import HgBookmarkRenameDialog
3676 if dlg.exec_() == QDialog.Accepted: 3683 dlg = HgBookmarkRenameDialog(self.hgGetBookmarksList(repodir))
3677 newName, oldName = dlg.getData() 3684 if dlg.exec_() == QDialog.Accepted:
3678 3685 renameInfo = dlg.getData()
3686
3687 if renameInfo:
3679 args = self.initCommand("bookmarks") 3688 args = self.initCommand("bookmarks")
3680 args.append("--rename") 3689 args.append("--rename")
3681 args.append(oldName) 3690 args.append(renameInfo[0])
3682 args.append(newName) 3691 args.append(renameInfo[1])
3683 3692
3684 dia = HgDialog(self.tr('Rename Mercurial Bookmark'), self) 3693 dia = HgDialog(self.tr('Rename Mercurial Bookmark'), self)
3685 res = dia.startProcess(args, repodir) 3694 res = dia.startProcess(args, repodir)
3686 if res: 3695 if res:
3687 dia.exec_() 3696 dia.exec_()
3790 name = " ".join(li) 3799 name = " ".join(li)
3791 bookmarksList.append(name) 3800 bookmarksList.append(name)
3792 3801
3793 return bookmarksList 3802 return bookmarksList
3794 3803
3795 def hgBookmarkPull(self, name, current=False): 3804 def hgBookmarkPull(self, name, current=False, bookmark=None):
3796 """ 3805 """
3797 Public method to pull a bookmark from a remote repository. 3806 Public method to pull a bookmark from a remote repository.
3798 3807
3799 @param name file/directory name 3808 @param name file/directory name
3800 @type str 3809 @type str
3801 @param current flag indicating to pull the current bookmark 3810 @param current flag indicating to pull the current bookmark
3802 @type bool 3811 @type bool
3812 @param bookmark name of the bookmark
3813 @type str
3803 """ 3814 """
3804 # find the root of the repo 3815 # find the root of the repo
3805 repodir = self.splitPath(name)[0] 3816 repodir = self.splitPath(name)[0]
3806 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3817 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3807 repodir = os.path.dirname(repodir) 3818 repodir = os.path.dirname(repodir)
3809 return 3820 return
3810 3821
3811 if current: 3822 if current:
3812 bookmark = "." 3823 bookmark = "."
3813 ok = True 3824 ok = True
3825 elif bookmark:
3826 ok = True
3814 else: 3827 else:
3815 bookmarks = self.__getInOutBookmarks(repodir, True) 3828 bookmarks = self.__getInOutBookmarks(repodir, True)
3816
3817 bookmark, ok = QInputDialog.getItem( 3829 bookmark, ok = QInputDialog.getItem(
3818 None, 3830 None,
3819 self.tr("Pull Bookmark"), 3831 self.tr("Pull Bookmark"),
3820 self.tr("Select the bookmark to be pulled:"), 3832 self.tr("Select the bookmark to be pulled:"),
3821 [""] + sorted(bookmarks), 3833 [""] + sorted(bookmarks),
3822 0, True) 3834 0, True)
3835
3823 if ok and bookmark: 3836 if ok and bookmark:
3824 args = self.initCommand("pull") 3837 args = self.initCommand("pull")
3825 args.append('--bookmark') 3838 args.append('--bookmark')
3826 args.append(bookmark) 3839 args.append(bookmark)
3827 3840
3830 self) 3843 self)
3831 res = dia.startProcess(args, repodir) 3844 res = dia.startProcess(args, repodir)
3832 if res: 3845 if res:
3833 dia.exec_() 3846 dia.exec_()
3834 3847
3835 def hgBookmarkPush(self, name, current=False): 3848 def hgBookmarkPush(self, name, current=False, bookmark=None):
3836 """ 3849 """
3837 Public method to push a bookmark to a remote repository. 3850 Public method to push a bookmark to a remote repository.
3838 3851
3839 @param name file/directory name 3852 @param name file/directory name
3840 @type str 3853 @type str
3841 @param current flag indicating to push the current bookmark 3854 @param current flag indicating to push the current bookmark
3842 @type bool 3855 @type bool
3856 @param bookmark name of the bookmark
3857 @type str
3843 """ 3858 """
3844 # find the root of the repo 3859 # find the root of the repo
3845 repodir = self.splitPath(name)[0] 3860 repodir = self.splitPath(name)[0]
3846 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3861 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3847 repodir = os.path.dirname(repodir) 3862 repodir = os.path.dirname(repodir)
3849 return 3864 return
3850 3865
3851 if current: 3866 if current:
3852 bookmark = "." 3867 bookmark = "."
3853 ok = True 3868 ok = True
3869 elif bookmark:
3870 ok = True
3854 else: 3871 else:
3855 bookmarks = self.__getInOutBookmarks(repodir, False) 3872 bookmarks = self.__getInOutBookmarks(repodir, False)
3856
3857 bookmark, ok = QInputDialog.getItem( 3873 bookmark, ok = QInputDialog.getItem(
3858 None, 3874 None,
3859 self.tr("Push Bookmark"), 3875 self.tr("Push Bookmark"),
3860 self.tr("Select the bookmark to be push:"), 3876 self.tr("Select the bookmark to be push:"),
3861 [""] + sorted(bookmarks), 3877 [""] + sorted(bookmarks),
3862 0, True) 3878 0, True)
3879
3863 if ok and bookmark: 3880 if ok and bookmark:
3864 args = self.initCommand("push") 3881 args = self.initCommand("push")
3865 args.append('--bookmark') 3882 args.append('--bookmark')
3866 args.append(bookmark) 3883 args.append(bookmark)
3867 3884

eric ide

mercurial