[PATCH] record: use in-memory patching for recording changes (fixes #3591)
Patrick Mézard
patrick at mezard.eu
Tue Aug 28 01:56:22 CDT 2012
Le 27/08/12 21:29, michalsznajder at gmail.com a écrit :
> # HG changeset patch
> # User Michal Sznajder <michalsznajder at gmail.com>
> # Date 1345485746 -7200
> # Node ID afe2f7b7a7fdd131827c889e472e01564f21f63d
> # Parent 99a2a4ae35e2180b7f825ef2677c36d538eac4ba
> record: use in-memory patching for recording changes (fixes #3591)
>
> record extensions was using revert and patching of working directory to achieve
> its work. This led to bugs in the past and is somewhat ridiculous as an
> implementation method.
>
> Solution is to use in-memory commit context and create a revison without
> touching working directory.
>
> =================
> Notes on changes:
> - test-record.t passes without one small tests (when someone breaks patch
> while editing it - i'll try to fix it later)
> - patch.filestore(): do we want to get rid of it and do everything in memeory? how?
> - repo.setparents(newrev): is this good way to update to given revison?
Did you check MQ qrefresh --interactive? I remember the reason I did not move record to patchrepo after implementing it was the integration with MQ.
Also, running the full test suite gives:
--- /home/pmezard/repos/hg-tests/tests/test-check-pyflakes.t
+++ /home/pmezard/repos/hg-tests/tests/test-check-pyflakes.t.err
@@ -1,6 +1,9 @@
$ "$TESTDIR/hghave" pyflakes || exit 80
$ cd "`dirname "$TESTDIR"`"
$ pyflakes mercurial hgext 2>&1 | "$TESTDIR/filterpyflakes.py"
- hgext/inotify/linux/__init__.py:*: 'from _inotify import *' used; unable to detect undefined names (glob)
+ hgext/record.py:13: 'errno' imported but unused
+ hgext/record.py:11: 'hg' imported but unused
+ hgext/record.py:13: 'shutil' imported but unused
+ hgext/inotify/linux/__init__.py:22: 'from _inotify import *' used; unable to detect undefined names
ERROR: /home/pmezard/repos/hg-tests/tests/test-check-pyflakes.t output changed
!.........s.....................s....s.............
--- /home/pmezard/repos/hg-tests/tests/test-check-code-hg.t
+++ /home/pmezard/repos/hg-tests/tests/test-check-code-hg.t.err
@@ -6,6 +6,19 @@
> exit 80
> fi
$ hg manifest | xargs "$check_code" || echo 'FAILURE IS NOT AN OPTION!!!'
+ hgext/record.py:502:
+ > Its job is to interactively filter local changes, and create
+ trailing whitespace
+ hgext/record.py:540:
+ > newrev = None
+ trailing whitespace
+ hgext/record.py:548:
+ >
+ trailing whitespace
+ hgext/record.py:565:
+ > repo.dirstate.rebuild(repo[newrev].node(), repo[newrev].manifest())
+ line too long
+ FAILURE IS NOT AN OPTION!!!
$ hg manifest | xargs "$check_code" --warnings --nolineno --per-file=0 || true
hgext/convert/cvsps.py:0:
@@ -71,6 +84,18 @@
hgext/patchbomb.py:0:
> ui.write('From: %s\n' % sender)
warning: unwrapped ui message
+ hgext/record.py:0:
+ >
+ trailing whitespace
+ hgext/record.py:0:
+ > repo.dirstate.rebuild(repo[newrev].node(), repo[newrev].manifest())
+ line too long
+ hgext/record.py:0:
+ > Its job is to interactively filter local changes, and create
+ trailing whitespace
+ hgext/record.py:0:
+ > newrev = None
+ trailing whitespace
mercurial/commands.py:0:
> ui.note('branch %s\n' % data)
warning: unwrapped ui message
ERROR: /home/pmezard/repos/hg-tests/tests/test-check-code-hg.t output changed
!......s.....................................s...................................................................s......................................
--- /home/pmezard/repos/hg-tests/tests/test-mq-subrepo.t
+++ /home/pmezard/repos/hg-tests/tests/test-mq-subrepo.t.err
@@ -264,17 +264,13 @@
diff --git a/.hgsub b/.hgsub
new file mode 100644
examine changes to '.hgsub'? [Ynesfdaq?]
- abort: uncommitted changes in subrepository sub
- [255]
+ [0]
% update substate when adding .hgsub w/clean updated subrepo
- A .hgsub
% qrecord --config ui.interactive=1 -m0 0.diff
- diff --git a/.hgsub b/.hgsub
- new file mode 100644
- examine changes to '.hgsub'? [Ynesfdaq?]
- path sub
- source sub
- revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
+ no changes to record
+ path sub
+ source sub
+ revision
$ testmod qrecord --config ui.interactive=1 -m1 1.diff <<EOF
> y
@@ -292,27 +288,19 @@
sub = sub
+sub2 = sub2
record this change to '.hgsub'? [Ynesfdaq?]
- abort: uncommitted changes in subrepository sub2
- [255]
+ [0]
% update substate when modifying .hgsub w/clean updated subrepo
- M .hgsub
% qrecord --config ui.interactive=1 -m1 1.diff
- diff --git a/.hgsub b/.hgsub
- 1 hunks, 1 lines changed
- examine changes to '.hgsub'? [Ynesfdaq?]
- @@ -1,1 +1,2 @@
- sub = sub
- +sub2 = sub2
- record this change to '.hgsub'? [Ynesfdaq?]
- path sub
- source sub
- revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
+ no changes to record
+ path sub
+ source sub
+ revision
path sub2
source sub2
- revision 1f94c7611cc6b74f5a17b16121a1170d44776845
+ revision
$ hg qpop -qa
- patch queue now empty
+ no patches applied
$ testrm1 qrecord --config ui.interactive=1 -m2 2.diff <<EOF
> y
> y
@@ -328,7 +316,7 @@
% debugsub should be empty
$ hg qpop -qa
- patch queue now empty
+ no patches applied
$ testrm2 qrecord --config ui.interactive=1 -m3 3.diff <<EOF
> y
> y
ERROR: /home/pmezard/repos/hg-tests/tests/test-mq-subrepo.t output changed
!.........................................
--- /home/pmezard/repos/hg-tests/tests/test-qrecord.t
+++ /home/pmezard/repos/hg-tests/tests/test-qrecord.t.err
@@ -280,9 +280,6 @@
$ hg tip -p
changeset: 1:5d1ca63427ee
- tag: a.patch
- tag: qbase
- tag: qtip
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
@@ -367,8 +364,6 @@
$ hg tip -p
changeset: 2:b056198bf878
- tag: b.patch
- tag: qtip
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
ERROR: /home/pmezard/repos/hg-tests/tests/test-qrecord.t output changed
!............................................
--- /home/pmezard/repos/hg-tests/tests/test-keyword.t
+++ /home/pmezard/repos/hg-tests/tests/test-keyword.t.err
@@ -360,7 +360,7 @@
5f5eb23505c3+ tip
$ hg status
M a
- A r
+ ? r
Cat modified file a
@@ -468,8 +468,8 @@
diff --git a/r b/r
new file mode 100644
examine changes to 'r'? [Ynesfdaq?]
+ patching file r
r
- committed changeset 3:82a2f715724d
overwriting r expanding keywords
- status call required for dirstate.normallookup() check
$ hg status r
@@ -492,8 +492,8 @@
diff --git a/i b/i
new file mode 100644
examine changes to 'i'? [Ynesfdaq?]
+ patching file i
i
- committed changeset 3:9f40ceb5a072
$ cat i
$Id$
$ hg -q rollback
ERROR: /home/pmezard/repos/hg-tests/tests/test-keyword.t output changed
!..
--- /home/pmezard/repos/hg-tests/tests/test-mq-qrefresh-interactive.t
+++ /home/pmezard/repos/hg-tests/tests/test-mq-qrefresh-interactive.t.err
@@ -212,11 +212,13 @@
diff --git a/dir/a.txt b/dir/a.txt
1 hunks, 1 lines changed
examine changes to 'dir/a.txt'? [Ynesfdaq?]
+ abort: empty commit message
+ [255]
After partial qrefresh 'tip'
$ hg tip -p
- changeset: 1:0738af1a8211
+ changeset: 1:ed27675cb5df
tag: patch
tag: qbase
tag: qtip
@@ -225,41 +227,32 @@
date: Thu Jan 01 00:00:00 1970 +0000
summary: [mq]: patch
- diff -r 1fd39ab63a33 -r 0738af1a8211 1.txt
- --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
- +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
- @@ -1,5 +1,5 @@
- 1
- -2
- +2 2
- 3
- 4
- 5
- diff -r 1fd39ab63a33 -r 0738af1a8211 2.txt
- --- a/2.txt Thu Jan 01 00:00:00 1970 +0000
- +++ b/2.txt Thu Jan 01 00:00:00 1970 +0000
- @@ -1,5 +1,5 @@
- a
- -b
- +b b
- c
- d
- e
After partial qrefresh 'diff'
$ hg diff --nodates
- diff -r 0738af1a8211 1.txt
+ diff -r ed27675cb5df 1.txt
--- a/1.txt
+++ b/1.txt
@@ -1,5 +1,5 @@
1
- 2 2
- 3
- -4
- +4 4
- 5
- diff -r 0738af1a8211 dir/a.txt
+ -2
+ +2 2
+ 3
+ -4
+ +4 4
+ 5
+ diff -r ed27675cb5df 2.txt
+ --- a/2.txt
+ +++ b/2.txt
+ @@ -1,5 +1,5 @@
+ a
+ -b
+ +b b
+ c
+ d
+ e
+ diff -r ed27675cb5df dir/a.txt
--- a/dir/a.txt
+++ b/dir/a.txt
@@ -1,4 +1,4 @@
@@ -278,31 +271,37 @@
> y
> EOF
diff --git a/1.txt b/1.txt
+ 2 hunks, 2 lines changed
+ examine changes to '1.txt'? [Ynesfdaq?]
+ @@ -1,3 +1,3 @@
+ 1
+ -2
+ +2 2
+ 3
+ record change 1/4 to '1.txt'? [Ynesfdaq?]
+ @@ -3,3 +3,3 @@
+ 3
+ -4
+ +4 4
+ 5
+ record change 2/4 to '1.txt'? [Ynesfdaq?]
+ diff --git a/2.txt b/2.txt
1 hunks, 1 lines changed
- examine changes to '1.txt'? [Ynesfdaq?]
- @@ -1,5 +1,5 @@
- 1
- 2 2
- 3
- -4
- +4 4
- 5
- record change 1/2 to '1.txt'? [Ynesfdaq?]
- diff --git a/dir/a.txt b/dir/a.txt
- 1 hunks, 1 lines changed
- examine changes to 'dir/a.txt'? [Ynesfdaq?]
- @@ -1,4 +1,4 @@
- -hello world
- +hello world!
-
- someone
- up
- record change 2/2 to 'dir/a.txt'? [Ynesfdaq?]
+ examine changes to '2.txt'? [Ynesfdaq?]
+ @@ -1,5 +1,5 @@
+ a
+ -b
+ +b b
+ c
+ d
+ e
+ record change 3/4 to '2.txt'? [Ynesfdaq?] abort: response expected
+ [255]
After final qrefresh 'tip'
$ hg tip -p
- changeset: 1:2c3f66afeed9
+ changeset: 1:ed27675cb5df
tag: patch
tag: qbase
tag: qtip
@@ -311,40 +310,40 @@
date: Thu Jan 01 00:00:00 1970 +0000
summary: [mq]: patch
- diff -r 1fd39ab63a33 -r 2c3f66afeed9 1.txt
- --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
- +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
- @@ -1,5 +1,5 @@
- 1
- -2
- +2 2
- 3
- -4
- +4 4
- 5
- diff -r 1fd39ab63a33 -r 2c3f66afeed9 2.txt
- --- a/2.txt Thu Jan 01 00:00:00 1970 +0000
- +++ b/2.txt Thu Jan 01 00:00:00 1970 +0000
- @@ -1,5 +1,5 @@
- a
- -b
- +b b
- c
- d
- e
- diff -r 1fd39ab63a33 -r 2c3f66afeed9 dir/a.txt
- --- a/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
- +++ b/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
+
+
+After qrefresh 'diff'
+
+ $ hg diff --nodates
+ diff -r ed27675cb5df 1.txt
+ --- a/1.txt
+ +++ b/1.txt
+ @@ -1,5 +1,5 @@
+ 1
+ -2
+ +2 2
+ 3
+ -4
+ +4 4
+ 5
+ diff -r ed27675cb5df 2.txt
+ --- a/2.txt
+ +++ b/2.txt
+ @@ -1,5 +1,5 @@
+ a
+ -b
+ +b b
+ c
+ d
+ e
+ diff -r ed27675cb5df dir/a.txt
+ --- a/dir/a.txt
+ +++ b/dir/a.txt
@@ -1,4 +1,4 @@
-hello world
+hello world!
someone
up
-
-
-After qrefresh 'diff'
-
- $ hg diff --nodates
$ cd ..
ERROR: /home/pmezard/repos/hg-tests/tests/test-mq-qrefresh-interactive.t output changed
!s..........
--- /home/pmezard/repos/hg-tests/tests/test-record.t
+++ /home/pmezard/repos/hg-tests/tests/test-record.t.err
@@ -1146,7 +1146,6 @@
record this change to 'editedfile'? [Ynesfdaq?]
patching file editedfile
Hunk #1 FAILED at 0
- 1 out of 1 hunks FAILED -- saving rejects to file editedfile.rej
abort: patch failed to apply
[255]
$ cat editedfile
@@ -1158,15 +1157,8 @@
This change will be committed
This is the third line
$ cat editedfile.rej
- --- editedfile
- +++ editedfile
- @@ -1,3 +1,3 @@
- -That is the first line
- -That change will be committed
- -That is the third line
- +That change will not be committed
- +That is the second line
- +That line has been added
+ cat: editedfile.rej: No such file or directory
+ [1]
$ hg up -C
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ERROR: /home/pmezard/repos/hg-tests/tests/test-record.t output changed
!.................................................................................................................
Skipped test-casecollision-merge.t: missing feature: case insensitive file system
Skipped test-no-symlinks.t: system supports symbolic links
Skipped test-casefolding.t: missing feature: case insensitive file system
Skipped test-convert-baz.t: missing feature: GNU Arch baz client
Skipped test-convert-p4.t: missing feature: Perforce server and client
Skipped test-convert-p4-filetypes.t: missing feature: Perforce server and client
Skipped test-convert-mtn.t: missing feature: monotone client (>= 1.0)
Failed test-record.t: output changed
Failed test-mq-qrefresh-interactive.t: output changed
Failed test-mq-subrepo.t: output changed
Failed test-qrecord.t: output changed
Failed test-keyword.t: output changed
Failed test-check-pyflakes.t: output changed
Failed test-check-code-hg.t: output changed
# Ran 443 tests, 7 skipped, 7 failed.
--
Patrick Mézard
More information about the Mercurial-devel
mailing list