Behavior of merging when MQ patches are involved

Mark Tolonen metolone+gmane at gmail.com
Thu Jul 29 12:24:08 UTC 2010


Mercurial with the MQ extension enabled allows merges when a patch is 
involved, and that merge can even be committed in some cases.  Should a 
merge be allowed when either branch contains a patch as parent/ancestor? 
Below is an example (Windows).  It creates two branch heads where one is a 
patch and the other is not and attempts to merge/commit first with the patch 
rev as the working dir and then with the other non-patch head:

  hg init ex
  cd ex
  echo >file1
  hg add
  hg ci -m file1
  echo >file2
  hg ci -m file2
  hg add
  hg ci -m file2
  hg update 0
  echo >file3
  hg add
  hg qnew file3
  hg merge
  hg ci -m "Merge (local is patch)"
  hg update 1 -C
  hg merge
  hg ci -m "Merge (other is patch)"

Here is the result:

  C:\>hg init ex
  C:\>cd ex
  C:\ex>echo  1>file1
  C:\ex>hg add
  adding file1
  C:\ex>hg ci -m file1
  C:\ex>echo  1>file2
  C:\ex>hg ci -m file2
  nothing changed
  C:\ex>hg add
  adding file2
  C:\ex>hg ci -m file2
  C:\ex>hg update 0
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  C:\ex>echo  1>file3
  C:\ex>hg add
  adding file3
  C:\ex>hg qnew file3
  C:\ex>hg merge
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  C:\ex>hg ci -m "Merge (local is patch)"
  abort: cannot commit over an applied mq patch
  C:\ex>hg update 1 -C
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  C:\ex>hg merge
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  C:\ex>hg ci -m "Merge (other is patch)"

Note that both merges succeed.  The first commit where the working dir 
parent is a patch fails, but the second commit where the working dir parent 
is not a patch succeeds.  This leaves the repository in a state where in 
cannot be pushed, and the patch cannot be popped.  The commit must be 
stripped or rolled back to allow the patch to be popped, or the patch can be 
qfinished.

To me disallowing a merge that involves a patch ancestor would be a good 
place to get an 'abort: cannot merge applied mq patches'.

Agree?  Worth a bug report/patch?

-Mark 





More information about the Mercurial mailing list