コード例 #1
0
ファイル: hgflow.py プロジェクト: peixinchen/my-conf
    def _mergeIntoPublishBranch(self, target_branch, name, source_tag_name = None):
        commands.update(self.ui, self.repo, target_branch)

        #tag for publish
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        self.outputln('Close branch `%s`' % (target_branch))

        #TODO: source_tag_name should in source_branch
        if source_tag_name:
            commands.merge(self.ui, self.repo, source_tag_name)
            self.outputln('Merge TAG `%s` into PRODCTION branch.' % (source_tag_name, ))
        else:
            commands.merge(self.ui, self.repo, target_branch)
            self.outputln('Merge BRANCH `%s` into PRODCTION branch.' % (target_branch, ))
            
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
        commands.tag(self.ui, self.repo, tag_name)
        
        self.outputln('Merge BRANCH `%s` into DEVELOP branch.' % (target_branch, ))

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #2
0
ファイル: ftp.py プロジェクト: mPastuszko/dotfiles
    def run(self):
        if not self.repo.local:
            raise util.Abort(_('Repository "%s" is not local') % self.repo.root)

        self._check_changed()
        upload, remove = self._get_files()

        if self.opts.get('show'):
            self.ui.write(_('Upload files:\n'))
            for f in upload:
                self.ui.write('\t%s\n' % f)
            self.ui.write(_('\nDelete files:\n'))
            for f in remove:
                self.ui.write('\t%s\n' % f)

        self.ui.write(_('Upload files: %s, delete files: %s\n') %
                (len(upload), len(remove)) )

        if self.opts.get('upload'):
            if upload or remove:
                self._ftp(upload, remove)

            if not self.opts.get('only'):
                commands.tag(self.ui, self.repo, self.tagname,
                        local=not self.useGlobal,
                        rev=str(self.selected),
                        force=True)

                self.ui.write(_('Added tag %s for changeset %d:%s\n') %
                        (self.tagname, self.selected, self.selected))
コード例 #3
0
ファイル: hgflow.py プロジェクト: djm/dotfiles
    def _mergeIntoPublishBranch(self, target_branch, name, source_tag_name = None):
        commands.update(self.ui, self.repo, target_branch)

        #tag for publish
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)
        
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        self.outputln('Close branch `%s`' % (target_branch))

        #TODO: source_tag_name should in source_branch
        if source_tag_name:
            commands.merge(self.ui, self.repo, source_tag_name)
            self.outputln('Merge TAG `%s` into PRODCTION branch.' % (source_tag_name, ))
        else:
            commands.merge(self.ui, self.repo, target_branch)
            self.outputln('Merge BRANCH `%s` into PRODCTION branch.' % (target_branch, ))
            
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
        
        self.outputln('Merge BRANCH `%s` into DEVELOP branch.' % (target_branch, ))

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #4
0
ファイル: hgflow-0.2.py プロジェクト: yulka/yulka-dotfiles
    def _mergeIntoPublishBranch(self, target_branch, name):
        commands.update(self.ui, self.repo, target_branch)
        commands.commit(self.ui,
                        self.repo,
                        close_branch=True,
                        message='hg flow, close release %s' %
                        (target_branch, ))
        commands.update(self.ui, self.repo, self.publishBranch)

        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(
            self.ui,
            self.repo,
            close_branch=True,
            message='hg flow, merge release `%s` to publish branch `%s`' %
            (name, self.publishBranch))

        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, self.publishBranch)

        commands.commit(
            self.ui,
            self.repo,
            message='hg flow, merge release `%s` to develop branch `%s`' %
            (name, self.developBranch))
コード例 #5
0
ファイル: ftp.py プロジェクト: sirex/dotfiles
    def run(self):
        if not self.repo.local:
            raise util.Abort(
                _('Repository "%s" is not local') % self.repo.root)

        self._check_changed()
        upload, remove = self._get_files()

        if self.opts.get('show'):
            self.ui.write(_('Upload files:\n'))
            for f in upload:
                self.ui.write('\t%s\n' % f)
            self.ui.write(_('\nDelete files:\n'))
            for f in remove:
                self.ui.write('\t%s\n' % f)

        self.ui.write(
            _('Upload files: %s, delete files: %s\n') %
            (len(upload), len(remove)))

        if self.opts.get('upload'):
            if upload or remove:
                self._ftp(upload, remove)

            if not self.opts.get('only'):
                commands.tag(self.ui,
                             self.repo,
                             self.tagname,
                             local=not self.useGlobal,
                             rev=str(self.selected),
                             force=True)

                self.ui.write(
                    _('Added tag %s for changeset %d:%s\n') %
                    (self.tagname, self.selected, self.selected))
コード例 #6
0
ファイル: hgflow.py プロジェクト: d3m3vilurr/settings
    def _mergeIntoPublishBranch(self, target_branch, name, source_tag_name = None):
        commands.update(self.ui, self.repo, target_branch)

        #tag for publish
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        if source_tag_name:
            commands.tag(self.ui, self.repo, tag_name, rev=source_tag_name)
        else:
            commands.tag(self.ui, self.repo, tag_name)
        
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        self.outputln('close target_branch')


        if source_tag_name:
            commands.merge(self.ui, self.repo, source_tag_name)
        else:
            commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
        self.outputln('merge source_tag_name into publish branch')
        
        '''
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)
        '''
        self.outputln('merge target_branch into develop branch')

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #7
0
ファイル: hgflow-0.2.py プロジェクト: itspec-ru/dotfiles
    def _mergeIntoPublishBranch(self, target_branch, name):
        commands.update(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))

        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, self.publishBranch)

        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #8
0
ファイル: docs.py プロジェクト: Liuer/mezzanine
def build_changelog(docs_path, package_name="mezzanine"):
    """
    Converts Mercurial commits into a changelog in RST format.
    """

    project_path = os.path.join(docs_path, "..")
    version_file = os.path.join(package_name, "__init__.py")
    version_var = "__version__"
    changelog_filename = "CHANGELOG"
    changelog_file = os.path.join(project_path, changelog_filename)
    versions = OrderedDict()
    repo = None
    ignore = (
        "AUTHORS",
        "formatting",
        "typo",
        "pep8",
        "pep 8",
        "whitespace",
        "README",
        "trans",
        "print debug",
        "debugging",
        "tabs",
        "style",
        "sites",
        "ignore",
        "tweak",
        "cleanup",
        "minor",
        "for changeset",
        ".com``",
        "oops",
        "syntax",
    )
    hotfixes = {"40cbc47b8d8a": "1.0.9", "a25749986abc": "1.0.10"}

    # Load the repo.
    try:
        from mercurial import ui, hg, error
        from mercurial.commands import tag
    except ImportError:
        pass
    else:
        try:
            ui = ui.ui()
            repo = hg.repository(ui, project_path)
        except error.RepoError:
            return
    if repo is None:
        return

    # Go through each changeset and assign it to the versions dict.
    changesets = [repo.changectx(changeset) for changeset in repo.changelog]
    for cs in sorted(changesets, reverse=True, key=_changeset_date):
        # Check if the file with the version number is in this changeset
        # and if it is, pull it out and assign it as a variable.
        files = cs.files()
        new_version = False
        # Commit message cleanup hacks.
        description = cs.description().decode("utf-8")
        description = description.rstrip(".").replace("\n", ". ")
        while "  " in description:
            description = description.replace("  ", " ")
        description = description.replace(". . ", ". ").replace("...", ",")
        while ".." in description:
            description = description.replace("..", ".")
        description = description.replace(":.", ":").replace("n'. t", "n't")
        words = description.split()
        # Format var names in commit.
        for i, word in enumerate(words):
            if set("._") & set(word[:-1]) and set(letters) & set(word) and "`" not in word and not word[0].isdigit():
                last = ""
                if word[-1] in ",.":
                    last, word = word[-1], word[:-1]
                words[i] = "``%s``%s" % (word, last)
        description = " ".join(words)
        if version_file in files:
            for line in cs[version_file].data().split("\n"):
                if line.startswith(version_var):
                    exec(line)
                    if locals()[version_var] == "0.1.0":
                        locals()[version_var] = "1.0.0"
                        break
                    versions[locals()[version_var]] = {"changes": [], "date": _changeset_date(cs).strftime("%b %d, %Y")}
                    new_version = len(files) == 1

        # Tag new versions.
        hotfix = hotfixes.get(cs.hex()[:12])
        if hotfix or new_version:
            if hotfix:
                version_tag = hotfix
            else:
                try:
                    version_tag = locals()[version_var]
                except KeyError:
                    version_tag = None
            if version_tag and version_tag not in cs.tags():
                try:
                    tag(ui, repo, version_tag, rev=cs.hex())
                    print("Tagging version %s" % version_tag)
                except:
                    pass

        # Ignore changesets that are merges, bumped the version, closed
        # a branch, regenerated the changelog itself, contain an ignore
        # word, or contain too few words to be meaningful.
        merge = len(cs.parents()) > 1
        branch_closed = len(files) == 0
        changelog_update = changelog_filename in files
        ignored = [w for w in ignore if w.lower() in description.lower()]
        too_few_words = len(description.split()) <= 3
        if merge or new_version or branch_closed or changelog_update or ignored or too_few_words:
            continue
        # Ensure we have a current version and if so, add this changeset's
        # description to it.
        version = None
        try:
            version = locals()[version_var]
        except KeyError:
            if not hotfix:
                continue
        user = cs.user().decode("utf-8").split("<")[0].strip()
        entry = "%s - %s" % (description, user)
        if hotfix or entry not in versions[version]["changes"]:
            if hotfix:
                versions[hotfix] = {"changes": [entry], "date": _changeset_date(cs).strftime("%b %d, %Y")}
            else:
                versions[version]["changes"].insert(0, entry)

    # Write out the changelog.
    with open(changelog_file, "w") as f:
        for version, version_info in versions.items():
            header = "Version %s (%s)" % (version, version_info["date"])
            f.write("%s\n" % header)
            f.write("%s\n" % ("-" * len(header)))
            f.write("\n")
            if version_info["changes"]:
                for change in version_info["changes"]:
                    f.write("  * %s\n" % change)
            else:
                f.write("  * No changes listed.\n")
            f.write("\n")
コード例 #9
0
ファイル: docs.py プロジェクト: seanhussey/mezzanine
def build_changelog(docs_path, package_name="mezzanine"):
    """
    Converts Mercurial commits into a changelog in RST format.
    """

    project_path = os.path.join(docs_path, "..")
    version_file = os.path.join(package_name, "__init__.py")
    version_var = "__version__"
    changelog_filename = "CHANGELOG"
    changelog_file = os.path.join(project_path, changelog_filename)
    versions = SortedDict()
    repo = None
    ignore = ("AUTHORS", "formatting", "typo", "pep8", "pep 8",
              "whitespace", "README", "trans", "print debug",
              "debugging", "tabs", "style", "sites", "ignore",
              "tweak", "cleanup", "minor", "for changeset",
              ".com``", "oops", "syntax")
    hotfixes = {
        "40cbc47b8d8a": "1.0.9",
        "a25749986abc": "1.0.10",
    }

    # Load the repo.
    try:
        from mercurial import ui, hg, error
        from mercurial.commands import tag
    except ImportError:
        pass
    else:
        try:
            ui = ui.ui()
            repo = hg.repository(ui, project_path)
        except error.RepoError:
            return
    if repo is None:
        return

    # Go through each changeset and assign it to the versions dict.
    changesets = [repo.changectx(changeset) for changeset in repo.changelog]
    for cs in sorted(changesets, reverse=True, key=_changeset_date):
        # Check if the file with the version number is in this changeset
        # and if it is, pull it out and assign it as a variable.
        files = cs.files()
        new_version = False
        # Commit message cleanup hacks.
        description = cs.description().decode("utf-8")
        description = description.rstrip(".").replace("\n", ". ")
        while "  " in description:
            description = description.replace("  ", " ")
        description = description.replace(". . ", ". ").replace("...", ",")
        while ".." in description:
            description = description.replace("..", ".")
        description = description.replace(":.", ":").replace("n'. t", "n't")
        words = description.split()
        # Format var names in commit.
        for i, word in enumerate(words):
            if (set("._") & set(word[:-1]) and set(letters) & set(word) and
                    "`" not in word and not word[0].isdigit()):
                last = ""
                if word[-1] in ",.":
                    last, word = word[-1], word[:-1]
                words[i] = "``%s``%s" % (word, last)
        description = " ".join(words)
        if version_file in files:
            for line in cs[version_file].data().split("\n"):
                if line.startswith(version_var):
                    exec(line)
                    if locals()[version_var] == "0.1.0":
                        locals()[version_var] = "1.0.0"
                        break
                    versions[locals()[version_var]] = {
                        "changes": [],
                        "date": _changeset_date(cs).strftime("%b %d, %Y")
                    }
                    new_version = len(files) == 1

        # Tag new versions.
        hotfix = hotfixes.get(cs.hex()[:12])
        if hotfix or new_version:
            if hotfix:
                version_tag = hotfix
            else:
                try:
                    version_tag = locals()[version_var]
                except KeyError:
                    version_tag = None
            if version_tag and version_tag not in cs.tags():
                try:
                    tag(ui, repo, version_tag, rev=cs.hex())
                    print("Tagging version %s" % version_tag)
                except:
                    pass

        # Ignore changesets that are merges, bumped the version, closed
        # a branch, regenerated the changelog itself, contain an ignore
        # word, or are one word long.
        merge = len(cs.parents()) > 1
        branch_closed = len(files) == 0
        changelog_update = changelog_filename in files
        ignored = [w for w in ignore if w.lower() in description.lower()]
        one_word = len(description.split()) == 1
        if (merge or new_version or branch_closed or changelog_update or
                ignored or one_word):
            continue
        # Ensure we have a current version and if so, add this changeset's
        # description to it.
        version = None
        try:
            version = locals()[version_var]
        except KeyError:
            if not hotfix:
                continue
        user = cs.user().decode("utf-8").split("<")[0].strip()
        entry = "%s - %s" % (description, user)
        if hotfix or entry not in versions[version]["changes"]:
            if hotfix:
                versions[hotfix] = {
                    "changes": [entry],
                    "date": _changeset_date(cs).strftime("%b %d, %Y"),
                }
            else:
                versions[version]["changes"].insert(0, entry)

    # Write out the changelog.
    with open(changelog_file, "w") as f:
        for version, version_info in versions.items():
            header = "Version %s (%s)" % (version, version_info["date"])
            f.write("%s\n" % header)
            f.write("%s\n" % ("-" * len(header)))
            f.write("\n")
            if version_info["changes"]:
                for change in version_info["changes"]:
                    f.write("  * %s\n" % change)
            else:
                f.write("  * No changes listed.\n")
            f.write("\n")
コード例 #10
0
ファイル: deliver.py プロジェクト: metoule/deezer-control
				print bcolors.YELLOW + "   Replacing old version %s by new one %s" % (aOldVersion, aNewVersion) + bcolors.ENDC					
				line = line.replace(aOldVersion, aNewVersion)
			aManifestFile.write(line)
	
	# abort here so that we don't write an empty file 
	if aOldVersion == aNewVersion:
		sys.exit("New version is the same as the old one, aborting...") 
			
	# Commit new version
	print bcolors.BLUE + "3. Commit manifest.json with message 'Bumped version'" + bcolors.ENDC
	commands.commit(ui.ui(), aHgRepo, 'manifest.json', message='Bumped version', user='******')
	
	# Tag repository
	aTagName = 'DEEZER_CONTROL_%s' % aNewVersion
	print bcolors.BLUE + "4. Tag repository with name %s" % aTagName  + bcolors.ENDC
	commands.tag(ui.ui(), aHgRepo, aTagName, user='******')
	
	# Create .zip file
	aZipName = 'deezer_control_%s.zip' % aNewVersion
	print bcolors.BLUE + "5. Create delivery file %s" % aZipName  + bcolors.ENDC
	with zipfile.ZipFile(aZipName, 'w') as aMyZip:
		aMyZip.write('CHANGELOG')
		aMyZip.write('LICENSE.txt')
		aMyZip.write('manifest.json')
		for file in os.listdir('.'):
			if file.endswith('.html'):
				aMyZip.write(file)
		addFolderToZip(aMyZip, 'css')
		addFolderToZip(aMyZip, 'imgs')
		addFolderToZip(aMyZip, '_locales')
		addFolderToZip(aMyZip, 'scripts')
コード例 #11
0
ファイル: wikibot.py プロジェクト: ArneBab/infocalypse
def tag_site_index(ui_, repo, index=None):
    """ Tag the local repository with a freesite index. """
    if index is None:
        index = latest_site_index(repo) + 1 # hmmmm... lazy vs. explicit.
    commands.tag(ui_, repo, 'I_%i' % index)
コード例 #12
0
ファイル: deliver.py プロジェクト: franzouille/MRadio
				print bcolors.YELLOW + "   Replacing old version %s by new one %s" % (aOldVersion, aNewVersion) + bcolors.ENDC					
				line = line.replace(aOldVersion, aNewVersion)
			aManifestFile.write(line)
	
	# abort here so that we don't write an empty file 
	if aOldVersion == aNewVersion:
		sys.exit("New version is the same as the old one, aborting...") 
			
	# Commit new version
	print bcolors.BLUE + "3. Commit manifest.json with message 'Bumped version'" + bcolors.ENDC
	commands.commit(ui.ui(), aHgRepo, 'manifest.json', message='Bumped version')
	
	# Tag repository
	aTagName = 'DEEZER_CONTROL_%s' % aNewVersion
	print bcolors.BLUE + "4. Tag repository with name %s" % aTagName  + bcolors.ENDC
	commands.tag(ui.ui(), aHgRepo, aTagName)
	
	# Create .zip file
	aZipName = 'deezer_control_%s.zip' % aNewVersion
	print bcolors.BLUE + "5. Create delivery file %s" % aZipName  + bcolors.ENDC
	with zipfile.ZipFile(aZipName, 'w') as aMyZip:
		aMyZip.write('CHANGELOG')
		aMyZip.write('LICENSE.txt')
		aMyZip.write('manifest.json')
		for file in os.listdir('.'):
			if file.endswith('.html'):
				aMyZip.write(file)
		addFolderToZip(aMyZip, 'css')
		addFolderToZip(aMyZip, 'imgs')
		addFolderToZip(aMyZip, '_locales')
		addFolderToZip(aMyZip, 'scripts')
コード例 #13
0
ファイル: cut_release.py プロジェクト: SeekingFor/jfniki
def tag_site_index(ui_, repo, index=None): # C&P: wikibot.py
    """ Tag the local repository with a freesite index. """
    if index is None:
        index = latest_site_index(repo) + 1
    commands.tag(ui_, repo, 'I_%i' % index)
コード例 #14
0
def tag_site_index(ui_, repo, index=None):
    """ Tag the local repository with a freesite index. """
    if index is None:
        index = latest_site_index(repo) + 1  # hmmmm... lazy vs. explicit.
    commands.tag(ui_, repo, 'I_%i' % index)