Show More
@@ -181,11 +181,14 b' def ishunk(x):' | |||||
181 |
|
181 | |||
182 | def newandmodified(chunks, originalchunks): |
|
182 | def newandmodified(chunks, originalchunks): | |
183 | newlyaddedandmodifiedfiles = set() |
|
183 | newlyaddedandmodifiedfiles = set() | |
|
184 | alsorestore = set() | |||
184 | for chunk in chunks: |
|
185 | for chunk in chunks: | |
185 | if (ishunk(chunk) and chunk.header.isnewfile() and chunk not in |
|
186 | if (ishunk(chunk) and chunk.header.isnewfile() and chunk not in | |
186 | originalchunks): |
|
187 | originalchunks): | |
187 | newlyaddedandmodifiedfiles.add(chunk.header.filename()) |
|
188 | newlyaddedandmodifiedfiles.add(chunk.header.filename()) | |
188 | return newlyaddedandmodifiedfiles |
|
189 | alsorestore.update(set(chunk.header.files()) - | |
|
190 | set([chunk.header.filename()])) | |||
|
191 | return newlyaddedandmodifiedfiles, alsorestore | |||
189 |
|
192 | |||
190 | def parsealiases(cmd): |
|
193 | def parsealiases(cmd): | |
191 | return cmd.split("|") |
|
194 | return cmd.split("|") | |
@@ -326,8 +329,11 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
326 |
|
329 | |||
327 | # We need to keep a backup of files that have been newly added and |
|
330 | # We need to keep a backup of files that have been newly added and | |
328 | # modified during the recording process because there is a previous |
|
331 | # modified during the recording process because there is a previous | |
329 | # version without the edit in the workdir |
|
332 | # version without the edit in the workdir. We also will need to restore | |
330 | newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) |
|
333 | # files that were the sources of renames so that the patch application | |
|
334 | # works. | |||
|
335 | newlyaddedandmodifiedfiles, alsorestore = newandmodified(chunks, | |||
|
336 | originalchunks) | |||
331 | contenders = set() |
|
337 | contenders = set() | |
332 | for h in chunks: |
|
338 | for h in chunks: | |
333 | try: |
|
339 | try: | |
@@ -392,7 +398,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
392 | # 3a. apply filtered patch to clean repo (clean) |
|
398 | # 3a. apply filtered patch to clean repo (clean) | |
393 | if backups: |
|
399 | if backups: | |
394 | # Equivalent to hg.revert |
|
400 | # Equivalent to hg.revert | |
395 | m = scmutil.matchfiles(repo, backups.keys()) |
|
401 | m = scmutil.matchfiles(repo, set(backups.keys()) | alsorestore) | |
396 | mergemod.update(repo, repo.dirstate.p1(), branchmerge=False, |
|
402 | mergemod.update(repo, repo.dirstate.p1(), branchmerge=False, | |
397 | force=True, matcher=m) |
|
403 | force=True, matcher=m) | |
398 |
|
404 | |||
@@ -3172,7 +3178,13 b' def _performrevert(repo, parents, ctx, n' | |||||
3172 | except error.PatchError as err: |
|
3178 | except error.PatchError as err: | |
3173 | raise error.Abort(_('error parsing patch: %s') % err) |
|
3179 | raise error.Abort(_('error parsing patch: %s') % err) | |
3174 |
|
3180 | |||
3175 | newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) |
|
3181 | # FIXME: when doing an interactive revert of a copy, there's no way of | |
|
3182 | # performing a partial revert of the added file, the only option is | |||
|
3183 | # "remove added file <name> (Yn)?", so we don't need to worry about the | |||
|
3184 | # alsorestore value. Ideally we'd be able to partially revert | |||
|
3185 | # copied/renamed files. | |||
|
3186 | newlyaddedandmodifiedfiles, unusedalsorestore = newandmodified( | |||
|
3187 | chunks, originalchunks) | |||
3176 | if tobackup is None: |
|
3188 | if tobackup is None: | |
3177 | tobackup = set() |
|
3189 | tobackup = set() | |
3178 | # Apply changes |
|
3190 | # Apply changes |
@@ -864,7 +864,7 b' class header(object):' | |||||
864 | allhunks_re = re.compile('(?:index|deleted file) ') |
|
864 | allhunks_re = re.compile('(?:index|deleted file) ') | |
865 | pretty_re = re.compile('(?:new file|deleted file) ') |
|
865 | pretty_re = re.compile('(?:new file|deleted file) ') | |
866 | special_re = re.compile('(?:index|deleted|copy|rename|new mode) ') |
|
866 | special_re = re.compile('(?:index|deleted|copy|rename|new mode) ') | |
867 | newfile_re = re.compile('(?:new file|copy to)') |
|
867 | newfile_re = re.compile('(?:new file|copy to|rename to)') | |
868 |
|
868 | |||
869 | def __init__(self, header): |
|
869 | def __init__(self, header): | |
870 | self.header = header |
|
870 | self.header = header |
@@ -790,6 +790,96 b' TODO: Fix this on Windows. See issue 202' | |||||
790 | [255] |
|
790 | [255] | |
791 | #endif |
|
791 | #endif | |
792 |
|
792 | |||
|
793 | Test that splitting moves works properly (issue5723) | |||
|
794 | ---------------------------------------------------- | |||
|
795 | ||||
|
796 | $ hg init $TESTTMP/issue5723-mv | |||
|
797 | $ cd $TESTTMP/issue5723-mv | |||
|
798 | $ printf '1\n2\n' > file | |||
|
799 | $ hg ci -qAm initial | |||
|
800 | $ hg mv file file2 | |||
|
801 | $ printf 'a\nb\n1\n2\n3\n4\n' > file2 | |||
|
802 | $ cat > $TESTTMP/messages <<EOF | |||
|
803 | > split1, keeping only the numbered lines | |||
|
804 | > -- | |||
|
805 | > split2, keeping the lettered lines | |||
|
806 | > EOF | |||
|
807 | $ hg ci -m 'move and modify' | |||
|
808 | $ printf 'y\nn\na\na\n' | hg split | |||
|
809 | diff --git a/file b/file2 | |||
|
810 | rename from file | |||
|
811 | rename to file2 | |||
|
812 | 2 hunks, 4 lines changed | |||
|
813 | examine changes to 'file' and 'file2'? | |||
|
814 | (enter ? for help) [Ynesfdaq?] y | |||
|
815 | ||||
|
816 | @@ -0,0 +1,2 @@ | |||
|
817 | +a | |||
|
818 | +b | |||
|
819 | record change 1/2 to 'file2'? | |||
|
820 | (enter ? for help) [Ynesfdaq?] n | |||
|
821 | ||||
|
822 | @@ -2,0 +5,2 @@ 2 | |||
|
823 | +3 | |||
|
824 | +4 | |||
|
825 | record change 2/2 to 'file2'? | |||
|
826 | (enter ? for help) [Ynesfdaq?] a | |||
|
827 | ||||
|
828 | EDITOR: HG: Splitting 8c42fa635116. Write commit message for the first split changeset. | |||
|
829 | EDITOR: move and modify | |||
|
830 | EDITOR: | |||
|
831 | EDITOR: | |||
|
832 | EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |||
|
833 | EDITOR: HG: Leave message empty to abort commit. | |||
|
834 | EDITOR: HG: -- | |||
|
835 | EDITOR: HG: user: test | |||
|
836 | EDITOR: HG: branch 'default' | |||
|
837 | EDITOR: HG: added file2 | |||
|
838 | EDITOR: HG: removed file | |||
|
839 | created new head | |||
|
840 | diff --git a/file2 b/file2 | |||
|
841 | 1 hunks, 2 lines changed | |||
|
842 | examine changes to 'file2'? | |||
|
843 | (enter ? for help) [Ynesfdaq?] a | |||
|
844 | ||||
|
845 | EDITOR: HG: Splitting 8c42fa635116. So far it has been split into: | |||
|
846 | EDITOR: HG: - 478be2a70c27: split1, keeping only the numbered lines | |||
|
847 | EDITOR: HG: Write commit message for the next split changeset. | |||
|
848 | EDITOR: move and modify | |||
|
849 | EDITOR: | |||
|
850 | EDITOR: | |||
|
851 | EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |||
|
852 | EDITOR: HG: Leave message empty to abort commit. | |||
|
853 | EDITOR: HG: -- | |||
|
854 | EDITOR: HG: user: test | |||
|
855 | EDITOR: HG: branch 'default' | |||
|
856 | EDITOR: HG: changed file2 | |||
|
857 | saved backup bundle to $TESTTMP/issue5723-mv/.hg/strip-backup/8c42fa635116-a38044d4-split.hg (obsstore-off !) | |||
|
858 | $ hg log -T '{desc}: {files%"{file} "}\n' | |||
|
859 | split2, keeping the lettered lines: file2 | |||
|
860 | split1, keeping only the numbered lines: file file2 | |||
|
861 | initial: file | |||
|
862 | $ cat file2 | |||
|
863 | a | |||
|
864 | b | |||
|
865 | 1 | |||
|
866 | 2 | |||
|
867 | 3 | |||
|
868 | 4 | |||
|
869 | $ hg cat -r ".^" file2 | |||
|
870 | 1 | |||
|
871 | 2 | |||
|
872 | 3 | |||
|
873 | 4 | |||
|
874 | $ hg cat -r . file2 | |||
|
875 | a | |||
|
876 | b | |||
|
877 | 1 | |||
|
878 | 2 | |||
|
879 | 3 | |||
|
880 | 4 | |||
|
881 | ||||
|
882 | ||||
793 | Test that splitting copies works properly (issue5723) |
|
883 | Test that splitting copies works properly (issue5723) | |
794 | ---------------------------------------------------- |
|
884 | ---------------------------------------------------- | |
795 |
|
885 |
General Comments 0
You need to be logged in to leave comments.
Login now