--- a/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Wed Jan 13 20:13:26 2021 +0100 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Thu Jan 14 17:51:12 2021 +0100 @@ -1003,27 +1003,23 @@ """ Public method used to get the registered state of a file in the vcs. - @param name filename to check (string) + @param name file or directory name to check + @type str @return a combination of canBeCommited and canBeAdded + @rtype int """ if name.endswith(os.sep): name = name[:-1] name = os.path.normcase(name) - dname, fname = self.splitPath(name) - if fname == '.' and os.path.isdir(os.path.join(dname, self.adminDir)): + if ( + os.path.isdir(name) and + os.path.isdir(os.path.join(name, self.adminDir)) + ): return self.canBeCommitted if name in self.statusCache: return self.statusCache[name] - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return 0 - args = self.initCommand("status") args.append('--all') args.append('--noninteractive') @@ -1031,19 +1027,14 @@ output, error = self.__client.runcommand(args) if output: + repodir = self.getClient().getRepository() for line in output.splitlines(): if len(line) > 2 and line[0] in "MARC!?I" and line[1] == " ": flag, path = line.split(" ", 1) - absname = os.path.join(repodir, os.path.normcase(path)) - if flag not in "?I": - if fname == '.': - if absname.startswith(dname + os.path.sep): - return self.canBeCommitted - if absname == dname: - return self.canBeCommitted - else: - if absname == name: - return self.canBeCommitted + absname = Utilities.normcasepath( + os.path.join(repodir, path)) + if flag not in "?I" and absname == name: + return self.canBeCommitted return self.canBeAdded @@ -1073,13 +1064,6 @@ names[name] = self.statusCache[name] if not found: - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return names - args = self.initCommand("status") args.append('--all') args.append('--noninteractive') @@ -1087,11 +1071,12 @@ output, error = self.__client.runcommand(args) if output: + repoPath = self.getClient().getRepository() dirs = [x for x in names.keys() if os.path.isdir(x)] for line in output.splitlines(): if line and line[0] in "MARC!?I": flag, path = line.split(" ", 1) - name = os.path.normcase(os.path.join(repodir, path)) + name = os.path.normcase(os.path.join(repoPath, path)) dirName = os.path.dirname(name) if name.startswith(dname): if flag not in "?I": @@ -1594,7 +1579,7 @@ @param isFile flag indicating log for a file is to be shown (boolean) """ - if name == self.__repoDir: + if name == self.getClient().getRepository(): name = None if self.logBrowser is None: @@ -1913,7 +1898,7 @@ @type dict """ if repoName is None: - repoName = self.__repoDir + repoName = self.getClient().getRepository() cfgFile = os.path.join(repoName, self.adminDir, "hgrc") if not os.path.exists(cfgFile): @@ -2328,23 +2313,15 @@ if res: dia.exec() - def hgServe(self, name): + def hgServe(self, repoPath): """ Public method used to serve the project. - @param name directory name (string) + @param repoPath directory containing the repository + @type str """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if os.path.splitdrive(repodir)[1] == os.sep: - return - from .HgServeDialog import HgServeDialog - self.serveDlg = HgServeDialog(self, repodir) + self.serveDlg = HgServeDialog(self, repoPath) self.serveDlg.show() def hgImport(self): @@ -2607,7 +2584,8 @@ """ Public method to delete all backup bundles in the backup area. """ - backupdir = os.path.join(self.__repodir, self.adminDir, "strip-backup") + backupdir = os.path.join(self.getClient().getRepository(), + self.adminDir, "strip-backup") yes = E5MessageBox.yesNo( self.__ui, self.tr("Delete All Backups"), @@ -2842,22 +2820,14 @@ self.iniFileChanged.emit() - def __monitorRepoIniFile(self, name): + def __monitorRepoIniFile(self, repodir): """ Private slot to add a repository configuration file to the list of monitored files. - @param name directory name pointing into the repository (string) + @param repodir directory name of the repository + @type str """ - dname, fname = self.splitPath(name) - - # find the root of the repo - repodir = dname - while not os.path.isdir(os.path.join(repodir, self.adminDir)): - repodir = os.path.dirname(repodir) - if not repodir or os.path.splitdrive(repodir)[1] == os.sep: - return - cfgFile = os.path.join(repodir, self.adminDir, "hgrc") if os.path.exists(cfgFile): self.__iniWatcher.addPath(cfgFile)