Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching should detect patch level #737

Closed
pitrou opened this issue Jan 26, 2016 · 5 comments
Closed

Patching should detect patch level #737

pitrou opened this issue Jan 26, 2016 · 5 comments
Labels
locked [bot] locked due to inactivity stale::closed [bot] closed after being marked as stale stale [bot] marked as stale due to inactivity

Comments

@pitrou
Copy link

pitrou commented Jan 26, 2016

Currently conda-build only accepts patches applicable with patch -p0. Since modern VCSes (git, mercurial...) by default produce diffs applicable with patch -p1, it would be nice to detect those and accept them too.

@jakirkham
Copy link
Member

Believe @mingwandroid fixed this at some point. So this should probably be closed.

@mingwandroid
Copy link
Contributor

Yeah one of my first tasks at anaconda! -p0? What on Earth?

@ltalirz
Copy link

ltalirz commented Jun 25, 2021

Can this be closed?

I guess this is being handled in

def _guess_patch_strip_level(filesstr, src_dir):
""" Determine the patch strip level automatically. """
maxlevel = None
files = {filestr.encode(errors='ignore') for filestr in filesstr}
src_dir = src_dir.encode(errors='ignore')
guessed = False
for file in files:
numslash = file.count(b'/')
maxlevel = numslash if maxlevel is None else min(maxlevel, numslash)
if maxlevel == 0:
patchlevel = 0
else:
histo = {i: 0 for i in range(maxlevel + 1)}
for file in files:
parts = file.split(b'/')
for level in range(maxlevel + 1):
if os.path.exists(join(src_dir, *parts[-len(parts) + level:])):
histo[level] += 1
order = sorted(histo, key=histo.get, reverse=True)
if histo[order[0]] == histo[order[1]]:
print("Patch level ambiguous, selecting least deep")
guessed = True
patchlevel = min([key for key, value
in histo.items() if value == histo[order[0]]])
return patchlevel, guessed

@jakirkham
Copy link
Member

I think so. @chenghlee would you be able to close this?

@github-actions
Copy link

Hi there, thank you for your contribution!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this issue to remain open please:

  1. Verify that you can still reproduce the issue at hand
  2. Comment that the issue is still reproducible and include:
    - What OS and version you reproduced the issue on
    - What steps you followed to reproduce the issue

NOTE: If this issue was closed prematurely, please leave a comment.

Thanks!

@github-actions github-actions bot added the stale [bot] marked as stale due to inactivity label Jun 26, 2022
@github-actions github-actions bot added the stale::closed [bot] closed after being marked as stale label Jul 26, 2022
@github-actions github-actions bot added the locked [bot] locked due to inactivity label Jul 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity stale::closed [bot] closed after being marked as stale stale [bot] marked as stale due to inactivity
Projects
None yet
Development

No branches or pull requests

4 participants