hgext/evolve.py
branchstable
changeset 949 2b2a4ab0eb68
parent 948 b2b3d5aa16bc
child 950 cf4dcf49d998
child 1399 9ff6d9240f16
equal deleted inserted replaced
948:b2b3d5aa16bc 949:2b2a4ab0eb68
   350     if ui.config('alias', 'pdiff', None) is None:
   350     if ui.config('alias', 'pdiff', None) is None:
   351         ui.setconfig('alias', 'pdiff', 'diff --rev .^')
   351         ui.setconfig('alias', 'pdiff', 'diff --rev .^')
   352     if ui.config('alias', 'olog', None) is None:
   352     if ui.config('alias', 'olog', None) is None:
   353         ui.setconfig('alias', 'olog', "log -r 'precursors(.)' --hidden")
   353         ui.setconfig('alias', 'olog', "log -r 'precursors(.)' --hidden")
   354     if ui.config('alias', 'odiff', None) is None:
   354     if ui.config('alias', 'odiff', None) is None:
   355         ui.setconfig('alias', 'odiff', "diff --hidden --rev 'limit(precursors(.),1)' --rev .")
   355         ui.setconfig('alias', 'odiff',
       
   356             "diff --hidden --rev 'limit(precursors(.),1)' --rev .")
   356     if ui.config('alias', 'grab', None) is None:
   357     if ui.config('alias', 'grab', None) is None:
   357         ui.setconfig('alias', 'grab', "! $HG rebase --dest . --rev $@ && $HG up tip")
   358         ui.setconfig('alias', 'grab',
       
   359             "! $HG rebase --dest . --rev $@ && $HG up tip")
   358 
   360 
   359 
   361 
   360 ### Troubled revset symbol
   362 ### Troubled revset symbol
   361 
   363 
   362 @eh.revset('troubled')
   364 @eh.revset('troubled')
   558     priordivergents = len(set(getrevs(repo, 'divergent')) - filtered)
   560     priordivergents = len(set(getrevs(repo, 'divergent')) - filtered)
   559     ret = orig(ui, repo, *args, **kwargs)
   561     ret = orig(ui, repo, *args, **kwargs)
   560     # workaround phase stupidity
   562     # workaround phase stupidity
   561     #phases._filterunknown(ui, repo.changelog, repo._phasecache.phaseroots)
   563     #phases._filterunknown(ui, repo.changelog, repo._phasecache.phaseroots)
   562     filtered = repo.changelog.filteredrevs
   564     filtered = repo.changelog.filteredrevs
   563     newunstables = len(set(getrevs(repo, 'unstable')) - filtered) - priorunstables
   565     newunstables = \
   564     newbumpeds = len(set(getrevs(repo, 'bumped')) - filtered) - priorbumpeds
   566         len(set(getrevs(repo, 'unstable')) - filtered) - priorunstables
   565     newdivergents = len(set(getrevs(repo, 'divergent')) - filtered) - priordivergents
   567     newbumpeds = \
       
   568         len(set(getrevs(repo, 'bumped')) - filtered) - priorbumpeds
       
   569     newdivergents = \
       
   570         len(set(getrevs(repo, 'divergent')) - filtered) - priordivergents
   566     if newunstables > 0:
   571     if newunstables > 0:
   567         ui.warn(_('%i new unstable changesets\n') % newunstables)
   572         ui.warn(_('%i new unstable changesets\n') % newunstables)
   568     if newbumpeds > 0:
   573     if newbumpeds > 0:
   569         ui.warn(_('%i new bumped changesets\n') % newbumpeds)
   574         ui.warn(_('%i new bumped changesets\n') % newbumpeds)
   570     if newdivergents > 0:
   575     if newdivergents > 0:
   741     try:
   746     try:
   742         if orig.rev() == dest.rev():
   747         if orig.rev() == dest.rev():
   743             raise util.Abort(_('tried to relocate a node on top of itself'),
   748             raise util.Abort(_('tried to relocate a node on top of itself'),
   744                              hint=_("This shouldn't happen. If you still "
   749                              hint=_("This shouldn't happen. If you still "
   745                                     "need to move changesets, please do so "
   750                                     "need to move changesets, please do so "
   746                                     "manually with nothing to rebase - working directory parent is also destination"))
   751                                     "manually with nothing to rebase - working "
       
   752                                     "directory parent is also destination"))
   747 
   753 
   748         rebase = extensions.find('rebase')
   754         rebase = extensions.find('rebase')
   749         # dummy state to trick rebase node
   755         # dummy state to trick rebase node
   750         if not orig.p2().rev() == node.nullrev:
   756         if not orig.p2().rev() == node.nullrev:
   751             raise util.Abort(
   757             raise util.Abort(
   855                     tr.release()
   861                     tr.release()
   856         return ret
   862         return ret
   857 
   863 
   858 
   864 
   859 @command('^evolve|stabilize|solve',
   865 @command('^evolve|stabilize|solve',
   860     [('n', 'dry-run', False, 'do not perform actions, just print what would be done'),
   866     [('n', 'dry-run', False,
       
   867         'do not perform actions, just print what would be done'),
   861     ('A', 'any', False, 'evolve any troubled changeset'),
   868     ('A', 'any', False, 'evolve any troubled changeset'),
   862     ('a', 'all', False, 'evolve all troubled changesets'),
   869     ('a', 'all', False, 'evolve all troubled changesets'),
   863     ('c', 'continue', False, 'continue an interrupted evolution'), ],
   870     ('c', 'continue', False, 'continue an interrupted evolution'), ],
   864     _('[OPTIONS]...'))
   871     _('[OPTIONS]...'))
   865 def evolve(ui, repo, **opts):
   872 def evolve(ui, repo, **opts):
   900         return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
   907         return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
   901 
   908 
   902     tr = _picknexttroubled(ui, repo, anyopt or allopt)
   909     tr = _picknexttroubled(ui, repo, anyopt or allopt)
   903     if tr is None:
   910     if tr is None:
   904         if repo['.'].obsolete():
   911         if repo['.'].obsolete():
   905             displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
   912             displayer = cmdutil.show_changeset(
       
   913                 ui, repo, {'template': shorttemplate})
   906             successors = set()
   914             successors = set()
   907 
   915 
   908             for successorsset in obsolete.successorssets(repo, repo['.'].node()):
   916             for successorsset in obsolete.successorssets(repo, repo['.'].node()):
   909                 for nodeid in successorsset:
   917                 for nodeid in successorsset:
   910                     successors.add(repo[nodeid])
   918                     successors.add(repo[nodeid])
  1072         try:
  1080         try:
  1073             relocate(repo, orig, target)
  1081             relocate(repo, orig, target)
  1074         except MergeFailure:
  1082         except MergeFailure:
  1075             repo.opener.write('graftstate', orig.hex() + '\n')
  1083             repo.opener.write('graftstate', orig.hex() + '\n')
  1076             repo.ui.write_err(_('evolve failed!\n'))
  1084             repo.ui.write_err(_('evolve failed!\n'))
  1077             repo.ui.write_err(_('fix conflict and run "hg evolve --continue"\n'))
  1085             repo.ui.write_err(
       
  1086                 _('fix conflict and run "hg evolve --continue"\n'))
  1078             raise
  1087             raise
  1079         finally:
  1088         finally:
  1080             lock.release()
  1089             lock.release()
  1081 
  1090 
  1082 def _solvebumped(ui, repo, bumped, dryrun=False, progresscb=None):
  1091 def _solvebumped(ui, repo, bumped, dryrun=False, progresscb=None):
  1116             # Basic check for common parent. Far too complicated and fragile
  1125             # Basic check for common parent. Far too complicated and fragile
  1117             tr = repo.transaction('bumped-stabilize')
  1126             tr = repo.transaction('bumped-stabilize')
  1118             try:
  1127             try:
  1119                 if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)):
  1128                 if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)):
  1120                     # Need to rebase the changeset at the right place
  1129                     # Need to rebase the changeset at the right place
  1121                     repo.ui.status(_('rebasing to destination parent: %s\n') % prec.p1())
  1130                     repo.ui.status(
       
  1131                         _('rebasing to destination parent: %s\n') % prec.p1())
  1122                     try:
  1132                     try:
  1123                         tmpid = relocate(repo, bumped, prec.p1())
  1133                         tmpid = relocate(repo, bumped, prec.p1())
  1124                         if tmpid is not None:
  1134                         if tmpid is not None:
  1125                             tmpctx = repo[tmpid]
  1135                             tmpctx = repo[tmpid]
  1126                             createmarkers(repo, [(bumped, (tmpctx,))])
  1136                             createmarkers(repo, [(bumped, (tmpctx,))])
  1127                     except MergeFailure:
  1137                     except MergeFailure:
  1128                         repo.opener.write('graftstate', bumped.hex() + '\n')
  1138                         repo.opener.write('graftstate', bumped.hex() + '\n')
  1129                         repo.ui.write_err(_('evolution failed!\n'))
  1139                         repo.ui.write_err(_('evolution failed!\n'))
  1130                         repo.ui.write_err(_('fix conflict and run "hg evolve --continue"\n'))
  1140                         repo.ui.write_err(
       
  1141                             _('fix conflict and run "hg evolve --continue"\n'))
  1131                         raise
  1142                         raise
  1132                 # Create the new commit context
  1143                 # Create the new commit context
  1133                 repo.ui.status(_('computing new diff\n'))
  1144                 repo.ui.status(_('computing new diff\n'))
  1134                 files = set()
  1145                 files = set()
  1135                 copied = copies.pathcopies(prec, bumped)
  1146                 copied = copies.pathcopies(prec, bumped)
  1199         raise util.Abort("we do not handle divergence with split yet",
  1210         raise util.Abort("we do not handle divergence with split yet",
  1200                          hint='')
  1211                          hint='')
  1201     other = others[0]
  1212     other = others[0]
  1202     if divergent.phase() <= phases.public:
  1213     if divergent.phase() <= phases.public:
  1203         raise util.Abort("we can't resolve this conflict from the public side",
  1214         raise util.Abort("we can't resolve this conflict from the public side",
  1204                          hint="%s is public, try from %s" % (divergent, other))
  1215                     hint="%s is public, try from %s" % (divergent, other))
  1205     if len(other.parents()) > 1:
  1216     if len(other.parents()) > 1:
  1206         raise util.Abort("divergent changeset can't be a merge (yet)",
  1217         raise util.Abort("divergent changeset can't be a merge (yet)",
  1207                           hint="You have to fallback to solving this by hand...\n"
  1218                     hint="You have to fallback to solving this by hand...\n"
  1208                                "| This probably means redoing the merge and using "
  1219                          "| This probably means redoing the merge and using "
  1209                                "| `hg prune` to kill older version.")
  1220                          "| `hg prune` to kill older version.")
  1210     if other.p1() not in divergent.parents():
  1221     if other.p1() not in divergent.parents():
  1211         raise util.Abort("parents are not common (not handled yet)",
  1222         raise util.Abort("parents are not common (not handled yet)",
  1212                          hint="| %(d)s, %(o)s are not based on the same changeset."
  1223                     hint="| %(d)s, %(o)s are not based on the same changeset."
  1213                               "| With the current state of its implementation, "
  1224                          "| With the current state of its implementation, "
  1214                               "| evolve does not work in that case.\n"
  1225                          "| evolve does not work in that case.\n"
  1215                               "| rebase one of them next to the other and run "
  1226                          "| rebase one of them next to the other and run "
  1216                               "| this command again.\n"
  1227                          "| this command again.\n"
  1217                               "| - either: hg rebase -dest 'p1(%(d)s)' -r %(o)s"
  1228                          "| - either: hg rebase -dest 'p1(%(d)s)' -r %(o)s"
  1218                               "| - or:     hg rebase -dest 'p1(%(d)s)' -r %(o)s"
  1229                          "| - or:     hg rebase -dest 'p1(%(d)s)' -r %(o)s"
  1219                               % {'d': divergent, 'o': other})
  1230                               % {'d': divergent, 'o': other})
  1220 
  1231 
  1221     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  1232     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
  1222     ui.status(_('merge:'))
  1233     ui.status(_('merge:'))
  1223     if not ui.quiet:
  1234     if not ui.quiet:
  1362         displayer.show(c)
  1373         displayer.show(c)
  1363         return 0
  1374         return 0
  1364     else:
  1375     else:
  1365         for c in children:
  1376         for c in children:
  1366             displayer.show(c)
  1377             displayer.show(c)
  1367         ui.warn(_('multiple non-obsolete children, explicitly update to one\n'))
  1378         ui.warn(_('multiple non-obsolete children, '
       
  1379             'explicitly update to one of them\n'))
  1368         return 1
  1380         return 1
  1369 
  1381 
  1370 def _reachablefrombookmark(repo, revs, mark):
  1382 def _reachablefrombookmark(repo, revs, mark):
  1371     """filter revisions and bookmarks reachable from the given bookmark
  1383     """filter revisions and bookmarks reachable from the given bookmark
  1372     yoinked from mq.py
  1384     yoinked from mq.py
  1475         if not biject and len(sucs) > 1 and len(precs) > 1:
  1487         if not biject and len(sucs) > 1 and len(precs) > 1:
  1476             msg = "Can't use multiple successors for multiple precursors"
  1488             msg = "Can't use multiple successors for multiple precursors"
  1477             raise util.Abort(msg)
  1489             raise util.Abort(msg)
  1478 
  1490 
  1479         if biject and len(sucs) != len(precs):
  1491         if biject and len(sucs) != len(precs):
  1480             msg = "Can't use %d successors for %d precursors" % (len(sucs), len(precs))
  1492             msg = "Can't use %d successors for %d precursors" \
       
  1493                 % (len(sucs), len(precs))
  1481             raise util.Abort(msg)
  1494             raise util.Abort(msg)
  1482 
  1495 
  1483         relations = [(p, sucs) for p in precs]
  1496         relations = [(p, sucs) for p in precs]
  1484         if biject:
  1497         if biject:
  1485             relations = [(p, (s,)) for p, s in zip(precs, sucs)]
  1498             relations = [(p, (s,)) for p, s in zip(precs, sucs)]