diff --git a/hgext/mq.py b/hgext/mq.py index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_aGdleHQvbXEucHk=..fba17a64fa4978bfea19222da5e64a18cfddeecd_aGdleHQvbXEucHk= 100644 --- a/hgext/mq.py +++ b/hgext/mq.py @@ -2925,6 +2925,10 @@ Use the --no-backup option to discard the backup bundle once the operation completes. + Strip is not a history-rewriting operation and can be used on + changesets in the public phase. But if the stripped changesets have + been pushed to a remote repository you will likely pull them again. + Return 0 on success. """ backup = 'all' diff --git a/hgext/rebase.py b/hgext/rebase.py index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_aGdleHQvcmViYXNlLnB5..fba17a64fa4978bfea19222da5e64a18cfddeecd_aGdleHQvcmViYXNlLnB5 100644 --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -238,6 +238,9 @@ # Keep track of the current bookmarks in order to reset them later currentbookmarks = repo._bookmarks.copy() + activebookmark = repo._bookmarkcurrent + if activebookmark: + bookmarks.unsetcurrent(repo) sortedstate = sorted(state) total = len(sortedstate) @@ -327,6 +330,11 @@ util.unlinkpath(repo.sjoin('undo')) if skipped: ui.note(_("%d revisions have been skipped\n") % len(skipped)) + + if (activebookmark and + repo['tip'].node() == repo._bookmarks[activebookmark]): + bookmarks.setcurrent(repo, activebookmark) + finally: release(lock, wlock) @@ -476,7 +484,6 @@ def updatebookmarks(repo, nstate, originalbookmarks, **opts): 'Move bookmarks to their correct changesets' - current = repo._bookmarkcurrent for k, v in originalbookmarks.iteritems(): if v in nstate: if nstate[v] != nullmerge: @@ -480,9 +487,8 @@ for k, v in originalbookmarks.iteritems(): if v in nstate: if nstate[v] != nullmerge: - # reset the pointer if the bookmark was moved incorrectly - if k != current: - repo._bookmarks[k] = nstate[v] + # update the bookmarks for revs that have moved + repo._bookmarks[k] = nstate[v] bookmarks.write(repo) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_bWVyY3VyaWFsL2NtZHV0aWwucHk=..fba17a64fa4978bfea19222da5e64a18cfddeecd_bWVyY3VyaWFsL2NtZHV0aWwucHk= 100644 --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1301,7 +1301,11 @@ try: # First, do a regular commit to record all changes in the working # directory (if there are any) - node = commit(ui, repo, commitfunc, pats, opts) + ui.callhooks = False + try: + node = commit(ui, repo, commitfunc, pats, opts) + finally: + ui.callhooks = True ctx = repo[node] # Participating changesets: diff --git a/mercurial/commands.py b/mercurial/commands.py index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_bWVyY3VyaWFsL2NvbW1hbmRzLnB5..fba17a64fa4978bfea19222da5e64a18cfddeecd_bWVyY3VyaWFsL2NvbW1hbmRzLnB5 100644 --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2752,11 +2752,6 @@ ctx.p1().node()) finally: repo.ui.setconfig('ui', 'forcemerge', '') - # drop the second merge parent - repo.setparents(current.node(), nullid) - repo.dirstate.write() - # fix up dirstate for copies and renames - cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) # report any conflicts if stats and stats[3] > 0: # write out state for --continue @@ -2768,6 +2763,12 @@ else: cont = False + # drop the second merge parent + repo.setparents(current.node(), nullid) + repo.dirstate.write() + # fix up dirstate for copies and renames + cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) + # commit source = ctx.extra().get('source') if not source: diff --git a/mercurial/hook.py b/mercurial/hook.py index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_bWVyY3VyaWFsL2hvb2sucHk=..fba17a64fa4978bfea19222da5e64a18cfddeecd_bWVyY3VyaWFsL2hvb2sucHk= 100644 --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -138,6 +138,9 @@ _redirect = state def hook(ui, repo, name, throw=False, **args): + if not ui.callhooks: + return False + r = False oldstdout = -1 diff --git a/mercurial/ui.py b/mercurial/ui.py index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_bWVyY3VyaWFsL3VpLnB5..fba17a64fa4978bfea19222da5e64a18cfddeecd_bWVyY3VyaWFsL3VpLnB5 100644 --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -19,6 +19,7 @@ self._ucfg = config.config() # untrusted self._trustusers = set() self._trustgroups = set() + self.callhooks = True if src: self.fout = src.fout @@ -31,6 +32,7 @@ self._trustusers = src._trustusers.copy() self._trustgroups = src._trustgroups.copy() self.environ = src.environ + self.callhooks = src.callhooks self.fixconfig() else: self.fout = sys.stdout diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_dGVzdHMvdGVzdC1jb21taXQtYW1lbmQudA==..fba17a64fa4978bfea19222da5e64a18cfddeecd_dGVzdHMvdGVzdC1jb21taXQtYW1lbmQudA== 100644 --- a/tests/test-commit-amend.t +++ b/tests/test-commit-amend.t @@ -23,7 +23,10 @@ nothing changed [1] + $ echo '[hooks]' >> $HGRCPATH + $ echo 'pretxncommit.foo = echo "pretxncommit $HG_NODE"; hg id -r $HG_NODE' >> $HGRCPATH + Amending changeset with changes in working dir: $ echo a >> a $ hg ci --amend -m 'amend base1' @@ -26,8 +29,11 @@ Amending changeset with changes in working dir: $ echo a >> a $ hg ci --amend -m 'amend base1' - saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg (glob) + pretxncommit 9cd25b479c51be2f4ed2c38e7abdf7ce67d8e0dc + 9cd25b479c51 tip + saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg + $ echo 'pretxncommit.foo = ' >> $HGRCPATH $ hg diff -c . diff -r ad120869acf0 -r 9cd25b479c51 a --- a/a Thu Jan 01 00:00:00 1970 +0000 diff --git a/tests/test-graft.t b/tests/test-graft.t index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_dGVzdHMvdGVzdC1ncmFmdC50..fba17a64fa4978bfea19222da5e64a18cfddeecd_dGVzdHMvdGVzdC1ncmFmdC50 100644 --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -304,4 +304,57 @@ 14 1:5d205f8b35b6 3 (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8) - $ cd .. +Resolve conflicted graft + $ hg up -q 0 + $ echo b > a + $ hg ci -m 8 + created new head + $ echo a > a + $ hg ci -m 9 + $ hg graft 1 --tool internal:fail + grafting revision 1 + abort: unresolved conflicts, can't continue + (use hg resolve and hg graft --continue) + [255] + $ hg resolve --all + merging a + $ hg graft -c + grafting revision 1 + $ hg export tip --git + # HG changeset patch + # User bar + # Date 0 0 + # Node ID 64ecd9071ce83c6e62f538d8ce7709d53f32ebf7 + # Parent 4bdb9a9d0b84ffee1d30f0dfc7744cade17aa19c + 1 + + diff --git a/a b/a + --- a/a + +++ b/a + @@ -1,1 +1,1 @@ + -a + +b + +Resolve conflicted graft with rename + $ echo c > a + $ hg ci -m 10 + $ hg graft 2 --tool internal:fail + grafting revision 2 + abort: unresolved conflicts, can't continue + (use hg resolve and hg graft --continue) + [255] + $ hg resolve --all + merging a and b to b + $ hg graft -c + grafting revision 2 + $ hg export tip --git + # HG changeset patch + # User test + # Date 0 0 + # Node ID 2e80e1351d6ed50302fe1e05f8bd1d4d412b6e11 + # Parent e5a51ae854a8bbaaf25cc5c6a57ff46042dadbb4 + 2 + + diff --git a/a b/b + rename from a + rename to b diff --git a/tests/test-rebase-bookmarks.t b/tests/test-rebase-bookmarks.t index d5422faf648cc589425cd3b0dbf1f6dbf93036a0_dGVzdHMvdGVzdC1yZWJhc2UtYm9va21hcmtzLnQ=..fba17a64fa4978bfea19222da5e64a18cfddeecd_dGVzdHMvdGVzdC1yZWJhc2UtYm9va21hcmtzLnQ= 100644 --- a/tests/test-rebase-bookmarks.t +++ b/tests/test-rebase-bookmarks.t @@ -36,4 +36,6 @@ adding d created new head + $ hg book W + $ hg tglog @@ -39,5 +41,5 @@ $ hg tglog - @ 3: 'D' bookmarks: + @ 3: 'D' bookmarks: W | | o 2: 'C' bookmarks: Y Z | | @@ -60,7 +62,7 @@ $ hg tglog @ 3: 'C' bookmarks: Y Z | - o 2: 'D' bookmarks: + o 2: 'D' bookmarks: W | | o 1: 'B' bookmarks: X |/ @@ -82,7 +84,28 @@ | o 2: 'B' bookmarks: X | - o 1: 'D' bookmarks: + o 1: 'D' bookmarks: W + | + o 0: 'A' bookmarks: + + +Keep active bookmark on the correct changeset + + $ cd .. + $ hg clone -q a a3 + + $ cd a3 + $ hg up -q X + + $ hg rebase -d W + saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob) + + $ hg tglog + @ 3: 'C' bookmarks: Y Z + | + o 2: 'B' bookmarks: X + | + o 1: 'D' bookmarks: W | o 0: 'A' bookmarks: