Patchwork D10777: fuzz: add hg to sys.path when constructing mpatch corpus

login
register
mail settings
Submitter phabricator
Date May 27, 2021, 4:11 p.m.
Message ID <differential-rev-PHID-DREV-hytt2xaa6dr7jaa4q7q7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49097/
State Superseded
Headers show

Comments

phabricator - May 27, 2021, 4:11 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10777

AFFECTED FILES
  contrib/fuzz/mpatch_corpus.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/fuzz/mpatch_corpus.py b/contrib/fuzz/mpatch_corpus.py
--- a/contrib/fuzz/mpatch_corpus.py
+++ b/contrib/fuzz/mpatch_corpus.py
@@ -1,10 +1,15 @@ 
 from __future__ import absolute_import, print_function
 
 import argparse
+import os
 import struct
 import sys
 import zipfile
 
+# Add ../.. to sys.path as an absolute path so we can import hg modules
+hgloc = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
+sys.path[0:0] = [hgloc]
+
 from mercurial import (
     hg,
     ui as uimod,