[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Local changes lost across an upstream rename?

From: <junkio_at_cox.net>
Date: 2003-04-14 07:18:28 CEST

I am trying to figure out how to prevent subversion from losing
local changes made to an upstream file across an upstream
rename. The scenario is like this:

 - Upstream version #1 consists of an file, "Numbers":

   $ cat Numbers
   one
   to
   three
   four
   five

 - This is imported into the vendor branch; vendor branch is
   copied to the trunk and a typo "to" is fixed to "two"
   in the trunk.

 - Upstream version #2 renames "Numbers" to "Integers", and adds
   a couple of lines. Because we have not fed our fix back to
   the upstream, the typo remains:

   $ cat Integers
   one
   to
   three
   four
   five
   six
   seven

 - We want to update our trunk to vendor version #2, without losing
   our local fix.

I could not get the above scenario working without subversion throwing
away the local change. I suspect that the way I am trying to handle
vendor drops is not correct. The exact test I tried follows.

As a comparison, I also attached an equivalent test script that uses
Tom Lord's "arch". Although it takes forever to finish compared with
"svn" which runs reasonably quickly, it gets the rename right without
losing the local change.

################################################################
# Test directory and repository URL
T=/var/tmp/trash-svn
TR=file://$T/repo
rm -fr $T && mkdir -p $T

# The strategy used here is:
# - Import the first vendor drop in repo/vendor/current
# - Server-side copy repo/vendor/current to repo/vendor/1 (to tag)
# - Server-side copy repo/vendor/current to repo/trunk
# - Check out trunk, make local change, and commit.
# - Check out vendor/current, apply the upstream diff, including
# renames, and commit.
# - Server-side copy repo/vendor/current to repo/vendor/2 (to tag)
# - Check out trunk, merge the difference between repo/vendor/1 and
# repo/vendor/2 there, and commit.

# --------------------------------
# Create a repository for this test.
# Test repository URL is $TR
cd $T
svnadmin create $T/repo
svn mkdir -m 'Vendor drop' $TR/vendor
svn ls -R $TR

# --------------------------------
# The first vendor drop
cd $T
mkdir upstream-1
for n in one to three four five
do echo $n
done >upstream-1/Numbers

svn import -m 'Upstream #1' $TR upstream-1 vendor/current
svn copy -m 'Upstream #1' $TR/vendor/current $TR/vendor/1
svn copy -m 'Local trunk' $TR/vendor/current $TR/trunk

# --------------------------------
# Apply local fixes
cd $T
svn checkout $TR/trunk fix-1
cd fix-1
sed -e 's/to/two/' Numbers >Numbers+
mv Numbers+ Numbers
svn commit -m 'Fix spelling of 3'

# --------------------------------
# The second vendor drop
# First start from the latest vendor drop.
cd $T
svn checkout $TR/vendor/current vendor-1-to-2
cd vendor-1-to-2

# Somehow we figured out the rename in upstream, so rearrange
# the vendor drop the same way to preserve the rename history,
# and then modify it.
svn move Numbers Integers
for n in six seven
do echo $n; done >>Integers
svn commit -m 'Upstream #2'
svn copy -m 'Upstream #2' $TR/vendor/current $TR/vendor/2

# --------------------------------
# Now we want to update the trunk with the latest vendor changes.
cd $T
svn checkout $TR/trunk fix-2
cd fix-2

# The problem is that this merge loses the local fix.
# The second line from the resulting Integers file reads "to".
svn merge $TR/vendor/1 $TR/vendor/2
cat Integers
# The merge result is trash and not worth committing. Sigh...

################################################################

Here is an equivalent with arch. This takes forever to run but
gives a correct result.

################################################################
# Test directory and archive
T=/var/tmp/trash-arch
myid=a@b.c
larch my-id "A B C <$myid>"
TR=$myid--test
if larch archives -n | grep 'a@b\.c--test'
then
    larch register-archive -d $TR
fi

# The strategy used here is:
# - Import the first vendor drop in test--upstream--1.0
# - Tag test--upstream--1.0 as test--upstream-1--1.0--base-0 (tag)
# - Tag test--upstream--1.0 as test--trunk--1.0 (this becomes trunk)
# - Check out trunk, make local change, and commit.
# - Check out test--upstream--1.0, apply the upstream diff, including
# renames, and commit.
# - Tag test--upstream--1.0 as test--upstream-1--1.0--patch-1 (tag)
# - Check out trunk, make it up-to-date relative to test--upstream--1.0,
# and commit.

rm -fr $T && mkdir -p $T

# --------------------------------
# Create an archive for this test.
cd $T
larch make-archive $TR $T/archive
larch make-category -A $TR test
for b in upstream upstream-1 upstream-2 trunk
do
  larch make-branch $TR/test--$b
  larch make-version $TR/test--$b--1.0
done

# --------------------------------
# The first vendor drop
cd $T
mkdir upstream-1
for n in one to three four five
do echo $n
done >upstream-1/Numbers
cd upstream-1
larch init-tree
larch tagging-method explicit
larch set-tree-version $TR/test--upstream--1.0
larch add-log $TR/test--upstream--1.0

larch add Numbers
L=`larch make-log`
echo 'Summary: first vendor drop
Keywords:

First vendor drop' >$L
larch import

larch tag $TR/test--upstream--1.0 $TR/test--upstream-1--1.0
larch tag $TR/test--upstream--1.0 $TR/test--trunk--1.0

# --------------------------------
# Apply local fixes
cd $T
larch get $TR/test--trunk--1.0 fix-1
cd fix-1
sed -e 's/to/two/' Numbers >Numbers+
mv Numbers+ Numbers
L=`larch make-log`
echo 'Summary: typo fix
Keywords:

Typo fix' >$L
larch commit

# --------------------------------
# The second vendor drop
# First start from the latest vendor drop.
cd $T
larch get $TR/test--upstream--1.0 vendor-1-to-2
cd vendor-1-to-2

# Somehow we figured out the rename in upstream, so rearrange
# the vendor drop the same way.
mv Numbers Integers
larch move Numbers Integers
for n in six seven
do echo $n; done >>Integers
L=`larch make-log`
echo 'Summary: Upstream #2
Keywords:

Upstream #2' >$L
larch commit

larch tag $TR/test--upstream--1.0 $TR/test--upstream-1--1.0

# --------------------------------
# Now we want to update the trunk with the latest vendor changes.
cd $T
larch get $TR/test--trunk--1.0 fix-2
cd fix-2

# Find out which patchset is needed to bring us up to date
# relative to the vendor branch.
larch whats-missing --full -s $TR/test--upstream--1.0

cd ..
larch update fix-2 fix-2+ $TR/test--upstream--1.0

cd fix-2+
cat Integers

larch log-ls -s
L=`larch make-log`
echo >$L 'Summary: Upstream #2
Keywords:

Merge upstream #2
'
larch log-for-merge >>$L

larch commit

################################################################

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Apr 14 07:19:17 2003

This is an archived mail posted to the Subversion Dev mailing list.