Skip to main content

Converting patches of old version to the ones with current line number

Project description

patchtool

Prerequisite

Here I will simply list the packages on which the tool is implemented. It should be working fine with similar environment

OS: Linux

Interpreter: 3.6.8

Version Controller: git 2.18.1

Compiler: gcc-8.3.1

Kernel: 4.18.0-128.el8.x86_64

Installation

Install via pip

pip install patchtool

How to use

usage: patchtool [-h] -d D -p P [-s]

optional arguments:
  -h, --help  show this help message and exit
  -d D        The directory where this patch tool is hoped to be used
  -p P        Directory of the patch file
  -s S        The style in which you would like the updated file to be output

The patchtool provides with two modes where you can choose either to let the tool verify if the code in patch still exists and unmodified, or just do not check their validity, and output the line-number-modified patches. To verify the code, add -s verify after the command, and the output will tell you at the command whether each commit is verified. As the excecution finishes, two files will be generated with verified and unverified separately in each file.

An ordinary usage goes like this:

patchtool -d [git_directory] -p [patchfile_path]

Directly output the updated line number to the terminal.

patchtool -d [git_directory] -p [patchfile_path] -s verify

This will generate three files:

  1. .unverified.patch: patches that has the possibility where there might be discrepancies from the reality and what the updated-patch shows
  2. .verified.patch: patches showing the codes that are identical to the real code
  3. verification_info.log: a file showing the results of verification

Requirements for input patch file

A standard input has a format as follow, which can be automatically generated by virtcov, a tool used for libvirt coverage test:

From <commit_hash> 
[headers]
<neck_information>
<body>
--
<version>

where <commit hash> is a hexadecimal integer generated by the submission where the bug was solved. [headers] represents header information of the commit. <neck_information> is necessary for separating header and body, with a format shown as below:

\s[0-9]*\sfile(s)?\schanged,\s[0-9]*\s(insertions\(\+\)|deletions\(\-\))(,\s[0-9]*\sdeletions\(\-\))?

The <body> part shows the diff information of the bug commit, whose format is given below:

diff --git a/<sorce_directory> b/<dir_after_effect>
index <hash> <operation_code>
--- a/<sorce_directory>
+++ b/<dir_after_effect>
@@ -[0-9]{1,},[0-9]{1,} +[0-9]{1,},[0-9]{1,} @@ [other_info]
...

which can be repeated multiple times.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

patchtool-1.2.0.post1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

patchtool-1.2.0.post1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file patchtool-1.2.0.post1.tar.gz.

File metadata

  • Download URL: patchtool-1.2.0.post1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.8

File hashes

Hashes for patchtool-1.2.0.post1.tar.gz
Algorithm Hash digest
SHA256 a531ceff8002c2fccc5fe033ede89b8c1a9c2ceb57f161542431bd9ebc32064e
MD5 25f2efa66068d4c4bf6216a5fe2867a5
BLAKE2b-256 b62e907cc59379db63895526e302ac7ca9cbffa434c505bfd900d91d2241a298

See more details on using hashes here.

File details

Details for the file patchtool-1.2.0.post1-py3-none-any.whl.

File metadata

  • Download URL: patchtool-1.2.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.8

File hashes

Hashes for patchtool-1.2.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 e6d197d1e8786dc34a9562689dc6e8d8be52304a6eb6701a466e18804819f903
MD5 b75ff71109a9780d8a16749458dd06cf
BLAKE2b-256 a37f3dd97fef00615edce208f8081e344d80535afd876bbe3cc513613df92239

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page