comparison mercurial/obsutil.py @ 33252:53b3a1968aa6

obsolete: reports the number of local changeset obsoleted when unbundling This is a first basic visible usage of the changes tracking in the transaction. We adds a new function computing the pre-existing changesets obsoleted by a transaction and a transaction call back displaying this information. Example output: added 1 changesets with 1 changes to 1 files (+1 heads) 3 new obsolescence markers obsoleted 1 changesets The goal is to evolve the transaction summary into something bigger, gathering existing output there and adding new useful one. This patch is a good first step on this road. The new output is basic but give a user to the content of tr.changes['obsmarkers'] and give an idea of the new options we haves. I expect to revisit the message soon. The caller recording the transaction summary should also be moved into a more generic location but further refactoring is needed before it can happen.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 28 Jun 2017 03:54:19 +0200
parents a14e2e7f7d1f
children df90f4d6c609
comparison
equal deleted inserted replaced
33251:a5cb2e4460de 33252:53b3a1968aa6
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9
10 from . import (
11 phases,
12 )
9 13
10 class marker(object): 14 class marker(object):
11 """Wrap obsolete marker raw data""" 15 """Wrap obsolete marker raw data"""
12 16
13 def __init__(self, repo, data): 17 def __init__(self, repo, data):
282 mutable = [c.node() for c in foreground if c.mutable()] 286 mutable = [c.node() for c in foreground if c.mutable()]
283 succs.update(allsuccessors(repo.obsstore, mutable)) 287 succs.update(allsuccessors(repo.obsstore, mutable))
284 known = (n for n in succs if n in nm) 288 known = (n for n in succs if n in nm)
285 foreground = set(repo.set('%ln::', known)) 289 foreground = set(repo.set('%ln::', known))
286 return set(c.node() for c in foreground) 290 return set(c.node() for c in foreground)
291
292 def getobsoleted(repo, tr):
293 """return the set of pre-existing revisions obsoleted by a transaction"""
294 torev = repo.unfiltered().changelog.nodemap.get
295 phase = repo._phasecache.phase
296 succsmarkers = repo.obsstore.successors.get
297 public = phases.public
298 addedmarkers = tr.changes.get('obsmarkers')
299 addedrevs = tr.changes.get('revs')
300 seenrevs = set(addedrevs)
301 obsoleted = set()
302 for mark in addedmarkers:
303 node = mark[0]
304 rev = torev(node)
305 if rev is None or rev in seenrevs:
306 continue
307 seenrevs.add(rev)
308 if phase(repo, rev) == public:
309 continue
310 if set(succsmarkers(node)).issubset(addedmarkers):
311 obsoleted.add(rev)
312 return obsoleted
287 313
288 def successorssets(repo, initialnode, cache=None): 314 def successorssets(repo, initialnode, cache=None):
289 """Return set of all latest successors of initial nodes 315 """Return set of all latest successors of initial nodes
290 316
291 The successors set of a changeset A are the group of revisions that succeed 317 The successors set of a changeset A are the group of revisions that succeed