D3693: shelve: directly handle the initial parent alignment
lothiraldan (Boris Feld)
phabricator at mercurial-scm.org
Mon Jul 9 20:34:43 UTC 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc829749e7639: shelve: directly handle the initial parent alignment (authored by lothiraldan, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D3693?vs=9408&id=9483
REVISION DETAIL
https://phab.mercurial-scm.org/D3693
AFFECTED FILES
hgext/shelve.py
tests/test-copytrace-heuristics.t
tests/test-shelve.t
CHANGE DETAILS
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -213,7 +213,6 @@
unshelving change 'default-01'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 4:32c69314e062 "changes to: [mq]: second.patch" (tip)
merging a/a
$ hg revert --all -q
@@ -335,7 +334,6 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 5:32c69314e062 "changes to: [mq]: second.patch" (tip)
merging a/a
warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -529,7 +527,6 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 6:2f694dd83a13 "changes to: second" (tip)
merging a/a
$ hg parents -q
4:33f7f61e6c5e
@@ -552,9 +549,8 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 6:2f694dd83a13 "changes to: second" (tip)
merging a/a
- note: rebase of 6:2f694dd83a13 created no changes to commit
+ note: unshelved changes already existed in the working copy
$ hg parents -q
4:33f7f61e6c5e
$ hg shelve -l
@@ -643,7 +639,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 4:82a0d7d6ba61 "changes to: xyz" (tip)
$ hg status
M z
@@ -670,7 +665,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 3:958bcbd1776e "changes to: c" (tip)
$ hg status
A d
@@ -684,7 +678,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 3:013284d9655e "changes to: b" (tip)
$ hg status
A d
@@ -786,7 +779,6 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 5:81152db69da7 "changes to: commit stuff" (tip)
merging f
warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -825,7 +817,6 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 5:81152db69da7 "changes to: commit stuff" (tip)
$ hg st
M a
A f
@@ -841,7 +832,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 5:81152db69da7 "changes to: commit stuff" (tip)
merging f
warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -883,7 +873,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 5:e42a7da90865 "changes to: second" (tip)
merging a/a
warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -993,7 +982,6 @@
unshelving change 'test'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 6:96a1354f65f6 "changes to: create conflict" (tip)
merging a/a
$ hg bookmark
* test 4:33f7f61e6c5e
@@ -1170,13 +1158,12 @@
$ hg unshelve --keep default
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 7:206bf5d4f922 "changes to: create conflict" (tip)
==== preupdate:
VISIBLE 6:66b86db80ee4
ACTUAL 5:703117a2acfb
====
==== preupdate:
- VISIBLE 8:a0e04704317e
+ VISIBLE 8:92fdbb7b4de7
ACTUAL 5:703117a2acfb
====
==== preupdate:
@@ -1215,7 +1202,6 @@
$ hg unshelve --keep default
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 7:206bf5d4f922 "changes to: create conflict" (tip)
==== update:
VISIBLE 6:66b86db80ee4
VISIBLE 7:206bf5d4f922
@@ -1355,7 +1341,6 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 1:098df96e7410 "(changes in empty repository)" (tip)
merging unknown
$ hg status
A unknown
@@ -1376,7 +1361,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 1:098df96e7410 "(changes in empty repository)" (tip)
merging unknown
$ hg status
M unknown
@@ -1509,7 +1493,6 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 2:425c97ef07f3 "changes to: a" (tip)
merging a
warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -1544,7 +1527,6 @@
$ hg unshelve
unshelving change 'test'
rebasing shelved changes
- rebasing 2:357525f34729 "changes to: test-commit" (tip)
$ hg status
A b
$ hg branch
@@ -1585,7 +1567,6 @@
unshelving change 'default'
temporarily committing pending changes (restore with 'hg unshelve --abort')
rebasing shelved changes
- rebasing 2:425c97ef07f3 "changes to: a" (tip)
merging a
warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -1658,7 +1639,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 1:396ea74229f9 "(changes in empty repository)" (tip)
merging file
warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -1697,7 +1677,6 @@
$ hg unshelve --keep
unshelving change 'default'
rebasing shelved changes
- rebasing 2:3fbe6fbb0bef "changes to: 1" (tip)
merging file
warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
@@ -1755,7 +1734,6 @@
$ hg unshelve
unshelving change 'ashelve'
rebasing shelved changes
- rebasing 2:003d2d94241c "changes to: root" (tip)
merging a
warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
diff --git a/tests/test-copytrace-heuristics.t b/tests/test-copytrace-heuristics.t
--- a/tests/test-copytrace-heuristics.t
+++ b/tests/test-copytrace-heuristics.t
@@ -583,7 +583,6 @@
$ hg unshelve
unshelving change 'default'
rebasing shelved changes
- rebasing 2:45f63161acea "changes to: initial" (tip)
merging b and a to b
$ ls
b
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -686,6 +686,10 @@
shelvectx = repo[state.parents[1]]
pendingctx = state.pendingctx
+ with repo.dirstate.parentchange():
+ repo.setparents(state.pendingctx.node(), nodemod.nullid)
+ repo.dirstate.write(repo.currenttransaction())
+
overrides = {('phases', 'new-commit'): phases.secret}
with repo.ui.configoverride(overrides, 'unshelve'):
with repo.dirstate.parentchange():
@@ -761,33 +765,46 @@
if tmpwctx.node() == shelvectx.parents()[0].node():
return shelvectx
- ui.status(_('rebasing shelved changes\n'))
- try:
- rebase.rebase(ui, repo, **{
- r'rev': [shelvectx.rev()],
- r'dest': "%d" % tmpwctx.rev(),
- r'keep': True,
- r'tool': opts.get('tool', ''),
- })
- except error.InterventionRequired:
- tr.close()
+ overrides = {
+ ('ui', 'forcemerge'): opts.get('tool', ''),
+ ('phases', 'new-commit'): phases.secret,
+ }
+ with repo.ui.configoverride(overrides, 'unshelve'):
+ ui.status(_('rebasing shelved changes\n'))
+ stats = merge.graft(repo, shelvectx, shelvectx.p1(),
+ labels=['dest', 'source'],
+ keepconflictparent=True)
+ if stats.unresolvedcount:
+ tr.close()
+
+ nodestoremove = [repo.changelog.node(rev)
+ for rev in xrange(oldtiprev, len(repo))]
+ shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
+ branchtorestore, opts.get('keep'), activebookmark)
+ raise error.InterventionRequired(
+ _("unresolved conflicts (see 'hg resolve', then "
+ "'hg unshelve --continue')"))
- nodestoremove = [repo.changelog.node(rev)
- for rev in xrange(oldtiprev, len(repo))]
- shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
- branchtorestore, opts.get('keep'), activebookmark)
+ with repo.dirstate.parentchange():
+ repo.setparents(tmpwctx.node(), nodemod.nullid)
+ newnode = repo.commit(text=shelvectx.description(),
+ extra=shelvectx.extra(),
+ user=shelvectx.user(),
+ date=shelvectx.date())
- repo.vfs.rename('rebasestate', 'unshelverebasestate')
- raise error.InterventionRequired(
- _("unresolved conflicts (see 'hg resolve', then "
- "'hg unshelve --continue')"))
+ if newnode is None:
+ # If it ended up being a no-op commit, then the normal
+ # merge state clean-up path doesn't happen, so do it
+ # here. Fix issue5494
+ merge.mergestate.clean(repo)
+ shelvectx = tmpwctx
+ msg = _('note: unshelved changes already existed '
+ 'in the working copy\n')
+ ui.status(msg)
+ else:
+ shelvectx = repo[newnode]
+ hg.updaterepo(repo, tmpwctx.node(), False)
- # refresh ctx after rebase completes
- shelvectx = repo['tip']
-
- if tmpwctx not in shelvectx.parents():
- # rebase was a no-op, so it produced no child commit
- shelvectx = tmpwctx
return shelvectx
def _forgetunknownfiles(repo, shelvectx, addedbefore):
To: lothiraldan, #hg-reviewers, pulkit, durin42
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list