hg backout behavior

곽병재 bjkwak at etri.re.kr
Tue Aug 29 07:59:14 UTC 2023


I was following the examples on hg backout command explained in Mercurial: the definitive guide, 2nd edition.
However, the behavior of hg backout is not the same as the examples in the book. I wonder if this is a bug.

* The example I was following:  https://book.mercurial-scm.org/read/undo.html?highlight=backout#dealing-with-committed-changes
* I am on Windows 10 system.
* I am not a software developer, and I am using mercurial to version control my text files.
* Summary of the problem: tried to back out only revision 1, but hg backed out revision 1 and 2.

Please see below for details:


M:\>hg version
Mercurial Distributed SCM (version 6.3.1+hg4.c44f350759c3)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2022 Olivia 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.

M:\>hg init myrepo

M:\>cd myrepo

M:\myrepo>echo first change >> myfile

M:\myrepo>hg add myfile

M:\myrepo>hg commit -m "first change"

M:\myrepo>echo second change >> myfile

M:\myrepo>hg commit -m "second change"

M:\myrepo>echo third change >> myfile

M:\myrepo>hg commit -m "third change"

M:\myrepo>hg status

M:\myrepo>type myfile
first change
second change
third change

M:\myrepo>hg log -G
@  changeset:   2:db8046c8b3a8
|  tag:         tip
|  user:        Byung-Jae Kwak <xxx at xxx.xxx.xxx> on i7-12700K
|  date:        Tue Aug 29 16:34:01 2023 +0900
|  summary:     third change
|
o  changeset:   1:3d815a5c42a8
|  user:        Byung-Jae Kwak <xxx at xxx.xxx.xxx> on i7-12700K
|  date:        Tue Aug 29 16:33:34 2023 +0900
|  summary:     second change
|
o  changeset:   0:5c04fb12dce5
   user:        Byung-Jae Kwak <xxx at xxx.xxx.xxx> on i7-12700K
   date:        Tue Aug 29 16:33:21 2023 +0900
   summary:     first change

M:\myrepo>hg annotate myfile
0: first change
1: second change
2: third change


M:\myrepo>hg backout --merge -m "back out second change" -r 1
reverting myfile
created new head
changeset 3:51a9bdebb761 backs out changeset 1:3d815a5c42a8
merging with changeset 3:51a9bdebb761
merging myfile
warning: conflicts while merging myfile! (edit, then use 'hg resolve --mark')
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon

M:\myrepo>hg resolve -l
U myfile


M:\myrepo>type myfile
first change
<<<<<<< local
second change
third change
=======
>>>>>>> other

-- Byung-Jae


More information about the Mercurial mailing list