Mercurial > evolve
changeset 358:ce5ea6f6a700 stable
merge with doc fix
author | Pierre-Yves.David@ens-lyon.org |
---|---|
date | Sat, 14 Jul 2012 17:58:08 +0200 |
parents | b398e9c2dbd1 (current diff) 56d4c6207ef9 (diff) |
children | 88cee22c89f1 |
files | |
diffstat | 6 files changed, 106 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Wed Jul 11 13:59:06 2012 -0400 +++ b/.hgtags Sat Jul 14 17:58:08 2012 +0200 @@ -2,3 +2,4 @@ d3f20770b86a31dba56ae7b252089e12b34702da 0.2.0 c046b083a5e0b21af69027f31cee141800cf894b 0.3.0 9bbcd274689829d9239978236e16610688978233 0.4.0 +4ecbaec1d664b1e6f8ebc78292e1ced77a8e69c0 0.4.1
--- a/hgext/evolve.py Wed Jul 11 13:59:06 2012 -0400 +++ b/hgext/evolve.py Sat Jul 14 17:58:08 2012 +0200 @@ -33,24 +33,6 @@ return map(repo.changelog.node, scmutil.revrange(repo, revsets)) -def warnobserrors(orig, ui, repo, *args, **kwargs): - """display warning is the command resulted in more instable changeset""" - priorunstables = len(repo.revs('unstable()')) - priorlatecomers = len(repo.revs('latecomer()')) - #print orig, priorunstables - #print len(repo.revs('secret() - obsolete()')) - try: - return orig(ui, repo, *args, **kwargs) - finally: - newunstables = len(repo.revs('unstable()')) - priorunstables - newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers - #print orig, newunstables - #print len(repo.revs('secret() - obsolete()')) - if newunstables > 0: - ui.warn(_('%i new unstables changesets\n') % newunstables) - if newlatecomers > 0: - ui.warn(_('%i new latecomers changesets\n') % newlatecomers) - ### changeset rewriting logic ############################# @@ -677,6 +659,10 @@ rebase = None raise error.Abort(_('evolution extension require rebase extension.')) + for cmd in ['amend', 'kill', 'uncommit']: + entry = extensions.wrapcommand(cmdtable, cmd, + obsolete.warnobserrors) + entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper) entry[1].append(('o', 'obsolete', [], _("make commit obsolete this revision"))) @@ -686,11 +672,3 @@ entry[1].append(('O', 'old-obsolete', False, _("make graft obsoletes its source"))) - # warning about more obsolete - for cmd in ['commit', 'push', 'pull', 'graft', 'phase', 'unbundle']: - entry = extensions.wrapcommand(commands.table, cmd, warnobserrors) - for cmd in ['amend', 'kill', 'uncommit']: - entry = extensions.wrapcommand(cmdtable, cmd, warnobserrors) - - if rebase is not None: - entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors)
--- a/hgext/obsolete.py Wed Jul 11 13:59:06 2012 -0400 +++ b/hgext/obsolete.py Sat Jul 14 17:58:08 2012 +0200 @@ -152,6 +152,14 @@ context.changectx.latecomer = latecomer +def conflicting(ctx): + """is the changeset conflicting (Try to succeed to public change)""" + if ctx.node() is None: + return False + return ctx.rev() in ctx._repo._conflictingset + +context.changectx.conflicting = conflicting + ### revset ############################# @@ -193,6 +201,11 @@ args = revset.getargs(x, 0, 0, 'latecomer takes no arguments') return [r for r in subset if r in repo._latecomerset] +def revsetconflicting(repo, subset, x): + """conflicting, Try to succeed to public change""" + args = revset.getargs(x, 0, 0, 'conflicting takes no arguments') + return [r for r in subset if r in repo._conflictingset] + def _precursors(repo, s): """Precursor of a changeset""" cs = set() @@ -391,6 +404,7 @@ revset.symbols["suspended"] = revsetsuspended revset.symbols["extinct"] = revsetextinct revset.symbols["latecomer"] = revsetlatecomer + revset.symbols["conflicting"] = revsetconflicting revset.symbols["obsparents"] = revsetprecursors # DEPR revset.symbols["precursors"] = revsetprecursors revset.symbols["obsancestors"] = revsetallprecursors # DEPR @@ -400,9 +414,13 @@ templatekw.keywords['obsolete'] = obsoletekw + # warning about more obsolete + for cmd in ['commit', 'push', 'pull', 'graft', 'phase', 'unbundle']: + entry = extensions.wrapcommand(commands.table, cmd, warnobserrors) try: rebase = extensions.find('rebase') if rebase: + entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) extensions.wrapfunction(rebase, 'buildstate', buildstate) extensions.wrapfunction(rebase, 'defineparents', defineparents) extensions.wrapfunction(rebase, 'concludenode', concludenode) @@ -483,6 +501,9 @@ if ctx.latecomer(): raise util.Abort(_("Trying to push latecomer changeset: %s!") % ctx, hint=hint) + if ctx.conflicting(): + raise util.Abort(_("Trying to push conflicting changeset: %s!") % ctx, + hint=hint) ### patch remote branch map # do not read it this burn eyes try: @@ -609,7 +630,7 @@ del oldmark['id'] # dropped for now del oldmark['reason'] # unused until then oldobject = str(oldmark.pop('object')) - oldsubjects = [str(s) for s in oldmark.pop('subjects')] + oldsubjects = [str(s) for s in oldmark.pop('subjects', [])] LOOKUP_ERRORS = (error.RepoLookupError, error.LookupError) if len(oldobject) != 40: try: @@ -626,7 +647,9 @@ meta = dict((k.encode('utf-8'), v.encode('utf-8')) for k, v in oldmark.iteritems()) try: - store.create(bin(oldobject), [bin(n) for n in oldsubjects], + succs = [bin(n) for n in oldsubjects] + succs = [n for n in succs if n != nullid] + store.create(bin(oldobject), succs, 0, meta) cnt += 1 except ValueError: @@ -672,6 +695,28 @@ ui.warn(_('Working directory parent is obsolete\n')) return res +def warnobserrors(orig, ui, repo, *args, **kwargs): + """display warning is the command resulted in more instable changeset""" + priorunstables = len(repo.revs('unstable()')) + priorlatecomers = len(repo.revs('latecomer()')) + priorconflictings = len(repo.revs('conflicting()')) + #print orig, priorunstables + #print len(repo.revs('secret() - obsolete()')) + try: + return orig(ui, repo, *args, **kwargs) + finally: + newunstables = len(repo.revs('unstable()')) - priorunstables + newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers + newconflictings = len(repo.revs('conflicting()')) - priorconflictings + #print orig, newunstables + #print len(repo.revs('secret() - obsolete()')) + if newunstables > 0: + ui.warn(_('%i new unstables changesets\n') % newunstables) + if newlatecomers > 0: + ui.warn(_('%i new latecomers changesets\n') % newlatecomers) + if newconflictings > 0: + ui.warn(_('%i new conflictings changesets\n') % newconflictings) + def noextinctsvisibleheads(orig, repo): repo._turn_extinct_secret() return orig(repo) @@ -754,6 +799,7 @@ while toproceed: current = toproceed.pop() assert len(current) <= 1, 'splitting not handled yet. %r' % current + current = [n for n in current if n != nullid] if current: n, = current if n in objectrels: @@ -1028,6 +1074,26 @@ query = 'allsuccessors(public()) - obsolete() - public()' return set(self.revs(query)) + @util.propertycache + def _conflictingset(self): + """the set of rev trying to obsolete public revision""" + conflicting = set() + obsstore = self.obsstore + newermap = {} + for ctx in self.set('(not public()) - obsolete()'): + prec = obsstore.successors.get(ctx.node(), ()) + toprocess = set(prec) + while toprocess: + prec = toprocess.pop()[0] + if prec not in newermap: + newermap[prec] = newerversion(self, prec) + newer = [n for n in newermap[prec] if n] # filter kill + if len(newer) > 1: + conflicting.add(ctx.rev()) + break + toprocess.update(obsstore.successors.get(prec, ())) + return conflicting + def _clearobsoletecache(self): if '_obsoleteset' in vars(self): del self._obsoleteset @@ -1046,6 +1112,8 @@ del self._extinctset if '_latecomerset' in vars(self): del self._latecomerset + if '_conflictingset' in vars(self): + del self._conflictingset def addobsolete(self, sub, obj): """Add a relation marking that node <sub> is a new version of <obj>"""
--- a/tests/test-obsolete.t Wed Jul 11 13:59:06 2012 -0400 +++ b/tests/test-obsolete.t Sat Jul 14 17:58:08 2012 +0200 @@ -108,6 +108,7 @@ $ hg up 3 -q Working directory parent is obsolete $ mkcommit d # 5 (on 3) + 1 new unstables changesets $ qlog -r 'obsolete()' 3 - 0d3f46688ccc @@ -180,6 +181,7 @@ Working directory parent is obsolete $ mkcommit obsol_d # 6 created new head + 1 new unstables changesets $ hg debugobsolete 6 5 $ qlog 6 @@ -235,6 +237,7 @@ Working directory parent is obsolete $ mkcommit "obsol_d'" # 7 created new head + 1 new unstables changesets $ hg debugobsolete 7 6 $ hg pull -R ../other-new . pulling from . @@ -318,6 +321,7 @@ Working directory parent is obsolete $ mkcommit "obsol_d''" created new head + 1 new unstables changesets $ hg debugobsolete 8 7 $ cd ../other-new $ hg up -q 3 @@ -488,6 +492,7 @@ $ cd local $ hg phase --public 11 + 1 new latecomers changesets $ hg --config extensions.graphlog=glog glog --template='{rev} - ({phase}) {node|short} {desc}\n' @ 12 - (draft) 6db5e282cb91 add obsol_d''' | @@ -578,3 +583,24 @@ 9468a5f5d8b2 6db5e282cb91 95de7fc6918d 909a0fb57e5d a7a6f2b5d8a5 95de7fc6918d + +Check conflict detection + + $ hg up 9468a5f5d8b2 # add obsol_d'' + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ mkcommit "obsolet_conflicting_d" + $ hg summary + parent: 14:50f11e5e3a63 tip + add obsolet_conflicting_d + branch: default + commit: (clean) + update: 9 new changesets, 9 branch heads (merge) + $ hg debugobsolete 50f11e5e3a63 a7a6f2b5d8a5 + $ hg log -r 'conflicting()' + changeset: 14:50f11e5e3a63 + tag: tip + parent: 11:9468a5f5d8b2 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: add obsolet_conflicting_d +
--- a/tests/test-oldconvert.t Wed Jul 11 13:59:06 2012 -0400 +++ b/tests/test-oldconvert.t Sat Jul 14 17:58:08 2012 +0200 @@ -78,9 +78,6 @@ > }, > { > "reason": "import from older format.", - > "subjects": [ - > "a37154106de358121a32a3dd6ba0281931550515" - > ], > "user": "Pierre-Yves David <pierre-yves.david@logilab.fr>", > "date": [ > 1336557472.7875929, @@ -92,7 +89,7 @@ > { > "reason": "import from older format.", > "subjects": [ - > "dc8d8aa6e8ac490fcafd074d570df0787ee0ee69" + > "0000000000000000000000000000000000000000" > ], > "user": "Pierre-Yves David <pierre-yves.david@logilab.fr>", > "date": [ @@ -111,7 +108,7 @@ $ hg debugconvertobsolete --traceback 3 obsolete marker converted $ hg debugsuccessors - 2c3784e102bb dc8d8aa6e8ac + 2c3784e102bb 3e03d82708d4 3218406b50ed - 5c722672795c a37154106de3 + 5c722672795c 7c3bad9141dc d67cd0334eee
--- a/tests/test-uncommit.t Wed Jul 11 13:59:06 2012 -0400 +++ b/tests/test-uncommit.t Sat Jul 14 17:58:08 2012 +0200 @@ -242,6 +242,7 @@ Working directory parent is obsolete $ hg --config extensions.purge= purge $ hg uncommit -I 'set:added() and e' + 2 new conflictings changesets $ hg st --copies A e $ hg st --copies --change . @@ -285,6 +286,7 @@ Working directory parent is obsolete $ hg --config extensions.purge= purge $ hg uncommit --all -X e + 1 new conflictings changesets $ hg st --copies M b M d