Changeset - 8092a1881a49
[Not reviewed]
0 1 0
Branko Majic (branko) - 9 months ago 2025-03-02 00:58:38
branko@majic.rs
[thebuggenie_hg_remote.py] Fixed linter errors:

- Mostly spacing-related.
- Use the range function instead of xrange (Python 2.7 -> Python 3.x).
- Script probably will not run correctly under Python 3.x, but at
least the linter will not get in the way when working on other
Python code in the project.
1 file changed with 13 insertions and 8 deletions:
0 comments (0 inline, 0 general)
hooks/thebuggenie_hg_remote.py
Show inline comments
 
@@ -59,6 +59,7 @@ import subprocess
 

	
 
import mercurial.node
 

	
 

	
 
def call_program(program, arguments, url):
 
    """
 
    Calls the specified program, passing it the arguments. The URL is passed
 
@@ -95,6 +96,7 @@ def call_program(program, arguments, url):
 
    # Return the exit code of process, and message that should be shown to user.
 
    return process.returncode, stdout, stderr
 

	
 

	
 
def extract_report(repo, context):
 
    """
 
    Extract the commit report from provided context.
 
@@ -141,6 +143,7 @@ def extract_report(repo, context):
 
    # Finally return the report.
 
    return report
 

	
 

	
 
def submit_report(commit, repo, ui, program, program_params, base_url, project_id, passkey):
 
    """
 
    Submits report to TBG for a single commit.
 
@@ -206,6 +209,7 @@ def submit_report(commit, repo, ui, program, program_params, base_url, project_i
 
        stdout += "\n"
 
        ui.warn(stdout)
 

	
 

	
 
def hook(ui, repo, hooktype, node=None, url=None, **kwargs):
 
    """
 
    Commit and changegroup hook for Mercurial.
 
@@ -228,16 +232,16 @@ def hook(ui, repo, hooktype, node = None, url = None, **kwargs):
 
    config = dict((param, value) for param, value in ui.configitems('buggenie'))
 

	
 
    # Make sure the required settings were specified.
 
    if not "program" in config:
 
    if "program" not in config:
 
        ui.warn("TBG HG Hook: No program was specified. Check your settings.\n")
 
        return
 
    if not "url" in config:
 
    if "url" not in config:
 
        ui.warn("TBG HG Hook: No base URL was specified. Check your settings.\n")
 
        return
 
    if not "project" in config:
 
    if "project" not in config:
 
        ui.warn("TBG HG Hook: No project ID was specified. Check your settings.\n")
 
        return
 
    if not "passkey" in config:
 
    if "passkey" not in config:
 
        ui.warn("TBG HG Hook: No passkey was specified. Check your settings.\n")
 
        return
 

	
 
@@ -264,10 +268,11 @@ def hook(ui, repo, hooktype, node = None, url = None, **kwargs):
 
        start = repo.changelog.rev(node_hash)
 
        end = len(repo.changelog)
 

	
 
        for commit in xrange(start, end):
 
            submit_report(commit, repo, ui, config["program"], program_params, config["url"], config["project"], config["passkey"])
 
        for commit in range(start, end):
 
            submit_report(commit, repo, ui,
 
                          config["program"], program_params, config["url"], config["project"], config["passkey"])
 

	
 
    # If the hook is called as a commit, hook, process just the single commit.
 
    elif hooktype == "commit":
 
        submit_report(commit, repo, ui, config["program"], program_params, config["url"], config["project"], config["passkey"])
 

	
 
        submit_report(commit, repo, ui,
 
                      config["program"], program_params, config["url"], config["project"], config["passkey"])
0 comments (0 inline, 0 general)