Show More
@@ -346,19 +346,18 b' def ishunk(x):' | |||
|
346 | 346 | return isinstance(x, hunkclasses) |
|
347 | 347 | |
|
348 | 348 | |
|
349 | def newandmodified(chunks, originalchunks): | |
|
349 | def isheader(x): | |
|
350 | headerclasses = (crecordmod.uiheader, patch.header) | |
|
351 | return isinstance(x, headerclasses) | |
|
352 | ||
|
353 | ||
|
354 | def newandmodified(chunks): | |
|
350 | 355 | newlyaddedandmodifiedfiles = set() |
|
351 | 356 | alsorestore = set() |
|
352 | 357 | for chunk in chunks: |
|
353 | if ( | |
|
354 | ishunk(chunk) | |
|
355 | and chunk.header.isnewfile() | |
|
356 | and chunk not in originalchunks | |
|
357 | ): | |
|
358 | newlyaddedandmodifiedfiles.add(chunk.header.filename()) | |
|
359 | alsorestore.update( | |
|
360 | set(chunk.header.files()) - {chunk.header.filename()} | |
|
361 | ) | |
|
358 | if isheader(chunk) and chunk.isnewfile(): | |
|
359 | newlyaddedandmodifiedfiles.add(chunk.filename()) | |
|
360 | alsorestore.update(set(chunk.files()) - {chunk.filename()}) | |
|
362 | 361 | return newlyaddedandmodifiedfiles, alsorestore |
|
363 | 362 | |
|
364 | 363 | |
@@ -517,12 +516,12 b' def dorecord(' | |||
|
517 | 516 | diffopts.git = True |
|
518 | 517 | diffopts.showfunc = True |
|
519 | 518 | originaldiff = patch.diff(repo, changes=status, opts=diffopts) |
|
520 |
original |
|
|
519 | original_headers = patch.parsepatch(originaldiff) | |
|
521 | 520 | match = scmutil.match(repo[None], pats) |
|
522 | 521 | |
|
523 | 522 | # 1. filter patch, since we are intending to apply subset of it |
|
524 | 523 | try: |
|
525 |
chunks, newopts = filterfn(ui, original |
|
|
524 | chunks, newopts = filterfn(ui, original_headers, match) | |
|
526 | 525 | except error.PatchError as err: |
|
527 | 526 | raise error.InputError(_(b'error parsing patch: %s') % err) |
|
528 | 527 | opts.update(newopts) |
@@ -532,15 +531,11 b' def dorecord(' | |||
|
532 | 531 | # version without the edit in the workdir. We also will need to restore |
|
533 | 532 | # files that were the sources of renames so that the patch application |
|
534 | 533 | # works. |
|
535 | newlyaddedandmodifiedfiles, alsorestore = newandmodified( | |
|
536 | chunks, originalchunks | |
|
537 | ) | |
|
534 | newlyaddedandmodifiedfiles, alsorestore = newandmodified(chunks) | |
|
538 | 535 | contenders = set() |
|
539 | 536 | for h in chunks: |
|
540 |
|
|
|
537 | if isheader(h): | |
|
541 | 538 | contenders.update(set(h.files())) |
|
542 | except AttributeError: | |
|
543 | pass | |
|
544 | 539 | |
|
545 | 540 | changed = status.modified + status.added + status.removed |
|
546 | 541 | newfiles = [f for f in changed if f in contenders] |
@@ -3630,12 +3625,12 b' def _performrevert(' | |||
|
3630 | 3625 | diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts) |
|
3631 | 3626 | else: |
|
3632 | 3627 | diff = patch.diff(repo, ctx.node(), None, m, opts=diffopts) |
|
3633 |
original |
|
|
3628 | original_headers = patch.parsepatch(diff) | |
|
3634 | 3629 | |
|
3635 | 3630 | try: |
|
3636 | 3631 | |
|
3637 | 3632 | chunks, opts = recordfilter( |
|
3638 |
repo.ui, original |
|
|
3633 | repo.ui, original_headers, match, operation=operation | |
|
3639 | 3634 | ) |
|
3640 | 3635 | if operation == b'discard': |
|
3641 | 3636 | chunks = patch.reversehunks(chunks) |
@@ -3648,9 +3643,7 b' def _performrevert(' | |||
|
3648 | 3643 | # "remove added file <name> (Yn)?", so we don't need to worry about the |
|
3649 | 3644 | # alsorestore value. Ideally we'd be able to partially revert |
|
3650 | 3645 | # copied/renamed files. |
|
3651 | newlyaddedandmodifiedfiles, unusedalsorestore = newandmodified( | |
|
3652 | chunks, originalchunks | |
|
3653 | ) | |
|
3646 | newlyaddedandmodifiedfiles, unusedalsorestore = newandmodified(chunks) | |
|
3654 | 3647 | if tobackup is None: |
|
3655 | 3648 | tobackup = set() |
|
3656 | 3649 | # Apply changes |
@@ -1713,20 +1713,58 b' Moving files' | |||
|
1713 | 1713 | record this change to 'plain3'? |
|
1714 | 1714 | (enter ? for help) [Ynesfdaq?] y |
|
1715 | 1715 | |
|
1716 | ||
|
1717 | Rename file but discard edits | |
|
1718 | ||
|
1719 | $ echo content > new-file | |
|
1720 | $ hg add -q new-file | |
|
1721 | $ hg commit -qm 'new file' | |
|
1722 | $ hg mv new-file renamed-file | |
|
1723 | $ echo new-content >> renamed-file | |
|
1724 | $ hg commit -i -d '24 0' -m content-rename<<EOF | |
|
1725 | > y | |
|
1726 | > n | |
|
1727 | > EOF | |
|
1728 | diff --git a/new-file b/renamed-file | |
|
1729 | rename from new-file | |
|
1730 | rename to renamed-file | |
|
1731 | 1 hunks, 1 lines changed | |
|
1732 | examine changes to 'new-file' and 'renamed-file'? | |
|
1733 | (enter ? for help) [Ynesfdaq?] y | |
|
1734 | ||
|
1735 | @@ -1,1 +1,2 @@ | |
|
1736 | content | |
|
1737 | +new-content | |
|
1738 | record this change to 'renamed-file'? | |
|
1739 | (enter ? for help) [Ynesfdaq?] n | |
|
1740 | ||
|
1741 | $ hg status | |
|
1742 | M renamed-file | |
|
1743 | ? editedfile.orig | |
|
1744 | ? editedfile.rej | |
|
1745 | ? editor.sh | |
|
1746 | $ hg diff | |
|
1747 | diff -r * renamed-file (glob) | |
|
1748 | --- a/renamed-file Thu Jan 01 00:00:24 1970 +0000 | |
|
1749 | +++ b/renamed-file Thu Jan 01 00:00:00 1970 +0000 | |
|
1750 | @@ -1,1 +1,2 @@ | |
|
1751 | content | |
|
1752 | +new-content | |
|
1753 | ||
|
1716 | 1754 | The #if execbit block above changes the hash here on some systems |
|
1717 | 1755 | $ hg status -A plain3 |
|
1718 | 1756 | C plain3 |
|
1719 | 1757 | $ hg tip |
|
1720 |
changeset: 3 |
|
|
1758 | changeset: 34:* (glob) | |
|
1721 | 1759 | tag: tip |
|
1722 | 1760 | user: test |
|
1723 |
date: Thu Jan 01 00:00:2 |
|
|
1724 |
summary: |
|
|
1761 | date: Thu Jan 01 00:00:24 1970 +0000 | |
|
1762 | summary: content-rename | |
|
1725 | 1763 | |
|
1726 | 1764 | Editing patch of newly added file |
|
1727 | 1765 | |
|
1728 | 1766 | $ hg update -C . |
|
1729 |
|
|
|
1767 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
1730 | 1768 | $ cat > editor.sh << '__EOF__' |
|
1731 | 1769 | > cat "$1" | sed "s/first/very/g" > tt |
|
1732 | 1770 | > mv tt "$1" |
@@ -1737,7 +1775,7 b' Editing patch of newly added file' | |||
|
1737 | 1775 | > This is the third line |
|
1738 | 1776 | > __EOF__ |
|
1739 | 1777 | $ hg add newfile |
|
1740 |
$ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '2 |
|
|
1778 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '25 0' -medit-patch-new <<EOF | |
|
1741 | 1779 | > y |
|
1742 | 1780 | > e |
|
1743 | 1781 | > EOF |
@@ -1770,7 +1808,7 b' Add new file from within a subdirectory' | |||
|
1770 | 1808 | $ cd folder |
|
1771 | 1809 | $ echo "foo" > bar |
|
1772 | 1810 | $ hg add bar |
|
1773 |
$ hg commit -i -d '2 |
|
|
1811 | $ hg commit -i -d '26 0' -mnewfilesubdir <<EOF | |
|
1774 | 1812 | > y |
|
1775 | 1813 | > y |
|
1776 | 1814 | > EOF |
@@ -1786,15 +1824,15 b' Add new file from within a subdirectory' | |||
|
1786 | 1824 | |
|
1787 | 1825 | The #if execbit block above changes the hashes here on some systems |
|
1788 | 1826 | $ hg tip -p |
|
1789 |
changeset: 3 |
|
|
1827 | changeset: 36:* (glob) | |
|
1790 | 1828 | tag: tip |
|
1791 | 1829 | user: test |
|
1792 |
date: Thu Jan 01 00:00:2 |
|
|
1830 | date: Thu Jan 01 00:00:26 1970 +0000 | |
|
1793 | 1831 | summary: newfilesubdir |
|
1794 | 1832 | |
|
1795 | 1833 | diff -r * -r * folder/bar (glob) |
|
1796 | 1834 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1797 |
+++ b/folder/bar Thu Jan 01 00:00:2 |
|
|
1835 | +++ b/folder/bar Thu Jan 01 00:00:26 1970 +0000 | |
|
1798 | 1836 | @@ -0,0 +1,1 @@ |
|
1799 | 1837 | +foo |
|
1800 | 1838 |
General Comments 0
You need to be logged in to leave comments.
Login now