[issue2725] Rebase across redundant renames

Joe Schneider bugs at mercurial.selenic.com
Thu Mar 24 19:36:21 UTC 2011


New submission from Joe Schneider <josschne at gmail.com>:

Using: Mercurial Distributed SCM (version 1.8.1)

I believe I've found a bug in rebase.

Summary:  In a repository which contains a set of renames that cancel each
other out  ( rev 1: rename file1 to file2,  rev2: unrelated,  rev3: rename
file2 back to file1), if you base a changeset off of a parent somewhere
inbetween the renames, then rebase that changeset to somewhere beyond the
second rename, the rebased changeset will delete file1.

Script to reproduce issue:
hg init rebase-test
cd rebase-test

echo testing > file1.txt
hg add file1.txt
hg ci -m "Adding file1"

hg rename file1.txt file2.txt
hg ci -m "Rename file1 to file2"

echo Unrelated change > unrelated.txt
hg add unrelated.txt
hg ci -m "Unrelated change"

hg rename file2.txt file1.txt
hg ci -m "Rename file2 back to file1"

hg update -r -2
echo Another unrelated change >> unrelated.txt
hg ci -m "Another unrelated change"

hg rebase -s . -d -2

hg log -v -r .


Output  ---  note the last changeset removes file1.txt even though it should
only affect unrelated.txt:
C:\>hg init rebase-test
C:\>cd rebase-test
C:\rebase-test>echo testing  1>file1.txt
C:\rebase-test>hg add file1.txt
C:\rebase-test>hg ci -m "Adding file1"
C:\rebase-test>hg rename file1.txt file2.txt
C:\rebase-test>hg ci -m "Rename file1 to file2"
C:\rebase-test>echo Unrelated change  1>unrelated.txt
C:\rebase-test>hg add unrelated.txt
C:\rebase-test>hg ci -m "Unrelated change"
C:\rebase-test>hg rename file2.txt file1.txt
C:\rebase-test>hg ci -m "Rename file2 back to file1"
C:\rebase-test>hg update -r -2
1 files updated, 0 files merged, 1 files removed, 0 files unresolved

C:\rebase-test>echo Another unrelated change  1>>unrelated.txt
C:\rebase-test>hg ci -m "Another unrelated change"
created new head

C:\rebase-test>hg rebase -s . -d -2
saved backup bundle to C:\rebase-test\.hg\strip-backup\8d44750eacae-backup.hg

C:\rebase-test>hg log -v -r .
changeset:   4:88546ee25e97
tag:         tip
user:        me
date:        Thu Mar 24 14:12:59 2011 -0500
files:       file1.txt unrelated.txt
description:
Another unrelated change

----------
messages: 15824
nosy: josschne
priority: urgent
status: unread
title: Rebase across redundant renames

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2725>
____________________________________________________


More information about the Mercurial-devel mailing list