Mercurial > hgrepos > Python2 > PyMuPDF
comparison setup.py @ 24:21c6080bc183
When building "_build.py": also handle Mercurial repositories.
BUGS: Attribute names are left as-is.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 19 Sep 2025 18:19:48 +0200 |
| parents | 3b13504f9d89 |
| children | 575f70dbc259 |
comparison
equal
deleted
inserted
replaced
| 23:3b13504f9d89 | 24:21c6080bc183 |
|---|---|
| 364 def git_info( directory): | 364 def git_info( directory): |
| 365 ''' | 365 ''' |
| 366 Returns `(sha, comment, diff, branch)`, all items are str or None if not | 366 Returns `(sha, comment, diff, branch)`, all items are str or None if not |
| 367 available. | 367 available. |
| 368 | 368 |
| 369 Also handles Mercurial repository information. | |
| 370 | |
| 369 directory: | 371 directory: |
| 370 Root of git checkout. | 372 Root of git checkout. |
| 371 ''' | 373 ''' |
| 372 sha, comment, diff, branch = '', '', '', '' | 374 sha, comment, diff, branch = '', '', '', '' |
| 373 cp = subprocess.run( | 375 if os.path.isdir(os.path.join(directory, '.hg')): |
| 374 f'cd {directory} && (PAGER= git show --pretty=oneline|head -n 1 && git diff)', | 376 cp = subprocess.run( |
| 375 capture_output=1, | 377 f'hg -R {directory} id -i', |
| 376 shell=1, | 378 capture_output=1, |
| 377 text=1, | 379 shell=1, |
| 378 ) | 380 text=1, |
| 379 if cp.returncode == 0: | 381 ) |
| 380 sha, _ = cp.stdout.split(' ', 1) | 382 if cp.returncode == 0: |
| 381 comment, diff = _.split('\n', 1) | 383 sha = cp.stdout.strip() |
| 382 cp = subprocess.run( | 384 cp = subprocess.run( |
| 383 f'cd {directory} && git rev-parse --abbrev-ref HEAD', | 385 f'hg -R {directory} diff --git', |
| 384 capture_output=1, | 386 capture_output=1, |
| 385 shell=1, | 387 shell=1, |
| 386 text=1, | 388 text=1, |
| 387 ) | 389 ) |
| 388 if cp.returncode == 0: | 390 if cp.returncode == 0: |
| 389 branch = cp.stdout.strip() | 391 diff = cp.stdout |
| 392 cp = subprocess.run( | |
| 393 f'hg -R {directory} log -r. --template "{{branch}}"', | |
| 394 capture_output=1, | |
| 395 shell=1, | |
| 396 text=1, | |
| 397 ) | |
| 398 if cp.returncode == 0: | |
| 399 branch = cp.stdout.strip() | |
| 400 fp = subprocess.run( | |
| 401 f'hg -R {directory} log -r. --template "{{desc|firstline}}"', | |
| 402 capture_output=1, | |
| 403 shell=1, | |
| 404 text=1, | |
| 405 ) | |
| 406 if cp.returncode == 0: | |
| 407 comment = cp.stdout.strip() | |
| 408 else: | |
| 409 cp = subprocess.run( | |
| 410 f'cd {directory} && (PAGER= git show --pretty=oneline|head -n 1 && git diff)', | |
| 411 capture_output=1, | |
| 412 shell=1, | |
| 413 text=1, | |
| 414 ) | |
| 415 if cp.returncode == 0: | |
| 416 sha, _ = cp.stdout.split(' ', 1) | |
| 417 comment, diff = _.split('\n', 1) | |
| 418 cp = subprocess.run( | |
| 419 f'cd {directory} && git rev-parse --abbrev-ref HEAD', | |
| 420 capture_output=1, | |
| 421 shell=1, | |
| 422 text=1, | |
| 423 ) | |
| 424 if cp.returncode == 0: | |
| 425 branch = cp.stdout.strip() | |
| 390 log(f'git_info(): directory={directory!r} returning branch={branch!r} sha={sha!r} comment={comment!r}') | 426 log(f'git_info(): directory={directory!r} returning branch={branch!r} sha={sha!r} comment={comment!r}') |
| 391 return sha, comment, diff, branch | 427 return sha, comment, diff, branch |
| 392 | 428 |
| 393 | 429 |
| 394 def git_patch(directory, patch, hard=False): | 430 def git_patch(directory, patch, hard=False): |
