49 """ |
49 """ |
50 Class implementing the version control systems interface to Mercurial. |
50 Class implementing the version control systems interface to Mercurial. |
51 |
51 |
52 @signal committed() emitted after the commit action has completed |
52 @signal committed() emitted after the commit action has completed |
53 """ |
53 """ |
54 def __init__(self, plugin, parent=None, name=None): |
54 def __init__(self, plugin, parent = None, name = None): |
55 """ |
55 """ |
56 Constructor |
56 Constructor |
57 |
57 |
58 @param plugin reference to the plugin object |
58 @param plugin reference to the plugin object |
59 @param parent parent widget (QWidget) |
59 @param parent parent widget (QWidget) |
375 dia = HgDialog(self.trUtf8('Commiting changes to Mercurial repository')) |
377 dia = HgDialog(self.trUtf8('Commiting changes to Mercurial repository')) |
376 res = dia.startProcess(args, dname) |
378 res = dia.startProcess(args, dname) |
377 if res: |
379 if res: |
378 dia.exec_() |
380 dia.exec_() |
379 self.emit(SIGNAL("committed()")) |
381 self.emit(SIGNAL("committed()")) |
|
382 if self.__forgotNames: |
|
383 model = e5App().getObject("Project").getModel() |
|
384 for name in self.__forgotNames: |
|
385 model.updateVCSStatus(name) |
|
386 self.__forgotNames = [] |
380 self.checkVCSStatus() |
387 self.checkVCSStatus() |
381 |
388 |
382 def vcsUpdate(self, name, noDialog = False, revision = None): |
389 def vcsUpdate(self, name, noDialog = False, revision = None): |
383 """ |
390 """ |
384 Public method used to update a file/directory with the Mercurial repository. |
391 Public method used to update a file/directory with the Mercurial repository. |
1596 dia = HgDialog(self.trUtf8('Recovering from interrupted transaction')) |
1603 dia = HgDialog(self.trUtf8('Recovering from interrupted transaction')) |
1597 res = dia.startProcess(args, repodir, False) |
1604 res = dia.startProcess(args, repodir, False) |
1598 if res: |
1605 if res: |
1599 dia.exec_() |
1606 dia.exec_() |
1600 |
1607 |
|
1608 def hgIdentify(self, name): |
|
1609 """ |
|
1610 Public method to identify the current working directory. |
|
1611 |
|
1612 @param name file/directory name (string) |
|
1613 """ |
|
1614 dname, fname = self.splitPath(name) |
|
1615 |
|
1616 # find the root of the repo |
|
1617 repodir = str(dname) |
|
1618 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
1619 repodir = os.path.dirname(repodir) |
|
1620 if repodir == os.sep: |
|
1621 return |
|
1622 |
|
1623 args = [] |
|
1624 args.append('identify') |
|
1625 |
|
1626 dia = HgDialog(self.trUtf8('Identifying project directory')) |
|
1627 res = dia.startProcess(args, repodir, False) |
|
1628 if res: |
|
1629 dia.exec_() |
|
1630 |
1601 def hgCreateIgnoreFile(self, name, autoAdd = False): |
1631 def hgCreateIgnoreFile(self, name, autoAdd = False): |
1602 """ |
1632 """ |
1603 Public method to create the ignore file. |
1633 Public method to create the ignore file. |
1604 |
1634 |
1605 @param name directory name to create the ignore file in (string) |
1635 @param name directory name to create the ignore file in (string) |
1606 @param autoAdd flag indicating to add it automatically (boolean) |
1636 @param autoAdd flag indicating to add it automatically (boolean) |
1607 @return flag indicating success |
1637 @return flag indicating success |
1608 """ |
1638 """ |
|
1639 status = False |
1609 ignorePatterns = [ |
1640 ignorePatterns = [ |
1610 "glob:.eric5project", |
1641 "glob:.eric5project", |
1611 "glob:.ropeproject", |
1642 "glob:.ropeproject", |
1612 "glob:.directory", |
1643 "glob:.directory", |
1613 "glob:**.pyc", |
1644 "glob:**.pyc", |
1614 "glob:**.orig", |
1645 "glob:**.orig", |
1615 "glob:**.bak", |
1646 "glob:**.bak", |
1616 ] |
1647 ] |
1617 |
1648 |
1618 ignoreName = os.path.join(name, ".hgignore") |
1649 ignoreName = os.path.join(name, ".hgignore") |
1619 try: |
1650 if os.path.exists(ignoreName): |
1620 # create a .hgignore file |
1651 res = QMessageBox.warning(None, |
1621 ignore = open(ignoreName, "w") |
1652 self.trUtf8("Create .hgignore file"), |
1622 ignore.write("\n".join(ignorePatterns)) |
1653 self.trUtf8("""<p>The file <b>{0}</b> exists already.""" |
1623 ignore.write("\n") |
1654 """ Overwrite it?</p>""").format(ignoreName), |
1624 ignore.close() |
1655 QMessageBox.StandardButtons(\ |
1625 status = True |
1656 QMessageBox.No | \ |
1626 except IOError: |
1657 QMessageBox.Yes), |
1627 status = False |
1658 QMessageBox.No) |
1628 |
1659 else: |
1629 if status and autoAdd: |
1660 res = QMessageBox.Yes |
1630 self.vcsAdd(ignoreName, noDialog = True) |
1661 if res == QMessageBox.Yes: |
1631 project = e5App().getObject("Project") |
1662 try: |
1632 project.appendFile(ignoreName) |
1663 # create a .hgignore file |
|
1664 ignore = open(ignoreName, "w") |
|
1665 ignore.write("\n".join(ignorePatterns)) |
|
1666 ignore.write("\n") |
|
1667 ignore.close() |
|
1668 status = True |
|
1669 except IOError: |
|
1670 status = False |
|
1671 |
|
1672 if status and autoAdd: |
|
1673 self.vcsAdd(ignoreName, noDialog = True) |
|
1674 project = e5App().getObject("Project") |
|
1675 project.appendFile(ignoreName) |
1633 |
1676 |
1634 return status |
1677 return status |
1635 |
1678 |
1636 def hgBundle(self, name): |
1679 def hgBundle(self, name): |
1637 """ |
1680 """ |
1801 dia = HgDialog(self.trUtf8('Mercurial Bisect ({0})').format(subcommand)) |
1844 dia = HgDialog(self.trUtf8('Mercurial Bisect ({0})').format(subcommand)) |
1802 res = dia.startProcess(args, repodir) |
1845 res = dia.startProcess(args, repodir) |
1803 if res: |
1846 if res: |
1804 dia.exec_() |
1847 dia.exec_() |
1805 |
1848 |
|
1849 def hgForget(self, name): |
|
1850 """ |
|
1851 Public method used to remove a file from the Mercurial repository. |
|
1852 |
|
1853 This will not remove the file from the project directory. |
|
1854 |
|
1855 @param name file/directory name to be removed (string or list of strings)) |
|
1856 """ |
|
1857 args = [] |
|
1858 args.append('forget') |
|
1859 self.addArguments(args, self.options['global']) |
|
1860 args.append('-v') |
|
1861 |
|
1862 if isinstance(name, list): |
|
1863 dname, fnames = self.splitPathList(name) |
|
1864 self.addArguments(args, name) |
|
1865 else: |
|
1866 dname, fname = self.splitPath(name) |
|
1867 args.append(name) |
|
1868 |
|
1869 # find the root of the repo |
|
1870 repodir = dname |
|
1871 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
1872 repodir = os.path.dirname(repodir) |
|
1873 if repodir == os.sep: |
|
1874 return False |
|
1875 |
|
1876 dia = HgDialog(\ |
|
1877 self.trUtf8('Removing files from the Mercurial repository only')) |
|
1878 res = dia.startProcess(args, repodir) |
|
1879 if res: |
|
1880 dia.exec_() |
|
1881 if isinstance(name, list): |
|
1882 self.__forgotNames.extend(name) |
|
1883 else: |
|
1884 self.__forgotNames.append(name) |
|
1885 |
1806 ############################################################################ |
1886 ############################################################################ |
1807 ## Methods to get the helper objects are below. |
1887 ## Methods to get the helper objects are below. |
1808 ############################################################################ |
1888 ############################################################################ |
1809 |
1889 |
1810 def vcsGetProjectBrowserHelper(self, browser, project, isTranslationsBrowser = False): |
1890 def vcsGetProjectBrowserHelper(self, browser, project, isTranslationsBrowser = False): |