Mercurial > hg
comparison mercurial/commands.py @ 15906:aad565319fa3
phase: report phase movement
When used in "set" mode, the phase command now display the number of changeset
who changed phase.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 17 Jan 2012 20:43:41 +0100 |
parents | afd459933d5f |
children | c654eac03452 |
comparison
equal
deleted
inserted
replaced
15905:634d49a8b6db | 15906:aad565319fa3 |
---|---|
4235 | 4235 |
4236 Unless -f/--force is specified, :hg:`phase` won't move changeset from a | 4236 Unless -f/--force is specified, :hg:`phase` won't move changeset from a |
4237 lower phase to an higher phase. Phases are ordered as follows:: | 4237 lower phase to an higher phase. Phases are ordered as follows:: |
4238 | 4238 |
4239 public < draft < secret | 4239 public < draft < secret |
4240 | |
4241 Return 0 on success, 1 if no phases were changed. | |
4240 """ | 4242 """ |
4241 # search for a unique phase argument | 4243 # search for a unique phase argument |
4242 targetphase = None | 4244 targetphase = None |
4243 for idx, name in enumerate(phases.phasenames): | 4245 for idx, name in enumerate(phases.phasenames): |
4244 if opts[name]: | 4246 if opts[name]: |
4251 revs.extend(opts['rev']) | 4253 revs.extend(opts['rev']) |
4252 if not revs: | 4254 if not revs: |
4253 raise util.Abort(_('no revisions specified!')) | 4255 raise util.Abort(_('no revisions specified!')) |
4254 | 4256 |
4255 lock = None | 4257 lock = None |
4258 ret = 0 | |
4256 if targetphase is None: | 4259 if targetphase is None: |
4257 # display | 4260 # display |
4258 for ctx in repo.set('%lr', revs): | 4261 for ctx in repo.set('%lr', revs): |
4259 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr())) | 4262 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr())) |
4260 else: | 4263 else: |
4262 try: | 4265 try: |
4263 # set phase | 4266 # set phase |
4264 nodes = [ctx.node() for ctx in repo.set('%lr', revs)] | 4267 nodes = [ctx.node() for ctx in repo.set('%lr', revs)] |
4265 if not nodes: | 4268 if not nodes: |
4266 raise util.Abort(_('empty revision set')) | 4269 raise util.Abort(_('empty revision set')) |
4270 olddata = repo._phaserev[:] | |
4267 phases.advanceboundary(repo, targetphase, nodes) | 4271 phases.advanceboundary(repo, targetphase, nodes) |
4268 if opts['force']: | 4272 if opts['force']: |
4269 phases.retractboundary(repo, targetphase, nodes) | 4273 phases.retractboundary(repo, targetphase, nodes) |
4270 finally: | 4274 finally: |
4271 lock.release() | 4275 lock.release() |
4276 if olddata is not None: | |
4277 changes = 0 | |
4278 newdata = repo._phaserev | |
4279 changes = sum(o != newdata[i] for i, o in enumerate(olddata)) | |
4280 if changes: | |
4281 ui.note(_('phase change for %i changesets\n') % changes) | |
4282 else: | |
4283 ui.warn(_('no phases changed\n')) | |
4284 ret = 1 | |
4285 return ret | |
4272 | 4286 |
4273 def postincoming(ui, repo, modheads, optupdate, checkout): | 4287 def postincoming(ui, repo, modheads, optupdate, checkout): |
4274 if modheads == 0: | 4288 if modheads == 0: |
4275 return | 4289 return |
4276 if optupdate: | 4290 if optupdate: |