Move obserror warning into the obsolete extension. stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 11 Jul 2012 13:59:02 +0200
branchstable
changeset 356 56d4c6207ef9
parent 355 72642a6970e0
child 358 ce5ea6f6a700
child 359 43f79983f638
Move obserror warning into the obsolete extension.
hgext/evolve.py
hgext/obsolete.py
tests/test-obsolete.t
tests/test-uncommit.t
--- a/hgext/evolve.py	Wed Jul 11 13:38:48 2012 +0200
+++ b/hgext/evolve.py	Wed Jul 11 13:59:02 2012 +0200
@@ -33,28 +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()'))
-    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)
-
 ### changeset rewriting logic
 #############################
 
@@ -681,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")))
@@ -690,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:38:48 2012 +0200
+++ b/hgext/obsolete.py	Wed Jul 11 13:59:02 2012 +0200
@@ -414,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)
@@ -691,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)
--- a/tests/test-obsolete.t	Wed Jul 11 13:38:48 2012 +0200
+++ b/tests/test-obsolete.t	Wed Jul 11 13:59:02 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'''
   |
--- a/tests/test-uncommit.t	Wed Jul 11 13:38:48 2012 +0200
+++ b/tests/test-uncommit.t	Wed Jul 11 13:59:02 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