[issue2403] Empty commit with dirty .hgsubstate file

Martin Geisler bugs at mercurial.selenic.com
Mon Sep 27 04:52:19 CDT 2010


New submission from Martin Geisler <mg at lazybytes.net>:

The following test script shows a problem where we can make an empty commit
because Mercurial forgot to update th .hgsubstate file.

Create three changesets with outer and inner repos moving in lock-step

  $ hg init
  $ hg init sub
  $ echo 'sub = sub' > .hgsub
  $ hg add .hgsub
  $ echo x0 > x
  $ echo y0 > sub/y
  $ hg add -S
  adding x
  adding sub/y
  $ hg commit -m r0
  committing subrepository sub

  $ echo x1 > x
  $ echo y1 > sub/y
  $ hg commit -m r1
  committing subrepository sub

  $ echo x2 > x
  $ echo y2 > sub/y
  $ hg commit -m r2
  committing subrepository sub

  $ cat x sub/y .hgsubstate
  x2
  y2
  97dc77eda23d16886b839deb0e8ff655b431b9f7 sub

  $ hg -R sub log --template '{rev}: {node|short}\n'
  2: 97dc77eda23d
  1: 8514e0ba703c
  0: a2eda9ba59e6

Now update to an earlier version:

  $ hg update 1
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cat x sub/y .hgsubstate
  x1
  y1
  8514e0ba703cdb0dcc5c92beb6c534ec8e7cb34b sub
  $ hg -R sub id
  8514e0ba703c

Update the subrepository to an even earlier version:

  $ hg -R sub update 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cat x sub/y .hgsubstate
  x1
  y0
  8514e0ba703cdb0dcc5c92beb6c534ec8e7cb34b sub
  $ hg -R sub id
  a2eda9ba59e6

What happens when we update the outer repository?

  $ hg update 2
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cat x sub/y .hgsubstate
  x2
  y2
  8514e0ba703cdb0dcc5c92beb6c534ec8e7cb34b sub
  $ hg -R sub id
  97dc77eda23d tip

The .hgsubstate file still records the old revision, but the subrepo
was updated correctly.

  $ hg summary
  parent: 2:0fc3cdfccbc8 tip
   r2
  branch: default
  commit: 1 modified, 1 subrepos
  update: (current)

  $ hg commit -m 'r3 - empty substate commit!'
  committing subrepository sub

  $ cat x sub/y .hgsubstate
  x2
  y2
  97dc77eda23d16886b839deb0e8ff655b431b9f7 sub
  $ hg -R sub id
  97dc77eda23d tip

  $ hg log
  changeset:   3:9313ee30238c
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     r3 - empty substate commit!
  
  changeset:   2:0fc3cdfccbc8
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     r2
  
  changeset:   1:5d202505eb64
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     r1
  
  changeset:   0:56b51e4cf504
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     r0
  
  $ hg export tip
  # HG changeset patch
  # User test
  # Date 0 0
  # Node ID 9313ee30238c88d124ef38e8f2f3a7daa83618b5
  # Parent  0fc3cdfccbc805c2bb4f2a09a354ff037583bdab
  r3 - empty substate commit!

----------
messages: 13760
nosy: mg, sedlock
priority: bug
status: unread
title: Empty commit with dirty .hgsubstate file

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


More information about the Mercurial-devel mailing list