Patchwork [2,of,2] histedit: use base for computing renames when folding (issue3729)

login
register
mail settings
Submitter Martin Geisler
Date July 15, 2013, 1:14 p.m.
Message ID <33b5c323b4e878ff106a.1373894087@go>
Download mbox | patch
Permalink /patch/1897/
State Accepted
Commit f6b047cf9272121a36c47a05cee4adb0c95629fb
Headers show

Comments

Martin Geisler - July 15, 2013, 1:14 p.m.
# HG changeset patch
# User Martin Geisler <martin@geisler.net>
# Date 1373893482 -7200
#      Mon Jul 15 15:04:42 2013 +0200
# Branch stable
# Node ID 33b5c323b4e878ff106a6167b5fdfb9b9b745b6b
# Parent  02b3fca42ffba93191fd89b4a156af60840a66c4
histedit: use base for computing renames when folding (issue3729)

When a file was renamed in the very first changeset being histedited,
the rename was not detected. Consider a history like this:

   0  base: add a.txt
   1  first: rename a.txt to b.txt
   2  last: edit b.txt

When 1 and 2 are edited, copies.pathcopies(first, last) correctly
returns that nothing was renamed. We must instead use
copies.pathcopies(first, last) to detect the initial rename.
Martin Geisler - July 15, 2013, 1:17 p.m.
Martin Geisler <martin@geisler.net> writes:

> # HG changeset patch
> # User Martin Geisler <martin@geisler.net>
> # Date 1373893482 -7200
> #      Mon Jul 15 15:04:42 2013 +0200
> # Branch stable
> # Node ID 33b5c323b4e878ff106a6167b5fdfb9b9b745b6b
> # Parent  02b3fca42ffba93191fd89b4a156af60840a66c4
> histedit: use base for computing renames when folding (issue3729)

These patches are for the stable branch -- I forgot to --flag them when
I sent them. Maybe we should let patchbomb ask if it should use the
branch name as a flag?
Augie Fackler - July 16, 2013, 3:07 p.m.
On Mon, Jul 15, 2013 at 03:14:47PM +0200, Martin Geisler wrote:
> # HG changeset patch
> # User Martin Geisler <martin@geisler.net>
> # Date 1373893482 -7200
> #      Mon Jul 15 15:04:42 2013 +0200
> # Branch stable
> # Node ID 33b5c323b4e878ff106a6167b5fdfb9b9b745b6b
> # Parent  02b3fca42ffba93191fd89b4a156af60840a66c4
> histedit: use base for computing renames when folding (issue3729)

queued these, thanks

>
> When a file was renamed in the very first changeset being histedited,
> the rename was not detected. Consider a history like this:
>
>    0  base: add a.txt
>    1  first: rename a.txt to b.txt
>    2  last: edit b.txt
>
> When 1 and 2 are edited, copies.pathcopies(first, last) correctly
> returns that nothing was renamed. We must instead use
> copies.pathcopies(first, last) to detect the initial rename.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -247,7 +247,7 @@
>          files.update(ctx.files())
>
>      # Recompute copies (avoid recording a -> b -> a)
> -    copied = copies.pathcopies(first, last)
> +    copied = copies.pathcopies(base, last)
>
>      # prune files which were reverted by the updates
>      def samefile(f):
> diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
> --- a/tests/test-histedit-fold.t
> +++ b/tests/test-histedit-fold.t
> @@ -266,3 +266,37 @@
>    +6
>    $ cd ..
>
> +
> +Folding with initial rename (issue3729)
> +---------------------------------------
> +
> +  $ hg init fold-rename
> +  $ cd fold-rename
> +  $ echo a > a.txt
> +  $ hg add a.txt
> +  $ hg commit -m a
> +  $ hg rename a.txt b.txt
> +  $ hg commit -m rename
> +  $ echo b >> b.txt
> +  $ hg commit -m b
> +
> +  $ hg logt --follow b.txt
> +  2:e0371e0426bc b
> +  1:1c4f440a8085 rename
> +  0:6c795aa153cb a
> +
> +  $ hg histedit 1c4f440a8085 --commands - 2>&1 << EOF | fixbundle
> +  > pick 1c4f440a8085 rename
> +  > fold e0371e0426bc b
> +  > EOF
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  reverting b.txt
> +  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +  $ hg logt --follow b.txt
> +  1:cf858d235c76 rename
> +  0:6c795aa153cb a
> +
> +  $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -247,7 +247,7 @@ 
         files.update(ctx.files())
 
     # Recompute copies (avoid recording a -> b -> a)
-    copied = copies.pathcopies(first, last)
+    copied = copies.pathcopies(base, last)
 
     # prune files which were reverted by the updates
     def samefile(f):
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -266,3 +266,37 @@ 
   +6
   $ cd ..
 
+
+Folding with initial rename (issue3729)
+---------------------------------------
+
+  $ hg init fold-rename
+  $ cd fold-rename
+  $ echo a > a.txt
+  $ hg add a.txt
+  $ hg commit -m a
+  $ hg rename a.txt b.txt
+  $ hg commit -m rename
+  $ echo b >> b.txt
+  $ hg commit -m b
+
+  $ hg logt --follow b.txt
+  2:e0371e0426bc b
+  1:1c4f440a8085 rename
+  0:6c795aa153cb a
+
+  $ hg histedit 1c4f440a8085 --commands - 2>&1 << EOF | fixbundle
+  > pick 1c4f440a8085 rename
+  > fold e0371e0426bc b
+  > EOF
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  reverting b.txt
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg logt --follow b.txt
+  1:cf858d235c76 rename
+  0:6c795aa153cb a
+
+  $ cd ..