hgext/evolve.py
changeset 1361 043e5ca9322f
parent 1357 3bb7a080da4d
child 1364 f00d91365ab9
equal deleted inserted replaced
1360:5c13945b32fc 1361:043e5ca9322f
  1252         newer = obsolete.successorssets(repo, obs.node())
  1252         newer = obsolete.successorssets(repo, obs.node())
  1253     if len(newer) > 1:
  1253     if len(newer) > 1:
  1254         raise util.Abort(_("conflict rewriting. can't choose destination\n"))
  1254         raise util.Abort(_("conflict rewriting. can't choose destination\n"))
  1255     return repo[newer[0][0]].rev()
  1255     return repo[newer[0][0]].rev()
  1256 
  1256 
  1257 def orderrevs(repo, revs):
  1257 def builddependencies(repo, revs):
  1258     """ Compute an ordering to solve instability for the given revs
  1258     """ returns dependency graphs giving an order to solve instability of revs
  1259 
  1259     (see orderrevs for more information on usage) """
  1260     - Takes revs a list of instable revisions
  1260 
  1261 
       
  1262     - Returns the same revisions ordered to solve their instability from the
       
  1263     bottom to the top of the stack that the stabilization process will produce
       
  1264     eventually.
       
  1265 
       
  1266     This ensure the minimal number of stabilization as we can stabilize each
       
  1267     revision on its final, stabilized, destination.
       
  1268     """
       
  1269 
       
  1270     # Step 1: Build the dependency graph
       
  1271     # For each troubled revision we keep track of what instability if any should
  1261     # For each troubled revision we keep track of what instability if any should
  1272     # be resolved in order to resolve it. Example:
  1262     # be resolved in order to resolve it. Example:
  1273     # dependencies = {3: [6], 6:[]}
  1263     # dependencies = {3: [6], 6:[]}
  1274     # Means that: 6 has no dependency, 3 depends on 6 to be solved
  1264     # Means that: 6 has no dependency, 3 depends on 6 to be solved
  1275     dependencies = {}
  1265     dependencies = {}
  1281         for p in repo[r].parents():
  1271         for p in repo[r].parents():
  1282             succ = _singlesuccessor(repo, p)
  1272             succ = _singlesuccessor(repo, p)
  1283             if succ in revs:
  1273             if succ in revs:
  1284                 dependencies[r].add(succ)
  1274                 dependencies[r].add(succ)
  1285                 rdependencies[succ].add(r)
  1275                 rdependencies[succ].add(r)
  1286 
  1276     return dependencies, rdependencies
       
  1277 
       
  1278 def orderrevs(repo, revs):
       
  1279     """ Compute an ordering to solve instability for the given revs
       
  1280 
       
  1281     - Takes revs a list of instable revisions
       
  1282 
       
  1283     - Returns the same revisions ordered to solve their instability from the
       
  1284     bottom to the top of the stack that the stabilization process will produce
       
  1285     eventually.
       
  1286 
       
  1287     This ensure the minimal number of stabilization as we can stabilize each
       
  1288     revision on its final, stabilized, destination.
       
  1289     """
       
  1290     # Step 1: Build the dependency graph
       
  1291     dependencies, rdependencies = builddependencies(repo, revs)
  1287     # Step 2: Build the ordering
  1292     # Step 2: Build the ordering
  1288     # Remove the revisions with no dependency(A) and add them to the ordering.
  1293     # Remove the revisions with no dependency(A) and add them to the ordering.
  1289     # Removing these revisions leads to new revisions with no dependency (the
  1294     # Removing these revisions leads to new revisions with no dependency (the
  1290     # one depending on A) that we can remove from the dependency graph and add
  1295     # one depending on A) that we can remove from the dependency graph and add
  1291     # to the ordering. We progress in a similar fashion until the ordering is
  1296     # to the ordering. We progress in a similar fashion until the ordering is