changeset 1626:0edb545503fe

topic: 'hg evolve --all' pick all trouble within current topic This is the first changeset of a collaboration between the topic extensions and evolve. If there is an active topic, 'hg evolve --all' will try to fix all changesets in that topic wherever they are. Aspiring descendant that are not in the current topic will be ignored. For now, evolve behave as usual if there is no active topic. This is a bit inconsistent and will probably be unified in the future.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Mar 2016 09:39:35 -0700
parents 081605c2e9b6
children a91115687a7e
files README hgext/evolve.py tests/test-evolve-topic.t
diffstat 3 files changed, 172 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/README	Sat Mar 12 13:59:07 2016 +0800
+++ b/README	Thu Mar 17 09:39:35 2016 -0700
@@ -56,6 +56,11 @@
 Changelog
 =========
 
+5.4.0 -- 
+
+- Some collaboration with the topic experimental extensions
+  - hg evolve --all with consider all trouble in your current topic
+
 5.3.0 -- 2016-02-11
 
 - split: add a new command to split changesets,
--- a/hgext/evolve.py	Sat Mar 12 13:59:07 2016 +0800
+++ b/hgext/evolve.py	Thu Mar 17 09:39:35 2016 -0700
@@ -1454,9 +1454,14 @@
         revs = repo.revs(targetcat+'()')
         if revopt:
             revs = scmutil.revrange(repo, revopt) & revs
-        elif not anyopt and targetcat == 'unstable':
-            revs = set(_aspiringdescendant(repo,
-                                           repo.revs('(.::) - obsolete()::')))
+        elif not anyopt:
+            topic = getattr(repo, 'currenttopic', '')
+            if topic:
+                revs = repo.revs('topic(%s)', topic) & revs
+            elif targetcat == 'unstable':
+                revs = _aspiringdescendant(repo,
+                                           repo.revs('(.::) - obsolete()::'))
+                revs = set(revs)
         if targetcat == 'divergent':
             # Pick one divergent per group of divergents
             revs = _dedupedivergents(repo, revs)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-evolve-topic.t	Thu Mar 17 09:39:35 2016 -0700
@@ -0,0 +1,159 @@
+
+Check we can find the topic extensions
+
+  $ [ -e $TOPICROOT/hgext3rd/topic/__init__.py ] || exit 80
+  $ cat >> $HGRCPATH <<EOF
+  > [defaults]
+  > amend=-d "0 0"
+  > fold=-d "0 0"
+  > [phases]
+  > publish = False
+  > [ui]
+  > logtemplate = {rev} - \{{get(namespaces, "topics")}} {node|short} {desc} ({phase})\n
+  > [diff]
+  > git = 1
+  > unified = 0
+  > [extensions]
+  > rebase = 
+  > topic = $TOPICROOT/hgext3rd/topic/
+  > EOF
+  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH
+
+  $ mkcommit() {
+  >    echo "$1" > "$1"
+  >    hg add "$1"
+  >    hg ci -m "add $1"
+  > }
+
+Create a simple setup
+
+  $ hg init repoa
+  $ cd repoa
+  $ mkcommit aaa
+  $ mkcommit bbb
+  $ hg topic foo
+  $ mkcommit ccc
+  $ mkcommit ddd
+  created new head
+  $ mkcommit eee
+  created new head
+  $ mkcommit fff
+  created new head
+  $ hg topic bar
+  $ mkcommit ggg
+  created new head
+  $ mkcommit hhh
+  created new head
+  $ mkcommit iii
+  created new head
+  $ mkcommit jjj
+  created new head
+
+  $ hg log -G
+  @  9 - {bar} 1d964213b023 add jjj (draft)
+  |
+  o  8 - {bar} fcab990f3261 add iii (draft)
+  |
+  o  7 - {bar} b0c2554835ac add hhh (draft)
+  |
+  o  6 - {bar} c748293f1c1a add ggg (draft)
+  |
+  o  5 - {foo} 6a6b7365c751 add fff (draft)
+  |
+  o  4 - {foo} 3969ab847d9c add eee (draft)
+  |
+  o  3 - {foo} 4e3a154f38c7 add ddd (draft)
+  |
+  o  2 - {foo} cced9bac76e3 add ccc (draft)
+  |
+  o  1 - {} a4dbed0837ea add bbb (draft)
+  |
+  o  0 - {} 199cc73e9a0b add aaa (draft)
+  
+
+Test that evolve --all evolve the current topic
+-----------------------------------------------
+
+make a mess
+
+  $ hg up foo
+  switching to topic foo
+  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+  $ hg topic -l 
+    _ add bbb
+  t0: add ccc
+  t1: add ddd
+  t2: add eee
+  t3@ add fff (current)
+  $ hg up 'desc(ddd)'
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo ddd >> ddd
+  $ hg amend
+  6 new unstable changesets
+  $ hg up 'desc(fff)'
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo fff >> fff
+  $ hg amend
+
+  $ hg log -G
+  @  13 - {foo} e104f49bab28 add fff (draft)
+  |
+  | o  11 - {foo} d9cacd156ffc add ddd (draft)
+  | |
+  | | o  9 - {bar} 1d964213b023 add jjj (draft)
+  | | |
+  | | o  8 - {bar} fcab990f3261 add iii (draft)
+  | | |
+  | | o  7 - {bar} b0c2554835ac add hhh (draft)
+  | | |
+  | | o  6 - {bar} c748293f1c1a add ggg (draft)
+  | | |
+  +---x  5 - {foo} 6a6b7365c751 add fff (draft)
+  | |
+  o |  4 - {foo} 3969ab847d9c add eee (draft)
+  | |
+  x |  3 - {foo} 4e3a154f38c7 add ddd (draft)
+  |/
+  o  2 - {foo} cced9bac76e3 add ccc (draft)
+  |
+  o  1 - {} a4dbed0837ea add bbb (draft)
+  |
+  o  0 - {} 199cc73e9a0b add aaa (draft)
+  
+
+Run evolve --all
+
+  $ hg evolve --all
+  move:[4] add eee
+  atop:[11] add ddd
+  move:[13] add fff
+  atop:[14] add eee
+  working directory is now at 070c5573d8f9
+  $ hg log -G
+  @  15 - {foo} 070c5573d8f9 add fff (draft)
+  |
+  o  14 - {foo} 42b49017ff90 add eee (draft)
+  |
+  o  11 - {foo} d9cacd156ffc add ddd (draft)
+  |
+  | o  9 - {bar} 1d964213b023 add jjj (draft)
+  | |
+  | o  8 - {bar} fcab990f3261 add iii (draft)
+  | |
+  | o  7 - {bar} b0c2554835ac add hhh (draft)
+  | |
+  | o  6 - {bar} c748293f1c1a add ggg (draft)
+  | |
+  | x  5 - {foo} 6a6b7365c751 add fff (draft)
+  | |
+  | x  4 - {foo} 3969ab847d9c add eee (draft)
+  | |
+  | x  3 - {foo} 4e3a154f38c7 add ddd (draft)
+  |/
+  o  2 - {foo} cced9bac76e3 add ccc (draft)
+  |
+  o  1 - {} a4dbed0837ea add bbb (draft)
+  |
+  o  0 - {} 199cc73e9a0b add aaa (draft)
+  
+