##// END OF EJS Templates
rebase: ensure rebase revision remains visible (issue4504)...
Pierre-Yves David -
r23970:8a544fb6 stable
parent child Browse files
Show More
@@ -16,7 +16,7 b' http://mercurial.selenic.com/wiki/Rebase'
16
16
17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
18 from mercurial import extensions, patch, scmutil, phases, obsolete, error
18 from mercurial import extensions, patch, scmutil, phases, obsolete, error
19 from mercurial import copies
19 from mercurial import copies, repoview
20 from mercurial.commands import templateopts
20 from mercurial.commands import templateopts
21 from mercurial.node import nullrev, nullid, hex, short
21 from mercurial.node import nullrev, nullid, hex, short
22 from mercurial.lock import release
22 from mercurial.lock import release
@@ -778,6 +778,7 b' def storestatus(repo, originalwd, target'
778
778
779 def clearstatus(repo):
779 def clearstatus(repo):
780 'Remove the status files'
780 'Remove the status files'
781 _clearrebasesetvisibiliy(repo)
781 util.unlinkpath(repo.join("rebasestate"), ignoremissing=True)
782 util.unlinkpath(repo.join("rebasestate"), ignoremissing=True)
782
783
783 def restorestatus(repo):
784 def restorestatus(repo):
@@ -831,6 +832,7 b' def restorestatus(repo):'
831 repo.ui.debug('computed skipped revs: %s\n' %
832 repo.ui.debug('computed skipped revs: %s\n' %
832 (' '.join(str(r) for r in sorted(skipped)) or None))
833 (' '.join(str(r) for r in sorted(skipped)) or None))
833 repo.ui.debug('rebase status resumed\n')
834 repo.ui.debug('rebase status resumed\n')
835 _setrebasesetvisibility(repo, state.keys())
834 return (originalwd, target, state, skipped,
836 return (originalwd, target, state, skipped,
835 collapse, keep, keepbranches, external, activebookmark)
837 collapse, keep, keepbranches, external, activebookmark)
836 except IOError, err:
838 except IOError, err:
@@ -892,6 +894,7 b' def buildstate(repo, dest, rebaseset, co'
892 dest: context
894 dest: context
893 rebaseset: set of rev
895 rebaseset: set of rev
894 '''
896 '''
897 _setrebasesetvisibility(repo, rebaseset)
895
898
896 # This check isn't strictly necessary, since mq detects commits over an
899 # This check isn't strictly necessary, since mq detects commits over an
897 # applied patch. But it prevents messing up the working directory when
900 # applied patch. But it prevents messing up the working directory when
@@ -1044,6 +1047,31 b' def pullrebase(orig, ui, repo, *args, **'
1044 raise util.Abort(_('--tool can only be used with --rebase'))
1047 raise util.Abort(_('--tool can only be used with --rebase'))
1045 orig(ui, repo, *args, **opts)
1048 orig(ui, repo, *args, **opts)
1046
1049
1050 def _setrebasesetvisibility(repo, revs):
1051 """store the currently rebased set on the repo object
1052
1053 This is used by another function to prevent rebased revision to because
1054 hidden (see issue4505)"""
1055 repo = repo.unfiltered()
1056 revs = set(revs)
1057 repo._rebaseset = revs
1058 # invalidate cache if visibility changes
1059 hiddens = repo.filteredrevcache.get('visible', set())
1060 if revs & hiddens:
1061 repo.invalidatevolatilesets()
1062
1063 def _clearrebasesetvisibiliy(repo):
1064 """remove rebaseset data from the repo"""
1065 repo = repo.unfiltered()
1066 if '_rebaseset' in vars(repo):
1067 del repo._rebaseset
1068
1069 def _rebasedvisible(orig, repo):
1070 """ensure rebased revs stay visible (see issue4505)"""
1071 blockers = orig(repo)
1072 blockers.update(getattr(repo, '_rebaseset', ()))
1073 return blockers
1074
1047 def summaryhook(ui, repo):
1075 def summaryhook(ui, repo):
1048 if not os.path.exists(repo.join('rebasestate')):
1076 if not os.path.exists(repo.join('rebasestate')):
1049 return
1077 return
@@ -1062,7 +1090,7 b' def summaryhook(ui, repo):'
1062 (len(state) - numrebased)))
1090 (len(state) - numrebased)))
1063
1091
1064 def uisetup(ui):
1092 def uisetup(ui):
1065 'Replace pull with a decorator to provide --rebase option'
1093 #Replace pull with a decorator to provide --rebase option
1066 entry = extensions.wrapcommand(commands.table, 'pull', pullrebase)
1094 entry = extensions.wrapcommand(commands.table, 'pull', pullrebase)
1067 entry[1].append(('', 'rebase', None,
1095 entry[1].append(('', 'rebase', None,
1068 _("rebase working directory to branch head")))
1096 _("rebase working directory to branch head")))
@@ -1072,3 +1100,6 b' def uisetup(ui):'
1072 cmdutil.unfinishedstates.append(
1100 cmdutil.unfinishedstates.append(
1073 ['rebasestate', False, False, _('rebase in progress'),
1101 ['rebasestate', False, False, _('rebase in progress'),
1074 _("use 'hg rebase --continue' or 'hg rebase --abort'")])
1102 _("use 'hg rebase --continue' or 'hg rebase --abort'")])
1103 # ensure rebased rev are not hidden
1104 extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible)
1105
@@ -498,3 +498,45 b' test on rebase dropping a merge'
498 |/
498 |/
499 o 0:cd010b8cd998 A
499 o 0:cd010b8cd998 A
500
500
501
502 Test hidden changesets in the rebase set (issue4504)
503
504 $ hg up --hidden 9
505 3 files updated, 0 files merged, 1 files removed, 0 files unresolved
506 $ echo J > J
507 $ hg add J
508 $ hg commit -m J
509 $ hg debugobsolete `hg log --rev . -T '{node}'`
510
511 $ hg rebase --rev .~1::. --dest 'max(desc(D))' --traceback
512 rebasing 9:4bde274eefcf "I"
513 rebasing 13:06edfc82198f "J" (tip)
514 $ hg log -G
515 @ 15:5ae8a643467b J
516 |
517 o 14:9ad579b4a5de I
518 |
519 | o 12:acd174b7ab39 I
520 | |
521 | o 11:6c11a6218c97 H
522 | |
523 o | 10:b5313c85b22e D
524 |/
525 | o 8:53a6a128b2b7 M
526 | |\
527 | | x 7:02de42196ebe H
528 | | |
529 o---+ 6:eea13746799a G
530 | | |
531 | | o 5:24b6387c8c8c F
532 | | |
533 o---+ 4:9520eea781bc E
534 / /
535 x | 3:32af7686d403 D
536 | |
537 o | 2:5fddd98957c8 C
538 | |
539 o | 1:42ccdea3bb16 B
540 |/
541 o 0:cd010b8cd998 A
542
General Comments 0
You need to be logged in to leave comments. Login now