[evolution/obsolete] very experimental and crude evolve support.
--- a/hgext/evolution.py Mon Sep 19 01:57:43 2011 +0200
+++ b/hgext/evolution.py Mon Sep 19 03:18:08 2011 +0200
@@ -32,9 +32,13 @@
def extsetup(ui):
try:
- rebase = extensions.find('obsolete')
+ obsolete = extensions.find('obsolete')
except KeyError:
raise error.Abort(_('evolution extension require obsolete extension.'))
+ try:
+ rebase = extensions.find('rebase')
+ except KeyError:
+ raise error.Abort(_('evolution extension require rebase extension.'))
### changeset rewriting logic
#############################
@@ -109,6 +113,23 @@
cmdtable = {}
command = cmdutil.command(cmdtable)
+@command('^evolve',
+ [],
+ '')
+def evolve(ui, repo):
+ """suggest the next evolution step"""
+ obsolete = extensions.find('obsolete')
+ next = min(obsolete.unstables(repo))
+ obs = repo[next].parents()[0]
+ if not obs.obsolete():
+ obs = next.parents()[1]
+ assert obs.obsolete()
+ newer = obsolete.newerversion(repo, obs.node())
+ target = newer[-1]
+ repo.ui.status('hg rebase --dest %s --source %s --detach \n' % (repo[target].rev(), next))
+
+
+
@command('^kill',
[],
'<revs>')
--- a/hgext/obsolete.py Mon Sep 19 01:57:43 2011 +0200
+++ b/hgext/obsolete.py Mon Sep 19 03:18:08 2011 +0200
@@ -283,6 +283,27 @@
rels.setdefault( subnode, set()).add(bin(objhex))
return rels
+### diagnostique tools
+#############################
+
+def unstables(repo):
+ """Return all unstable changeset"""
+ return scmutil.revrange(repo, ['obsolete():: and (not obsolete())'])
+
+def newerversion(repo, obs):
+ """Return the newer version of an obsolete changeset"""
+ toproceed = set([obs])
+ # XXX know optimization available
+ newer = set()
+ while toproceed:
+ current = toproceed.pop()
+ if current in repo._obsobjrels:
+ toproceed.update(repo._obsobjrels[current])
+ elif current is not None: # None is kill
+ newer.add(current)
+ return sorted(newer)
+
+
### repo subclassing
#############################
--- a/tests/test-evolution.t Mon Sep 19 01:57:43 2011 +0200
+++ b/tests/test-evolution.t Mon Sep 19 03:18:08 2011 +0200
@@ -8,6 +8,7 @@
> git = 1
> unified = 0
> [extensions]
+ > hgext.rebase=
> EOF
$ echo "states=$(echo $(dirname $TESTDIR))/hgext/states.py" >> $HGRCPATH
$ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py" >> $HGRCPATH
@@ -190,3 +191,23 @@
4 feature-B: another feature - test
1 feature-A: a nifty feature - test
0 : base - test
+
+ $ hg up feature-A -q
+ $ sed -i '' -e s/Eins/Un/ main-file-1
+
+ $ hg amend --note 'french looks better'
+ $ hg log
+ 6 feature-A: a nifty feature - test
+ 4 feature-B: another feature - test
+ 1 : a nifty feature - test
+ 0 : base - test
+ $ hg evolve
+ hg rebase --dest 6 --source 4 --detach
+ $ hg up feature-B -q #prevent feature-A bookmark to move grml
+ $ hg rebase --dest 6 --source 4 --detach
+ merging main-file-1
+ $ hg bookmark -fr 7 feature-B # XXX there is a bug out-there because we force --keep imp
+ $ hg log
+ 7 feature-B: another feature - test
+ 6 feature-A: a nifty feature - test
+ 0 : base - test