Bug 2725 - Rebase across redundant renames
Summary: Rebase across redundant renames
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: urgent bug
Assignee: Stefano Tortarolo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-24 13:36 UTC by Joe Schneider
Modified: 2011-04-21 12:00 UTC (History)
7 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Schneider 2011-03-24 13:36 UTC
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
Comment 1 HG Bot 2011-03-27 10:00 UTC
Fixed by http://selenic.com/repo/hg/rev/46c3043253fb
Stefano Tortarolo <stefano.tortarolo@gmail.com>
rebase: don't mark file as removed if missing in parent's manifest (issue2725)

(please test the fix)
Comment 2 Joe Schneider 2011-03-27 10:59 UTC
Tested fix by Stefano in both contrived example and original repository.
Issue appears fixed.  

Thanks Stefano!
Comment 3 HG Bot 2011-04-06 15:00 UTC
Fixed by http://selenic.com/repo/hg/rev/14c0988c314d
Stefano Tortarolo <stefano.tortarolo@gmail.com>
rebase: don't mark file as removed if missing in parent's manifest (issue2725)

(please test the fix)
Comment 4 Joe Schneider 2011-04-21 12:00 UTC
Tested with version 1.8.2+25-82845434e974, issue appears fixed.  Thanks!
Comment 5 Bugzilla 2012-05-12 09:18 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:18 EDT  ---

This bug was previously known as _bug_ 2725 at http://mercurial.selenic.com/bts/issue2725