Source code for gdeps.hg

#!python3

# Copyright 2007-2017 Gemr. All Rights Reserved.
# Licensed to MIT see LICENSE.txt

import os
import gdeps as GDeps

__author__ = 'Suryavarman (http://sourceforge.net/u/suryavarman/profile/)'


[docs]class Mercurial(GDeps.Versioning): def __init__(self, inConfigFile, inFolderPath, inLogFileDirectory, inReposUrl, inCloneArgs="", inUpdateArgs="", inSectionName="hg", inExePath=r"C:\\Program Files\\Mercurial\\hg.exe"): # """C:\\Program Files\\TortoiseHg\\hg.exe""" ): """ .. note: if you have a SSL certificate problem: self signed certificate in certificate chain : 1) Try to use the read only link : sourceforge : use -> http://hg.code.sf.net/REPOSNAME/code bitbucket : use -> ssh://hg@bitbucket.org/REPOSOWNERNAME/REPOSNAME 2) - Create an account on the platform (like bitbucket/sourceforge - create an asynchrone key - use a service like pageant/keypass-pageant to automatically load the key https://www.selenic.com/mercurial/hg.1.html -U --noupdate the clone will include an empty working directory (only a repository) -u --updaterev REV revision, tag, or branch to check out -r --rev REV [+] include the specified changeset -b --branch BRANCH [+] clone only the specified branch --pull use pull protocol to copy metadata --uncompressed use uncompressed transfer (fast over LAN) -e --ssh CMD specify ssh command to use --remotecmd CMD specify hg command to run on the remote side --insecure do not verify server certificate (ignoring web.cacerts config) --stupid use slower, but more compatible, protocol for Subversion -T --tagpaths VALUE list of paths to search for tags in Subversion repositories --branchdir VALUE path to search for branches in subversion repositories --trunkdir VALUE path to trunk in subversion repositories --infix VALUE path relative to trunk, branch an tag dirs to import -A --authors VALUE file mapping Subversion usernames to Mercurial authors --filemap VALUE file containing rules for remapping Subversion repository paths --layout VALUE import standard layout or single directory? Can be standard, single, or auto. (default: auto) --branchmap VALUE file containing rules for branch conversion --tagmap VALUE file containing rules for renaming tags --startrev VALUE convert Subversion revisions starting at the one specified, either an integer revision or HEAD; HEAD causes only the latest revision to be pulled global options ([+] can be repeated): -R --repository REPO repository root directory or name of overlay bundle file --cwd DIR change working directory -y --noninteractive do not prompt, automatically pick the first choice for all prompts -q --quiet suppress output -v --verbose enable additional output --config CONFIG [+] set/override config option (use 'section.name=value') --debug enable debugging output --debugger start debugger --encoding ENCODE set the charset encoding (default: cp1252) --encodingmode MODE set the charset encoding mode (default: strict) --traceback always print a traceback on exception --time time how long the command takes --profile print command execution profile --version output version information and exit -h --help display help and exit --hidden consider hidden changesets """ GDeps.Versioning.__init__(self, inConfigFile, inFolderPath, inLogFileDirectory, inReposUrl, inCloneArgs, inUpdateArgs, inSectionName, inExePath) self.m_ErrorRegexp = r"(.*abort:.*|.*invalid.*)"
[docs] def clone(self): aReport = GDeps.Versioning.clone(self) aCommand = self.getCMDExePath() aHgCommand = "clone " if self.m_CloneArgs: aHgCommand += self.m_CloneArgs + " " aHgCommand += "--insecure --verbose " aCommand += aHgCommand + self.m_ReposUrl + " " aCommand += self.getCloneTmpDir() self.CloneNoEmptyDir(aCommand, "hg-clone", aReport) return aReport
[docs] def update(self): aReport = GDeps.Versioning.update(self) aCommand = self.getCMDExePath() aHgCommand = "update" if self.m_UpdateArgs: aHgCommand += " " + self.m_UpdateArgs aCommand += aHgCommand aCurrentDir = os.getcwd() os.chdir(self.m_FolderPath) self.callWithLogFile(aCommand, "hg-update", aReport, self) os.chdir(aCurrentDir) return aReport
[docs] def clean(self): """ http://mercurial.selenic.com/wiki/GitConcepts http://antonym.org/2010/04/25-tips-for-intermediate-mercurial-users.html """ aReport = GDeps.Versioning.clean(self) aCommand = self.getCMDExePath() aHgCommand = "revert -a --no-backup" aCommand += aHgCommand aCurrentDir = os.getcwd() os.chdir(self.m_FolderPath) self.callWithLogFile(aCommand, "hg-clean", aReport, self) os.chdir(aCurrentDir) return aReport
[docs] def getFolderRepoConfigPath(self): return ".hg"