hgext/evolve.py
changeset 1470 c3f6e97c71b1
parent 1469 fa1a27009c76
child 1471 4140d680784e
child 1487 ee5391999f2d
equal deleted inserted replaced
1462:5dfb18b98a55 1470:c3f6e97c71b1
  1176         if parents:
  1176         if parents:
  1177             parentsdata += 1
  1177             parentsdata += 1
  1178         # cluster handling
  1178         # cluster handling
  1179         nodes = set(mark[1])
  1179         nodes = set(mark[1])
  1180         nodes.add(mark[0])
  1180         nodes.add(mark[0])
  1181         _updateclustermap(nodes, mark, clustersmap) 
  1181         _updateclustermap(nodes, mark, clustersmap)
  1182         # same with parent data
  1182         # same with parent data
  1183         nodes.update(parents)
  1183         nodes.update(parents)
  1184         _updateclustermap(nodes, mark, pclustersmap) 
  1184         _updateclustermap(nodes, mark, pclustersmap)
  1185 
  1185 
  1186     # freezing the result
  1186     # freezing the result
  1187     for c in clustersmap.values():
  1187     for c in clustersmap.values():
  1188         fc = (frozenset(c[0]), frozenset(c[1]))
  1188         fc = (frozenset(c[0]), frozenset(c[1]))
  1189         for n in fc[0]:
  1189         for n in fc[0]:
  1413             if succ in revs:
  1413             if succ in revs:
  1414                 dependencies[r].add(succ)
  1414                 dependencies[r].add(succ)
  1415                 rdependencies[succ].add(r)
  1415                 rdependencies[succ].add(r)
  1416     return dependencies, rdependencies
  1416     return dependencies, rdependencies
  1417 
  1417 
       
  1418 def _dedupedivergents(repo, revs):
       
  1419     """Dedupe the divergents revs in revs to get one from each group with the
       
  1420     lowest revision numbers
       
  1421     """
       
  1422     repo = repo.unfiltered()
       
  1423     res = set()
       
  1424     # To not reevaluate divergents of the same group once one is encountered
       
  1425     discarded = set()
       
  1426     for rev in revs:
       
  1427         if rev in discarded:
       
  1428             continue
       
  1429         divergent = repo[rev]
       
  1430         base, others = divergentdata(divergent)
       
  1431         othersrevs = [o.rev() for o in others]
       
  1432         res.add(min([divergent.rev()] + othersrevs))
       
  1433         discarded.update(othersrevs)
       
  1434     return res
       
  1435 
  1418 def _selectrevs(repo, allopt, revopt, anyopt, targetcat):
  1436 def _selectrevs(repo, allopt, revopt, anyopt, targetcat):
  1419     """select troubles in repo matching according to given options"""
  1437     """select troubles in repo matching according to given options"""
  1420     revs = set()
  1438     revs = set()
  1421     if allopt or revopt:
  1439     if allopt or revopt:
  1422         revs = repo.revs(targetcat+'()')
  1440         revs = repo.revs(targetcat+'()')
  1423         if revopt:
  1441         if revopt:
  1424             revs = scmutil.revrange(repo, revopt) & revs
  1442             revs = scmutil.revrange(repo, revopt) & revs
  1425         elif not anyopt and targetcat == 'unstable':
  1443         elif not anyopt and targetcat == 'unstable':
  1426             revs = set(_aspiringdescendant(repo, repo.revs('(.::) - obsolete()::')))
  1444             revs = set(_aspiringdescendant(repo, repo.revs('(.::) - obsolete()::')))
       
  1445         if targetcat == 'divergent':
       
  1446             # Pick one divergent per group of divergents
       
  1447             revs = _dedupedivergents(repo, revs)
  1427     elif anyopt:
  1448     elif anyopt:
  1428         revs = repo.revs('first(%s())' % (targetcat))
  1449         revs = repo.revs('first(%s())' % (targetcat))
  1429     elif targetcat == 'unstable':
  1450     elif targetcat == 'unstable':
  1430         revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::')))
  1451         revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::')))
  1431         if 1 < len(revs):
  1452         if 1 < len(revs):
  1847                  "| You should contact your local evolution Guru for help.\n"
  1868                  "| You should contact your local evolution Guru for help.\n"
  1848                  % (divergent, othersstr))
  1869                  % (divergent, othersstr))
  1849         ui.write_err(msg)
  1870         ui.write_err(msg)
  1850         return 2
  1871         return 2
  1851     other = others[0]
  1872     other = others[0]
  1852     if divergent.phase() <= phases.public:
       
  1853         msg = _("skipping %s: we can't resolve divergence from the public side\n") % divergent
       
  1854         ui.write_err(msg)
       
  1855         hint = _("(%s is public, try from %s)\n" % (divergent, other))
       
  1856         ui.write_err(hint)
       
  1857         return 2
       
  1858     if len(other.parents()) > 1:
  1873     if len(other.parents()) > 1:
  1859         msg = _("skipping %s: divergent changeset can't be a merge (yet)\n" % divergent)
  1874         msg = _("skipping %s: divergent changeset can't be a merge (yet)\n" % divergent)
  1860         ui.write_err(msg)
  1875         ui.write_err(msg)
  1861         hint = _("You have to fallback to solving this by hand...\n"
  1876         hint = _("You have to fallback to solving this by hand...\n"
  1862                  "| This probably means redoing the merge and using \n"
  1877                  "| This probably means redoing the merge and using \n"
  2251         if bookmark:
  2266         if bookmark:
  2252             _deletebookmark(ui, marks, bookmark)
  2267             _deletebookmark(ui, marks, bookmark)
  2253 
  2268 
  2254         # create markers
  2269         # create markers
  2255         obsolete.createmarkers(repo, relations, metadata=metadata)
  2270         obsolete.createmarkers(repo, relations, metadata=metadata)
  2256         
  2271 
  2257         # informs that changeset have been pruned
  2272         # informs that changeset have been pruned
  2258         ui.status(_('%i changesets pruned\n') % len(precs))
  2273         ui.status(_('%i changesets pruned\n') % len(precs))
  2259 
  2274 
  2260         for ctx in repo.unfiltered().set('bookmark() and %ld', precs):
  2275         for ctx in repo.unfiltered().set('bookmark() and %ld', precs):
  2261             # used to be:
  2276             # used to be:
  2607     ] + commitopts + commitopts2,
  2622     ] + commitopts + commitopts2,
  2608     _('hg fold [OPTION]... [-r] REV'))
  2623     _('hg fold [OPTION]... [-r] REV'))
  2609 def fold(ui, repo, *revs, **opts):
  2624 def fold(ui, repo, *revs, **opts):
  2610     """fold multiple revisions into a single one
  2625     """fold multiple revisions into a single one
  2611 
  2626 
  2612     Folds a set of revisions with the parent of the working directory.
  2627     By default, folds all the revisions linearly between the given revisions
  2613     All revisions linearly between the given revisions and the parent
  2628     and the parent of the working directory.
  2614     of the working directory will also be folded.
       
  2615 
  2629 
  2616     Use --exact for folding only the specified revisions while ignoring the
  2630     Use --exact for folding only the specified revisions while ignoring the
  2617     parent of the working directory. In this case, the given revisions must
  2631     parent of the working directory. In this case, the given revisions must
  2618     form a linear unbroken chain.
  2632     form a linear unbroken chain.
  2619 
  2633 
  2630          hg fold 'draft()'
  2644          hg fold 'draft()'
  2631 
  2645 
  2632        See :hg:`help phases` for more about draft revisions and
  2646        See :hg:`help phases` for more about draft revisions and
  2633        :hg:`help revsets` for more about the `draft()` keyword
  2647        :hg:`help revsets` for more about the `draft()` keyword
  2634 
  2648 
  2635      - Fold revisions 3, 4, 5, and 6 with the working directory parent::
  2649      - Fold revisions between 3 and 6 with the working directory parent::
  2636 
  2650 
  2637          hg fold 3:6
  2651          hg fold 3::6
       
  2652 
       
  2653      - Fold revisions 3 and 4:
       
  2654 
       
  2655         hg fold "3 + 4" --exact
  2638 
  2656 
  2639      - Only fold revisions linearly between foo and @::
  2657      - Only fold revisions linearly between foo and @::
  2640 
  2658 
  2641          hg fold foo::@ --exact
  2659          hg fold foo::@ --exact
  2642     """
  2660     """
  3331     '')
  3349     '')
  3332 def debugobsconvert(ui, repo, new_format):
  3350 def debugobsconvert(ui, repo, new_format):
  3333     if new_format == repo.obsstore._version:
  3351     if new_format == repo.obsstore._version:
  3334         msg = _('New format is the same as the old format, not upgrading!')
  3352         msg = _('New format is the same as the old format, not upgrading!')
  3335         raise util.Abort(msg)
  3353         raise util.Abort(msg)
  3336     f = repo.sopener('obsstore', 'wb', atomictemp=True)
  3354     f = repo.svfs('obsstore', 'wb', atomictemp=True)
  3337     origmarkers = repo.obsstore._all
  3355     origmarkers = repo.obsstore._all
  3338     known = set()
  3356     known = set()
  3339     markers = []
  3357     markers = []
  3340     for m in origmarkers:
  3358     for m in origmarkers:
  3341         # filter out invalid markers
  3359         # filter out invalid markers