Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 3185
d4fa462547bc
parent 3160
209a07d7e401
child 3190
a9a94491c4fd
equal deleted inserted replaced
3182:a4ce50816cba 3185:d4fa462547bc
879 self.summary = HgSummaryDialog(self) 879 self.summary = HgSummaryDialog(self)
880 self.summary.show() 880 self.summary.show()
881 self.summary.start(self.__projectHelper.getProject().getProjectPath(), 881 self.summary.start(self.__projectHelper.getProject().getProjectPath(),
882 mq=mq) 882 mq=mq)
883 883
884 def vcsTag(self, name): 884 def vcsTag(self, name, revision=None, tagName=None):
885 """ 885 """
886 Public method used to set the tag in the Mercurial repository. 886 Public method used to set/remove a tag in the Mercurial repository.
887 887
888 @param name file/directory name to be tagged (string) 888 @param name file/directory name to determine the repo root from
889 (string)
890 @param revision revision to set tag for (string)
891 @param tagName name of the tag (string)
892 @return flag indicating a performed tag action (boolean)
889 """ 893 """
890 dname, fname = self.splitPath(name) 894 dname, fname = self.splitPath(name)
891 895
892 # find the root of the repo 896 # find the root of the repo
893 repodir = dname 897 repodir = dname
895 repodir = os.path.dirname(repodir) 899 repodir = os.path.dirname(repodir)
896 if os.path.splitdrive(repodir)[1] == os.sep: 900 if os.path.splitdrive(repodir)[1] == os.sep:
897 return 901 return
898 902
899 from .HgTagDialog import HgTagDialog 903 from .HgTagDialog import HgTagDialog
900 dlg = HgTagDialog(self.hgGetTagsList(repodir)) 904 dlg = HgTagDialog(self.hgGetTagsList(repodir, withType=True),
905 revision, tagName)
901 if dlg.exec_() == QDialog.Accepted: 906 if dlg.exec_() == QDialog.Accepted:
902 tag, tagOp = dlg.getParameters() 907 tag, revision, tagOp = dlg.getParameters()
903 else: 908 else:
904 return 909 return False
905 910
906 args = [] 911 args = []
907 args.append('tag') 912 args.append('tag')
908 if tagOp == HgTagDialog.CreateLocalTag: 913 msgPart = ""
914 if tagOp in [HgTagDialog.CreateLocalTag, HgTagDialog.DeleteLocalTag]:
909 args.append('--local') 915 args.append('--local')
910 elif tagOp == HgTagDialog.DeleteTag: 916 msgPart = "local "
917 else:
918 msgPart = "global "
919 if tagOp in [HgTagDialog.DeleteGlobalTag, HgTagDialog.DeleteLocalTag]:
911 args.append('--remove') 920 args.append('--remove')
921 if tagOp in [HgTagDialog.CreateGlobalTag, HgTagDialog.CreateLocalTag]:
922 if revision:
923 args.append("--rev")
924 args.append(revision)
912 args.append('--message') 925 args.append('--message')
913 if tagOp != HgTagDialog.DeleteTag: 926 if tagOp in [HgTagDialog.CreateGlobalTag, HgTagDialog.CreateLocalTag]:
914 tag = tag.strip().replace(" ", "_") 927 tag = tag.strip().replace(" ", "_")
915 args.append("Created tag <{0}>.".format(tag)) 928 args.append("Created {1}tag <{0}>.".format(tag, msgPart))
916 else: 929 else:
917 args.append("Removed tag <{0}>.".format(tag)) 930 args.append("Removed {1}tag <{0}>.".format(tag, msgPart))
918 args.append(tag) 931 args.append(tag)
919 932
920 dia = HgDialog(self.trUtf8('Taging in the Mercurial repository'), self) 933 dia = HgDialog(self.trUtf8('Tagging in the Mercurial repository'),
934 self)
921 res = dia.startProcess(args, repodir) 935 res = dia.startProcess(args, repodir)
922 if res: 936 if res:
923 dia.exec_() 937 dia.exec_()
938
939 return True
924 940
925 def hgRevert(self, name): 941 def hgRevert(self, name):
926 """ 942 """
927 Public method used to revert changes made to a file/directory. 943 Public method used to revert changes made to a file/directory.
928 944
1509 project.copyDirectory(name, target) 1525 project.copyDirectory(name, target)
1510 else: 1526 else:
1511 project.appendFile(target) 1527 project.appendFile(target)
1512 return res 1528 return res
1513 1529
1514 def hgGetTagsList(self, repodir): 1530 def hgGetTagsList(self, repodir, withType=False):
1515 """ 1531 """
1516 Public method to get the list of tags. 1532 Public method to get the list of tags.
1517 1533
1518 @param repodir directory name of the repository (string) 1534 @param repodir directory name of the repository (string)
1519 @return list of tags (list of string) 1535 @param withType flag indicating to get the tag type as well (boolean)
1536 @return list of tags (list of string) or list of tuples of
1537 tag name and flag indicating a local tag (list of tuple of string
1538 and boolean), if withType is True
1520 """ 1539 """
1521 args = [] 1540 args = []
1522 args.append('tags') 1541 args.append('tags')
1523 args.append('--verbose') 1542 args.append('--verbose')
1524 1543
1536 Preferences.getSystem("IOEncoding"), 1555 Preferences.getSystem("IOEncoding"),
1537 'replace') 1556 'replace')
1538 else: 1557 else:
1539 output, error = self.__client.runcommand(args) 1558 output, error = self.__client.runcommand(args)
1540 1559
1560 tagsList = []
1541 if output: 1561 if output:
1542 self.tagsList = []
1543 for line in output.splitlines(): 1562 for line in output.splitlines():
1544 li = line.strip().split() 1563 li = line.strip().split()
1545 if li[-1][0] in "1234567890": 1564 if li[-1][0] in "1234567890":
1546 # last element is a rev:changeset 1565 # last element is a rev:changeset
1547 del li[-1] 1566 del li[-1]
1567 isLocal = False
1548 else: 1568 else:
1549 del li[-2:] 1569 del li[-2:]
1570 isLocal = True
1550 name = " ".join(li) 1571 name = " ".join(li)
1551 if name not in ["tip", "default"]: 1572 if name not in ["tip", "default"]:
1552 self.tagsList.append(name) 1573 if withType:
1553 1574 tagsList.append((name, isLocal))
1554 return self.tagsList[:] 1575 else:
1576 tagsList.append(name)
1577
1578 if withType:
1579 return tagsList
1580 else:
1581 if tagsList:
1582 self.tagsList = tagsList
1583 return self.tagsList[:]
1555 1584
1556 def hgGetBranchesList(self, repodir): 1585 def hgGetBranchesList(self, repodir):
1557 """ 1586 """
1558 Public method to get the list of branches. 1587 Public method to get the list of branches.
1559 1588

eric ide

mercurial