Commits

Pierre-Yves David  committed 246b8fe

[evolution/obsolete] very experimental and crude evolve support.

  • Participants
  • Parent commits 7f763ba

Comments (0)

Files changed (3)

File hgext/evolution.py

 
 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
 #############################
 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>')

File hgext/obsolete.py

         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
 #############################
 

File tests/test-evolution.t

   > 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
   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