def get_dt_from_hg(path): with mozversioncontrol.get_repository_object(path=path) as repo: phase = repo._run("log", "-r", ".", "-T" "{phase}") if phase.strip() != "public": return datetime.datetime.utcnow() repo_url = repo._run("paths", "default") repo_url = repo_url.strip().replace("ssh://", "https://") repo_url = repo_url.replace("hg://", "https://") cs = repo._run("log", "-r", ".", "-T" "{node}") url = pushlog_api_url.format(repo_url, cs) session = requests.Session() try: response = session.get(url) except Exception as e: msg = "Failed to retrieve push timestamp using {}\nError: {}".format( url, e) raise Exception(msg) data = response.json() try: date = data["pushdate"][0] except KeyError as exc: msg = "{}\ndata is: {}".format( str(exc), json.dumps(data, indent=2, sort_keys=True)) raise KeyError(msg) return datetime.datetime.utcfromtimestamp(date)
def test_commit(repo): vcs = get_repository_object(repo.strpath) assert vcs.working_directory_clean() # Modify both foo and bar next(repo.step) assert not vcs.working_directory_clean() # Commit just bar vcs.commit("Modify bar\n\nbut not baz", "Testing McTesterson <*****@*****.**>", "2017-07-14 02:40:00 UTC", ["bar"]) # We only committed bar, so foo is still keeping the working dir dirty assert not vcs.working_directory_clean() if repo.vcs == 'git': log_cmd = ['log', '-1', '--format=%an,%ae,%at,%B'] patch_cmd = ['log', '-1', '-p'] else: log_cmd = ['log', '-l', '1', '-T', '{person(author)},{email(author)},{date(localdate(date),"%s")},{desc}'] patch_cmd = ['log', '-l', '1', '-p'] # Verify commit metadata (we rstrip to normalize trivial git/hg differences) log = vcs._run(*log_cmd).rstrip() assert log == 'Testing McTesterson,[email protected],1500000000,Modify bar\n\nbut not baz' # Verify only the intended file was added to the commit patch = vcs._run(*patch_cmd) diffs = [line for line in patch.splitlines() if "diff --git" in line] assert len(diffs) == 1 assert diffs[0] == "diff --git a/bar b/bar"
def __init__(self, root, exclude=None, **lintargs): self.parse = Parser(root) try: self.vcs = get_repository_object(root) except InvalidRepoPath: self.vcs = None self.linters = [] self.lintargs = lintargs self.lintargs["root"] = root # result state self.result = ResultSummary(root) self.root = root self.exclude = exclude or [] if lintargs.get("show_verbose"): logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.WARNING) self.log = logging.LoggerAdapter(logger, { "lintname": "mozlint", "pid": os.getpid() })
def get_commits(logger, repo_root): try: repo = mozversioncontrol.get_repository_object(repo_root) except mozversioncontrol.InvalidRepoPath: logger.warning("No VCS found for path %s" % repo_root) return [] # The base_ref doesn't actually return a ref, sadly base_rev = repo.base_ref if repo.name == "git": logger.debug("Found git repo") logger.debug("Base rev is %s" % base_rev) if not repo.has_git_cinnabar: logger.error("git cinnabar not found") return [] changeset_iter = (repo._run("cinnabar", "git2hg", rev).strip() for rev in repo._run("log", "--format=%H", "-n50", base_rev, "testing/web-platform/tests", "testing/web-platform/mozilla/tests").splitlines()) else: logger.debug("Found hg repo") logger.debug("Base rev is %s" % base_rev) changeset_iter = repo._run("log", "-fl50", "--template={node}\n", "-r", base_rev, "testing/web-platform/tests", "testing/web-platform/mozilla/tests").splitlines() return changeset_iter
def run_clang_format(hooktype, changedFiles): try: vcs = get_repository_object(topsrcdir) except InvalidRepoPath: return if not changedFiles: # No files have been touched return arguments = ["clang-format", "-p"] + changedFiles # On windows we need this to call the command in a shell, see Bug 1511594 if os.name == "nt": clang_format_cmd = ["sh", "mach"] + arguments else: clang_format_cmd = [os.path.join(topsrcdir, "mach")] + arguments if "commit" in hooktype: # don't prevent commits, just display the clang-format results subprocess.call(clang_format_cmd) # Add the modified files back to the repo (expect a string) vcs.add_remove_files(" ".join(changedFiles)) return False print( "warning: '{}' is not a valid clang-format hooktype".format(hooktype)) return False
def test_push_to_try(repo, monkeypatch): commit_message = "commit message" vcs = get_repository_object(repo.strpath) captured_commands = [] def fake_run(*args, **kwargs): captured_commands.append(args[0]) monkeypatch.setattr(subprocess, 'check_output', fake_run) monkeypatch.setattr(subprocess, 'check_call', fake_run) vcs.push_to_try(commit_message) tool = vcs._tool if repo.vcs == 'hg': expected = [ (tool, 'push-to-try', '-m', commit_message), (tool, 'revert', '-a'), ] else: expected = [ (tool, 'cinnabar', '--version'), (tool, 'commit', '--allow-empty', '-m', commit_message), (tool, 'push', 'hg::ssh://hg.mozilla.org/try', '+HEAD:refs/heads/branches/default/tip'), (tool, 'reset', 'HEAD~'), ] for i, value in enumerate(captured_commands): assert value == expected[i] assert len(captured_commands) == len(expected)
def run_clang_format(hooktype, args): try: vcs = get_repository_object(topsrcdir) except InvalidRepoPath: return changedFiles = vcs.get_outgoing_files('AM') if not changedFiles: # No files have been touched return arguments = ['clang-format', '-s', '-p'] + changedFiles # On windows we need this to call the command in a shell, see Bug 1511594 if os.name == 'nt': clang_format_cmd = ['sh', 'mach'] + arguments else: clang_format_cmd = [os.path.join(topsrcdir, "mach")] + arguments if 'commit' in hooktype: # don't prevent commits, just display the clang-format results subprocess.Popen(clang_format_cmd) return False print( "warning: '{}' is not a valid clang-format hooktype".format(hooktype)) return False
def resolve_repository(): import mozversioncontrol try: # This API doesn't respect the vcs binary choices from configure. # If we ever need to use the VCS binary here, consider something # more robust. return mozversioncontrol.get_repository_object(path=topsrcdir) except (mozversioncontrol.InvalidRepoPath, mozversioncontrol.MissingVCSTool): return None
def test_working_directory_clean_untracked_files(repo): vcs = get_repository_object(repo.strpath) assert vcs.working_directory_clean() next(repo.step) assert not vcs.working_directory_clean() next(repo.step) assert vcs.working_directory_clean() assert not vcs.working_directory_clean(untracked=True)
def _warn_if_risky_revision(path): # Warn the user if they're trying to bootstrap from an obviously old # version of tree as reported by the version control system (a month in # this case). This is an approximate calculation but is probably good # enough for our purposes. NUM_SECONDS_IN_MONTH = 60 * 60 * 24 * 30 from mozversioncontrol import get_repository_object repo = get_repository_object(path) if (time.time() - repo.get_commit_time()) >= NUM_SECONDS_IN_MONTH: print(OLD_REVISION_WARNING)
def vcs_setup(command_context, update_only=False): """Ensure a Version Control System (Mercurial or Git) is optimally configured. This command will inspect your VCS configuration and guide you through an interactive wizard helping you configure the VCS for optimal use on Mozilla projects. User choice is respected: no changes are made without explicit confirmation from you. If "--update-only" is used, the interactive wizard is disabled and this command only ensures that remote repositories providing VCS extensions are up to date. """ import mozboot.bootstrap as bootstrap import mozversioncontrol from mozfile import which repo = mozversioncontrol.get_repository_object( command_context._mach_context.topdir) tool = "hg" if repo.name == "git": tool = "git" # "hg" is an executable script with a shebang, which will be found by # which. We need to pass a win32 executable to the function because we # spawn a process from it. if sys.platform in ("win32", "msys"): tool += ".exe" vcs = which(tool) if not vcs: raise OSError(errno.ENOENT, "Could not find {} on $PATH".format(tool)) if update_only: if repo.name == "git": bootstrap.update_git_tools( vcs, command_context._mach_context.state_dir, command_context._mach_context.topdir, ) else: bootstrap.update_vct(vcs, command_context._mach_context.state_dir) else: if repo.name == "git": bootstrap.configure_git( vcs, which("git-cinnabar"), command_context._mach_context.state_dir, command_context._mach_context.topdir, ) else: bootstrap.configure_mercurial( vcs, command_context._mach_context.state_dir)
def repository(self): '''Get a `mozversioncontrol.Repository` object for the top source directory.''' # We try to obtain a repo using the configured VCS info first. # If we don't have a configure context, fall back to auto-detection. try: return get_repository_from_build_config(self) except BuildEnvironmentNotFoundException: pass return get_repository_object(self.topsrcdir)
def resolve_is_employee_by_vcs(topsrcdir): try: vcs = get_repository_object(topsrcdir) except InvalidRepoPath: return None email = vcs.get_user_email() if not email: return None return "@mozilla.com" in email
def resolve_repository(): import mozversioncontrol try: # This API doesn't respect the vcs binary choices from configure. # If we ever need to use the VCS binary here, consider something # more robust. return mozversioncontrol.get_repository_object(path=mozilla_dir) except (mozversioncontrol.InvalidRepoPath, mozversioncontrol.MissingVCSTool): return None
def test_workdir_outgoing(repo): vcs = get_repository_object(repo.strpath) assert vcs.path == repo.strpath remotepath = '../remoterepo' if repo.vcs == 'hg' else 'upstream/master' # Mutate files. next(repo.step) assert_files(vcs.get_changed_files('A', 'all'), ['baz']) assert_files(vcs.get_changed_files('AM', 'all'), ['bar', 'baz']) assert_files(vcs.get_changed_files('D', 'all'), ['foo']) if repo.vcs == 'git': assert_files(vcs.get_changed_files('AM', mode='staged'), ['baz']) elif repo.vcs == 'hg': # Mercurial does not use a staging area (and ignores the mode parameter.) assert_files(vcs.get_changed_files('AM', 'unstaged'), ['bar', 'baz']) assert_files(vcs.get_outgoing_files('AMD'), []) assert_files(vcs.get_outgoing_files('AMD', remotepath), []) # Create a commit. next(repo.step) assert_files(vcs.get_changed_files('AMD', 'all'), []) assert_files(vcs.get_changed_files('AMD', 'staged'), []) assert_files(vcs.get_outgoing_files('AMD'), ['bar', 'baz', 'foo']) assert_files(vcs.get_outgoing_files('AMD', remotepath), ['bar', 'baz', 'foo']) # Mutate again. next(repo.step) assert_files(vcs.get_changed_files('A', 'all'), ['baby']) assert_files(vcs.get_changed_files('AM', 'all'), ['baby', 'baz']) assert_files(vcs.get_changed_files('D', 'all'), []) # Create a second commit. next(repo.step) assert_files(vcs.get_outgoing_files('AM'), ['bar', 'baz', 'baby']) assert_files(vcs.get_outgoing_files('AM', remotepath), ['bar', 'baz', 'baby']) if repo.vcs == 'git': assert_files(vcs.get_changed_files('AM', rev='HEAD~1'), ['bar', 'baz']) assert_files(vcs.get_changed_files('AM', rev='HEAD'), ['baby', 'baz']) else: assert_files(vcs.get_changed_files('AM', rev='.^'), ['bar', 'baz']) assert_files(vcs.get_changed_files('AM', rev='.'), ['baby', 'baz']) assert_files(vcs.get_changed_files('AM', rev='.^::'), ['bar', 'baz', 'baby']) assert_files(vcs.get_changed_files('AM', rev='modifies(baz)'), ['baz', 'baby'])
def test_workdir_outgoing(repo): vcs = get_repository_object(repo.strpath) assert vcs.path == repo.strpath remotepath = "../remoterepo" if repo.vcs == "hg" else "upstream/master" # Mutate files. next(repo.step) assert_files(vcs.get_changed_files("A", "all"), ["baz"]) assert_files(vcs.get_changed_files("AM", "all"), ["bar", "baz"]) assert_files(vcs.get_changed_files("D", "all"), ["foo"]) if repo.vcs == "git": assert_files(vcs.get_changed_files("AM", mode="staged"), ["baz"]) elif repo.vcs == "hg": # Mercurial does not use a staging area (and ignores the mode parameter.) assert_files(vcs.get_changed_files("AM", "unstaged"), ["bar", "baz"]) assert_files(vcs.get_outgoing_files("AMD"), []) assert_files(vcs.get_outgoing_files("AMD", remotepath), []) # Create a commit. next(repo.step) assert_files(vcs.get_changed_files("AMD", "all"), []) assert_files(vcs.get_changed_files("AMD", "staged"), []) assert_files(vcs.get_outgoing_files("AMD"), ["bar", "baz", "foo"]) assert_files(vcs.get_outgoing_files("AMD", remotepath), ["bar", "baz", "foo"]) # Mutate again. next(repo.step) assert_files(vcs.get_changed_files("A", "all"), ["baby"]) assert_files(vcs.get_changed_files("AM", "all"), ["baby", "baz"]) assert_files(vcs.get_changed_files("D", "all"), []) # Create a second commit. next(repo.step) assert_files(vcs.get_outgoing_files("AM"), ["bar", "baz", "baby"]) assert_files(vcs.get_outgoing_files("AM", remotepath), ["bar", "baz", "baby"]) if repo.vcs == "git": assert_files(vcs.get_changed_files("AM", rev="HEAD~1"), ["bar", "baz"]) assert_files(vcs.get_changed_files("AM", rev="HEAD"), ["baby", "baz"]) else: assert_files(vcs.get_changed_files("AM", rev=".^"), ["bar", "baz"]) assert_files(vcs.get_changed_files("AM", rev="."), ["baby", "baz"]) assert_files(vcs.get_changed_files("AM", rev=".^::"), ["bar", "baz", "baby"]) assert_files(vcs.get_changed_files("AM", rev="modifies(baz)"), ["baz", "baby"])
def test_push_to_try(repo, monkeypatch): commit_message = "commit message" vcs = get_repository_object(repo.strpath) captured_commands = [] def fake_run(*args, **kwargs): captured_commands.append(args[0]) monkeypatch.setattr(subprocess, "check_output", fake_run) monkeypatch.setattr(subprocess, "check_call", fake_run) vcs.push_to_try(commit_message) tool = vcs._tool if repo.vcs == "hg": expected = [ ( tool, "push-to-try", "-s", "ssh://hg.mozilla.org/projects/kaios-try", "-m", commit_message, ), (tool, "revert", "-a"), ] else: expected = [ (tool, "cinnabar", "--version"), ( tool, "-c", "commit.gpgSign=false", "commit", "--allow-empty", "-m", commit_message, ), ( tool, "push", "hg::ssh://hg.mozilla.org/projects/kaios-try", "+HEAD:refs/heads/branches/default/tip", ), (tool, "reset", "HEAD~"), ] for i, value in enumerate(captured_commands): assert value == expected[i] assert len(captured_commands) == len(expected)
def __init__(self, root, **lintargs): self.parse = Parser() try: self.vcs = get_repository_object(root) except InvalidRepoPath: self.vcs = None self.linters = [] self.lintargs = lintargs self.lintargs['root'] = root # linters that return non-zero self.failed = None
def setup_globals(): # Avoid incurring expensive computation on import. global build, vcs, CHUNK_MAPPING_TAG_FILE, CHUNK_MAPPING_FILE build = MozbuildObject.from_environment(cwd=here) vcs = get_repository_object(build.topsrcdir) root_hash = hashlib.sha256( six.ensure_binary(os.path.abspath(build.topsrcdir))).hexdigest() cache_dir = os.path.join(get_state_dir(), "cache", root_hash, "chunk_mapping") if not os.path.isdir(cache_dir): os.makedirs(cache_dir) CHUNK_MAPPING_FILE = os.path.join(cache_dir, "chunk_mapping.sqlite") CHUNK_MAPPING_TAG_FILE = os.path.join(cache_dir, "chunk_mapping_tag.json")
def resolve_repository(): import mozversioncontrol try: # This API doesn't respect the vcs binary choices from configure. # If we ever need to use the VCS binary here, consider something # more robust. return mozversioncontrol.get_repository_object(path=mozilla_dir) except mozversioncontrol.InvalidRepoPath: return None # This is mainly to catch failures resolving the VCS binary path. # TODO Change mozversioncontrol to raise non-generic exception. except Exception: return None
def test_push_to_try_missing_extensions(repo, monkeypatch): vcs = get_repository_object(repo.strpath) orig = vcs._run def cinnabar_raises(*args, **kwargs): # Simulate not having git cinnabar if args[0] == 'cinnabar': raise subprocess.CalledProcessError(1, args) return orig(*args, **kwargs) monkeypatch.setattr(vcs, '_run', cinnabar_raises) with pytest.raises(MissingVCSExtension): vcs.push_to_try("commit message")
def test_context_manager(repo): is_git = repo.vcs == "git" cmd = ["show", "--no-patch"] if is_git else ["tip"] vcs = get_repository_object(repo.strpath) output_subprocess = vcs._run(*cmd) assert is_git or vcs._client.server is None assert "Initial commit" in output_subprocess with vcs: assert is_git or vcs._client.server is not None output_client = vcs._run(*cmd) assert is_git or vcs._client.server is None assert output_subprocess == output_client
def __init__(self, root, exclude=None, **lintargs): self.parse = Parser(root) try: self.vcs = get_repository_object(root) except InvalidRepoPath: self.vcs = None self.linters = [] self.lintargs = lintargs self.lintargs['root'] = root # result state self.result = ResultSummary() self.root = root self.exclude = exclude or []
def __init__(self, root, **lintargs): self.parse = Parser() try: self.vcs = get_repository_object(root) except InvalidRepoPath: self.vcs = None self.linters = [] self.lintargs = lintargs self.lintargs['root'] = root # result state self.failed = None self.failed_setup = None self.results = None self.root = root
def vcs_setup(self, update_only=False): """Ensure a Version Control System (Mercurial or Git) is optimally configured. This command will inspect your VCS configuration and guide you through an interactive wizard helping you configure the VCS for optimal use on Mozilla projects. User choice is respected: no changes are made without explicit confirmation from you. If "--update-only" is used, the interactive wizard is disabled and this command only ensures that remote repositories providing VCS extensions are up to date. """ import which import mozboot.bootstrap as bootstrap import mozversioncontrol repo = mozversioncontrol.get_repository_object(self._context.topdir) vcs = 'hg' if repo.name == 'git': vcs = 'git' # "hg" is an executable script with a shebang, which will be found # by which.which. We need to pass a win32 executable to the function # because we spawn a process # from it. if sys.platform in ('win32', 'msys'): vcs = which.which(vcs + '.exe') else: vcs = which.which(vcs) if update_only: if repo.name == 'git': bootstrap.update_git_tools(vcs, self._context.state_dir, self._context.topdir) else: bootstrap.update_vct(vcs, self._context.state_dir) else: if repo.name == 'git': bootstrap.configure_git(vcs, self._context.state_dir, self._context.topdir) else: bootstrap.configure_mercurial(vcs, self._context.state_dir)
def run_clang_format(hooktype, changedFiles): try: vcs = get_repository_object(topsrcdir) except InvalidRepoPath: return if not changedFiles: # No files have been touched return # We have also a copy of this list in: # python/mozbuild/mozbuild/mach_commands.py # version-control-tools/hgext/clang-format/__init__.py # release-services/src/staticanalysis/bot/static_analysis_bot/config.py # Too heavy to import the full class just for this variable extensions = (".cpp", ".c", ".cc", ".h", ".m", ".mm") path_list = [] for filename in sorted(changedFiles): # Ignore files unsupported in clang-format if filename.decode().endswith(extensions): path_list.append(filename) if not path_list: # No files have been touched return arguments = ["clang-format", "-p"] + path_list # On windows we need this to call the command in a shell, see Bug 1511594 if os.name == "nt": clang_format_cmd = ["sh", "mach"] + arguments else: clang_format_cmd = [os.path.join(topsrcdir, "mach")] + arguments if "commit" in hooktype: # don't prevent commits, just display the clang-format results subprocess.call(clang_format_cmd) # Add the modified files back to the repo (expect a string) # one by one (fails otherwise, see bug #1541409) for f in path_list: vcs.add_remove_files(f) return False print( "warning: '{}' is not a valid clang-format hooktype".format(hooktype)) return False
def register_sentry(argv, settings, topsrcdir=None): if not is_telemetry_enabled(settings): return NoopErrorReporter() if topsrcdir: try: repo = get_repository_object(topsrcdir) email = repo.get_user_email() if email in _DEVELOPER_BLOCKLIST: return NoopErrorReporter() except InvalidRepoPath: pass sentry_sdk.init( _SENTRY_DSN, before_send=lambda event, _: _process_event(event, topsrcdir)) sentry_sdk.add_breadcrumb(message="./mach {}".format(" ".join(argv))) return SentryErrorReporter()
def test_file_content(repo): vcs = get_repository_object(repo.strpath) head_ref = vcs.head_ref assert vcs.get_file_content("foo") == b"foo\n" assert vcs.get_file_content("bar") == b"bar\n" next(repo.step) assert vcs.get_file_content("foo") == b"foo\n" assert vcs.get_file_content("bar") == b"bar\n" next(repo.step) assert vcs.get_file_content("foo") == b"foo\n" assert vcs.get_file_content("bar") == b"foo\n" assert vcs.get_file_content("bar", revision=head_ref) == b"bar\n" # Ensure a file that can't be found throws the right error. good = False try: vcs.get_file_content("baz", revision=head_ref) except NonexistentFile: good = True assert good
def install_puppeteer(self, product): setup() env = {} from mozversioncontrol import get_repository_object repo = get_repository_object(self.topsrcdir) puppeteer_dir = os.path.join("remote", "test", "puppeteer") changed_files = False for f in repo.get_changed_files(): if f.startswith(puppeteer_dir) and f.endswith(".ts"): changed_files = True break if product != "chrome": env["PUPPETEER_SKIP_DOWNLOAD"] = "1" lib_dir = os.path.join(self.topsrcdir, puppeteer_dir, "lib") if changed_files and os.path.isdir(lib_dir): # clobber lib to force `tsc compile` step shutil.rmtree(lib_dir) npm("ci", cwd=os.path.join(self.topsrcdir, puppeteer_dir), env=env)
def get_dt_from_hg(path): with mozversioncontrol.get_repository_object(path=path) as repo: repo_url = repo._run_in_client(["paths", "default"]) repo_url = repo_url.strip().replace("ssh://", "https://") repo_url = repo_url.replace("hg://", "https://") cs = repo._run_in_client(["log", "-r", ".", "-T" "{node}"]) url = pushlog_api_url.format(repo_url, cs) session = requests.Session() try: response = session.get(url) except Exception as e: msg = "Failed to retrieve push timestamp using {}\nError: {}".format( url, e) raise Exception(msg) data = response.json() date = data['pushdate'][0] return datetime.datetime.utcfromtimestamp(date)
def test_branch(repo): vcs = get_repository_object(repo.strpath) if vcs.name == "git" and LooseVersion(vcs.tool_version) < LooseVersion("2.22.0"): pytest.xfail("`git branch --show-current` not implemented yet") if vcs.name == "git": assert vcs.branch == "master" else: assert vcs.branch is None next(repo.step) assert vcs.branch == "test" next(repo.step) assert vcs.branch == "test" vcs.update(vcs.head_ref) assert vcs.branch is None vcs.update("test") assert vcs.branch == "test"
def test_workdir_outgoing(repo): vcs = get_repository_object(repo.strpath) assert vcs.path == repo.strpath remotepath = '../remoterepo' if repo.vcs == 'hg' else 'upstream/master' next(repo.setup) assert_files(vcs.get_changed_files('AM', 'all'), ['bar', 'baz']) if repo.vcs == 'git': assert_files(vcs.get_changed_files('AM', mode='staged'), ['baz']) elif repo.vcs == 'hg': assert_files(vcs.get_changed_files('AM', 'staged'), ['bar', 'baz']) assert_files(vcs.get_outgoing_files('AM'), []) assert_files(vcs.get_outgoing_files('AM', remotepath), []) next(repo.setup) assert_files(vcs.get_changed_files('AM', 'all'), []) assert_files(vcs.get_changed_files('AM', 'staged'), []) assert_files(vcs.get_outgoing_files('AM'), ['bar', 'baz']) assert_files(vcs.get_outgoing_files('AM', remotepath), ['bar', 'baz'])
def get_dt_from_hg(path): with mozversioncontrol.get_repository_object(path=path) as repo: phase = repo._run_in_client(["log", "-r", ".", "-T" "{phase}"]) if phase.strip() != "public": return datetime.datetime.utcnow() repo_url = repo._run_in_client(["paths", "default"]) repo_url = repo_url.strip().replace("ssh://", "https://") repo_url = repo_url.replace("hg://", "https://") cs = repo._run_in_client(["log", "-r", ".", "-T" "{node}"]) url = pushlog_api_url.format(repo_url, cs) session = requests.Session() try: response = session.get(url) except Exception as e: msg = "Failed to retrieve push timestamp using {}\nError: {}".format(url, e) raise Exception(msg) data = response.json() date = data['pushdate'][0] return datetime.datetime.utcfromtimestamp(date)
def get_head_ref(): return get_repository_object(GECKO).head_ref
def vcs(self): if not self._vcs: self._vcs = get_repository_object(self.topsrcdir) return self._vcs
def repository(self): '''Get a `mozversioncontrol.Repository` object for the top source directory.''' return get_repository_object(self.topsrcdir)