Bug 3340 - hg convert loses last commit
Summary: hg convert loses last commit
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: convert (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-28 01:14 UTC by Carl-Johan Kjellander
Modified: 2012-09-30 16:19 UTC (History)
5 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 Carl-Johan Kjellander 2012-03-28 01:14 UTC
I have hit an issue while trying to convert a repo and move the files within
it and change default to another branch name. In order to reproduce the bug
do the following.

hg init snygga
cd snygga/
touch .hgignore
hg add .hgignore
hg commit -m 'initial commit'
hg branch moose
hg commit -m 'branch monkey'
touch monkey
hg add monkey
hg commit -m 'me and my monkey'
hg up default
hg merge moose
hg commit -m 'merge monkey'
cd ..
echo "rename . apps/foo" >filemap
echo "default foo" >branchmap
hg convert --filemap filemap --branchmap branchmap snygga skor
cd skor
hg up


Now you would think that the log in "skor" would be the same as in "snygga",
but it is not.

"snygga"
$ hg log
changeset:   3:651ae2306da3
tag:         tip
parent:      0:e8a272c71b1e
parent:      2:30fdf9f41080
user:        Carl-Johan Kjellander <carl-johan@campanja.com>
date:        Wed Mar 28 08:57:10 2012 +0200
summary:     merge monkey

changeset:   2:30fdf9f41080
branch:      moose
user:        Carl-Johan Kjellander <carl-johan@campanja.com>
date:        Wed Mar 28 08:56:36 2012 +0200
summary:     me and my monkey

changeset:   1:c2dc0beae26e
branch:      moose
user:        Carl-Johan Kjellander <carl-johan@campanja.com>
date:        Wed Mar 28 08:55:18 2012 +0200
summary:     make branch

changeset:   0:e8a272c71b1e
user:        Carl-Johan Kjellander <carl-johan@campanja.com>
date:        Wed Mar 28 08:54:17 2012 +0200
summary:     initial commit

"skor"
changeset:   1:4352fafe06e6
branch:      moose
tag:         tip
user:        Carl-Johan Kjellander <carl-johan@campanja.com>
date:        Wed Mar 28 08:56:36 2012 +0200
summary:     me and my monkey

changeset:   0:0d01bb88b266
branch:      foo
user:        Carl-Johan Kjellander <carl-johan@campanja.com>
date:        Wed Mar 28 08:54:17 2012 +0200
summary:     initial commit

All empty commits like the branching and especially the merge is missing.

$ hg --version
Mercurial Distributed SCM (version 1.9.1)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2011 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

On ubuntu 11.10.
Comment 1 kiilerix 2012-03-28 04:10 UTC
As a test:

  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > convert =
  > graphlog =
  > EOF
  $ hg init r1
  $ cd r1
  $ touch f1
  $ hg add f1
  $ hg commit -m0
  $ hg branch -q b1
  $ hg commit -m1
  $ touch f2
  $ hg add f2
  $ hg commit -m2
  $ hg up default
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg merge b1
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg commit -m3

The previous merge was completely linear except for the branch jumping.
Now try to merge the same branch but make the default branch diverge first.

  $ hg up -r0
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ echo f1 > f1
  $ hg ci -m4
  created new head
  $ hg merge b1
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg commit -m5
  $ cd ..
  $ touch filemap
  $ hg convert --filemap filemap r1 r2
  initializing destination r2 repository
  scanning source...
  sorting...
  converting...
  5 0
  4 1
  3 2
  2 3
  1 4
  0 5

  $ hg glog -R r1
  @    changeset:   5:df1f1180ba7d
  |\   tag:         tip
  | |  parent:      4:bd981c70bdb0
  | |  parent:      2:87849517711f
  | |  user:        test
  | |  date:        Thu Jan 01 00:00:00 1970 +0000
  | |  summary:     5
  | |
  | o  changeset:   4:bd981c70bdb0
  | |  parent:      0:08bfba8bb809
  | |  user:        test
  | |  date:        Thu Jan 01 00:00:00 1970 +0000
  | |  summary:     4
  | |
  +---o  changeset:   3:dd1e3b271d62
  | |/   parent:      0:08bfba8bb809
  | |    parent:      2:87849517711f
  | |    user:        test
  | |    date:        Thu Jan 01 00:00:00 1970 +0000
  | |    summary:     3
  | |
  o |  changeset:   2:87849517711f
  | |  branch:      b1
  | |  user:        test
  | |  date:        Thu Jan 01 00:00:00 1970 +0000
  | |  summary:     2
  | |
  o |  changeset:   1:defc5d43eadb
  |/   branch:      b1
  |    user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     1
  |
  o  changeset:   0:08bfba8bb809
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     summary:     0

  $ hg glog -R r2
  o    changeset:   3:2841febefff0
  |\   tag:         tip
  | |  parent:      2:bd981c70bdb0
  | |  parent:      1:10770b18f3a7
  | |  user:        test
  | |  date:        Thu Jan 01 00:00:00 1970 +0000
  | |  summary:     5
  | |
  | o  changeset:   2:bd981c70bdb0
  | |  parent:      0:08bfba8bb809
  | |  user:        test
  | |  date:        Thu Jan 01 00:00:00 1970 +0000
  | |  summary:     4
  | |
  o |  changeset:   1:10770b18f3a7
  |/   branch:      b1
  |    user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     2
  |
  o  changeset:   0:08bfba8bb809
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     summary:     0


This is closely related to issue2538 - perhaps a duplicate, perhaps intended
behaviour.

The core issue is this: You 'obviously' want converted changesets to be
filtered out if the filemap filters out all the files modified by the
changeset. In other words: If a changeset after the filemap filtering
doesn't modify any files it will be skipped.

Mercurial do normally not allow changesets that doesn't modify any files,
but named branches is an inconsistent exception to that.

Convert has a hard time both filtering out changesets that are noop because
of filemap but at the same time preserve noop 'fast forward' merges that do
branch juggling that you care about.

Have you seen any real problems because of this, or is it just slightly
confusing and surprising?
Comment 2 Carl-Johan Kjellander 2012-03-28 04:57 UTC
Yes, real problems. We are trying to merge our 30 repos into one big one to
change how we do deployment and testing. This issue is in our way. We can't
loose random branches just because the merge doesn't touch any files.

It is more than confusing that the converted tree isn't the same as before
the conversion. It makes this feature totally useless.
Comment 3 Bugzilla 2012-05-12 09:29 UTC

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

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

Bug Status was UNCONFIRMED but everconfirmed was true
   Setting status to CONFIRMED

Comment 4 Patrick Mézard 2012-05-27 10:19 UTC
@Carl-Johan Kjellander: can you elaborate on why this is a problem in practice?

My understanding of the issue is convert + filemap discards empty revisions and therefore empty branches. While I recognize this behaviour is suboptimal, I would like to understand the actual issue you are facing? Why do you need these empty branches?
Comment 5 Patrick Mézard 2012-05-27 14:02 UTC
Patch submitted here:

  http://selenic.com/pipermail/mercurial-devel/2012-May/040627.html

The issue is not easy to deal with, I could have missed cases, please test it.
Comment 6 Carl-Johan Kjellander 2012-05-28 02:06 UTC
(In reply to comment #4)

This was the smallest example I could find, but you really want empty merges into default/master. Standard practice is to merge default/master into your feature branch and solve all conflicts, then merge it back into default/master.

Those merges back into default/master were missed by 'hg convert' since they were totally empty, and they were kinda very important since that were the features going live.

We side stepped the whole bug by converting all our companies repos to git and throwing out hg.
Comment 7 Matt Mackall 2012-07-29 15:07 UTC
Fixed in stable by:

5146de7bce96 convert: keep branch switching merges with ancestors
Comment 8 Matt Mackall 2012-09-30 16:19 UTC
Mass close old bugs in testing.