You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Vladimir Prus <gh...@cs.msu.su> on 2002/02/14 14:16:19 UTC
[PATCH] Updating a locally modified file with endline translation
Log message:
Fixes a bug that prevented updating a locally modified file when endline
translation for the file is turned on.
* subversion/libsvn_wc/get_editor.c (svn_wc_install_file): Make path
for a temporary file relative to the directory where update happens.
* subversion/tests/clients/cmdline/update_tests.py
(update_modified_with_translation): New function.
Patch (against rev 1272)
Index: ./subversion/libsvn_wc/get_editor.c
===================================================================
--- ./subversion/libsvn_wc/get_editor.c
+++ ./subversion/libsvn_wc/get_editor.c Thu Feb 14 17:04:57 2002
@@ -1843,6 +1843,13 @@
FALSE,
pool));
+ /* Make the temporary working file name relative to
+ the parent directory. */
+ tmp_working = svn_stringbuf_ncreate
+ (tmp_working->data + parent_dir->len + 1,
+ tmp_working->len - parent_dir->len - 1,
+ pool);
+
/* Copy the working file to tmp-working with
LF's, and any keywords contracted. */
Index: ./subversion/tests/clients/cmdline/update_tests.py
===================================================================
--- ./subversion/tests/clients/cmdline/update_tests.py
+++ ./subversion/tests/clients/cmdline/update_tests.py Thu Feb 14 17:04:12
2002
@@ -474,6 +474,48 @@
None, None, None, None, 0,
'-r', '0')
+#----------------------------------------------------------------------
+
+def update_modified_with_translation(sbox):
+ "ensure update for locally modified file with eol translation works"
+
+ if sbox.build():
+ return 1
+
+ wc_dir = sbox.wc_dir
+ cwd = os.getcwd()
+ os.chdir(wc_dir)
+
+ # Create initial content of rho and turn on newline translation.
+ rho_path = os.path.join('A', 'D', 'G', 'rho')
+ f = open(rho_path, "w")
+ f.write("1\n2\n3\n4\n5\n6\n7\n8\n9\n")
+ f.close()
+ svntest.main.run_svn(None, 'propset', 'svn:eol-style', 'native', rho_path)
+ svntest.main.run_svn(None, 'ci', '-m', '"log msg"', rho_path)
+
+ # Make immeditate revision
+ f = open(rho_path, "w")
+ f.write("1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n")
+ f.close()
+ svntest.main.run_svn(None, 'ci', '-m', '"log msg"', rho_path)
+
+ # Locally modify a file
+ f = open(rho_path, "w")
+ f.write("1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n10\n")
+ f.close()
+
+ # Try updating, and see if anything is printed to stderr
+ result = 0
+ if svntest.main.run_svn(None, 'up', '-r1')[1]:
+ result = 1
+
+ os.chdir(cwd)
+
+ return result
+
+
+
########################################################################
# Run the tests
@@ -485,6 +527,7 @@
update_binary_file_2,
update_ignores_added,
update_to_rev_zero,
+ update_modified_with_translation,
# update_missing,
]
A question:
In the test code above, I have to explicitly change directory to working
copy. Otherwise, all commits/updates fill happen in subversion tree. However,
other tests in update_tests.py don't do that? What am I missing?
- Volodya
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Updating a locally modified file with endline translation
Posted by Ben Collins-Sussman <su...@collab.net>.
cmpilato@collab.net writes:
> Vladimir Prus <gh...@cs.msu.su> writes:
>
> > A question:
> > In the test code above, I have to explicitly change directory to
> > working copy. Otherwise, all commits/updates fill happen in
> > subversion tree. However, other tests in update_tests.py don't do
> > that? What am I missing?
>
> Most other tests, when building paths to operate on, use:
>
> os.path.join (wc_dir, 'A', 'D', 'G', 'rho')
>
> instead of what you did:
>
> os.path.join ('A', 'D', 'G', 'rho')
>
Also, a side comment: you're running 'commit' and other subcommands
directly via the run_svn() routine. This is legitimate, but it
doesn't provide as much coverage as most of the other tests. The
other tests use a different API: run_and_verify_FOO(), where foo is
one of {commit, update, status}.
Admittedly, this is a harder API to use -- but it's a lot more
thorough. It scans the contents of the working copy, it parses the
output of the subcommand, and it parses of the output of 'svn st -v'
after the subcommand is finished. For people who have been mystified
about writing tests this way, read the huge doc comment at the top of
subversion/tests/clients/cmdline/svntest/tree.py.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Updating a locally modified file with endline translation
Posted by cm...@collab.net.
Vladimir Prus <gh...@cs.msu.su> writes:
> A question:
> In the test code above, I have to explicitly change directory to
> working copy. Otherwise, all commits/updates fill happen in
> subversion tree. However, other tests in update_tests.py don't do
> that? What am I missing?
Most other tests, when building paths to operate on, use:
os.path.join (wc_dir, 'A', 'D', 'G', 'rho')
instead of what you did:
os.path.join ('A', 'D', 'G', 'rho')
The way our testing setup current exists, it is impossible to test any
Subversion operation that needs `.' as the target without doing the
cwd stuff like you did. If your test is not expected to behave any
differently in:
(cd foo; svn <command> .)
versus:
svn <command> foo
You should probably just prepend wc_dir to all the paths in use.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Updating a locally modified file with endline translation
Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Vladimir Prus <gh...@cs.msu.su> writes:
> I don't see any problem here: the second assignment uses the result of the
> first, doesn't it? This is similar to what happens on lines 1784
> and 1808 in the same file.
Indeed -- that makes sense, I misread your code. Thanks!
> > Also it seems odd that the old way would work in most circumstances,
> > yet not for your reproduction recipe.
>
> Does the old way work indeed? Is there any existing test that passes the
> block of code that I've patched?
Perhaps not, since its translation specific, and we've deferred those
tests till the alpha phase.
I'll reexamine with your points in mind,
-K
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Updating a locally modified file with endline translation
Posted by Vladimir Prus <gh...@cs.msu.su>.
Karl Fogel wrote:
> > ===================================================================
> > --- ./subversion/libsvn_wc/get_editor.c
> > +++ ./subversion/libsvn_wc/get_editor.c Thu Feb 14 17:04:57 2002
> > @@ -1843,6 +1843,13 @@
> > FALSE,
> > pool));
> >
> > + /* Make the temporary working file name relative
> > to + the parent directory. */
> > + tmp_working = svn_stringbuf_ncreate
> > + (tmp_working->data + parent_dir->len + 1,
> > + tmp_working->len - parent_dir->len - 1,
> > + pool);
> > +
> > /* Copy the working file to tmp-working with
> > LF's, and any keywords contracted. */
>
> The context here doesn't show it, but this new assignment to
> tmp_working immediately follows another assignment (by reference) to
> tmp_working. They can't both be right, since the first *use* of the
> variable occurs later on. :-)
I don't see any problem here: the second assignment uses the result of the
first, doesn't it? This is similar to what happens on lines 1784 and 1808 in
the same file.
> Also it seems odd that the old way would work in most circumstances,
> yet not for your reproduction recipe.
Does the old way work indeed? Is there any existing test that passes the
block of code that I've patched?
- Volodya
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Updating a locally modified file with endline translation
Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Vladimir Prus <gh...@cs.msu.su> writes:
> Log message:
> Fixes a bug that prevented updating a locally modified file when endline
> translation for the file is turned on.
>
> * subversion/libsvn_wc/get_editor.c (svn_wc_install_file): Make path
> for a temporary file relative to the directory where update happens.
>
> * subversion/tests/clients/cmdline/update_tests.py
> (update_modified_with_translation): New function.
>
> Patch (against rev 1272)
>
> Index: ./subversion/libsvn_wc/get_editor.c
> ===================================================================
> --- ./subversion/libsvn_wc/get_editor.c
> +++ ./subversion/libsvn_wc/get_editor.c Thu Feb 14 17:04:57 2002
> @@ -1843,6 +1843,13 @@
> FALSE,
> pool));
>
> + /* Make the temporary working file name relative to
> + the parent directory. */
> + tmp_working = svn_stringbuf_ncreate
> + (tmp_working->data + parent_dir->len + 1,
> + tmp_working->len - parent_dir->len - 1,
> + pool);
> +
> /* Copy the working file to tmp-working with
> LF's, and any keywords contracted. */
The context here doesn't show it, but this new assignment to
tmp_working immediately follows another assignment (by reference) to
tmp_working. They can't both be right, since the first *use* of the
variable occurs later on. :-)
Also it seems odd that the old way would work in most circumstances,
yet not for your reproduction recipe. Suspect there's something
deeper going on here, and am looking...
-K
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org