Mercurial > evolve
comparison hgext/evolve.py @ 1408:b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
We were previously crashing when encountering them, but we want to be able to
solve the other solvable troubles instead of stopping right there.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Tue, 16 Jun 2015 17:56:23 -0700 |
parents | 552687eb4856 |
children | 3276730e4b32 |
comparison
equal
deleted
inserted
replaced
1407:552687eb4856 | 1408:b3afdc0815d0 |
---|---|
1258 if showprogress: | 1258 if showprogress: |
1259 ui.progress('evolve', None) | 1259 ui.progress('evolve', None) |
1260 if repo['.'] != startnode: | 1260 if repo['.'] != startnode: |
1261 ui.status(_('working directory is now at %s\n') % repo['.']) | 1261 ui.status(_('working directory is now at %s\n') % repo['.']) |
1262 | 1262 |
1263 class MultipleSuccessorsError(RuntimeError): | |
1264 """Exception raised by _singlesuccessor when multiple sucessors sets exists | |
1265 | |
1266 The object contains the list of successorssets in its 'successorssets' | |
1267 attribute to call to easily recover. | |
1268 """ | |
1269 | |
1270 def __init__(self, successorssets): | |
1271 self.successorssets = successorssets | |
1272 | |
1263 def _singlesuccessor(repo, p): | 1273 def _singlesuccessor(repo, p): |
1264 """returns p (as rev) if not obsolete or its unique latest successors | 1274 """returns p (as rev) if not obsolete or its unique latest successors |
1265 | 1275 |
1266 fail if there are no such successor""" | 1276 fail if there are no such successor""" |
1267 | 1277 |
1276 " trying to stabilize on its parent\n" % | 1286 " trying to stabilize on its parent\n" % |
1277 obs) | 1287 obs) |
1278 obs = obs.parents()[0] | 1288 obs = obs.parents()[0] |
1279 newer = obsolete.successorssets(repo, obs.node()) | 1289 newer = obsolete.successorssets(repo, obs.node()) |
1280 if len(newer) > 1: | 1290 if len(newer) > 1: |
1281 raise util.Abort(_("conflict rewriting. can't choose destination\n")) | 1291 raise MultipleSuccessorsError(newer) |
1292 | |
1282 return repo[newer[0][0]].rev() | 1293 return repo[newer[0][0]].rev() |
1283 | 1294 |
1284 def builddependencies(repo, revs): | 1295 def builddependencies(repo, revs): |
1285 """ returns dependency graphs giving an order to solve instability of revs | 1296 """ returns dependency graphs giving an order to solve instability of revs |
1286 (see orderrevs for more information on usage) """ | 1297 (see orderrevs for more information on usage) """ |
1294 rdependencies = collections.defaultdict(set) | 1305 rdependencies = collections.defaultdict(set) |
1295 | 1306 |
1296 for r in revs: | 1307 for r in revs: |
1297 dependencies[r] = set() | 1308 dependencies[r] = set() |
1298 for p in repo[r].parents(): | 1309 for p in repo[r].parents(): |
1299 succ = _singlesuccessor(repo, p) | 1310 try: |
1311 succ = _singlesuccessor(repo, p) | |
1312 except MultipleSuccessorsError, exc: | |
1313 dependencies[r] = exc.successorssets | |
1300 if succ in revs: | 1314 if succ in revs: |
1301 dependencies[r].add(succ) | 1315 dependencies[r].add(succ) |
1302 rdependencies[succ].add(r) | 1316 rdependencies[succ].add(r) |
1303 return dependencies, rdependencies | 1317 return dependencies, rdependencies |
1304 | 1318 |