Commits

Pierre-Yves David committed 56d4c62

Move obserror warning into the obsolete extension.

Comments (0)

Files changed (4)

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

hgext/obsolete.py

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

tests/test-obsolete.t

   $ hg up 3 -q
   Working directory parent is obsolete
   $ mkcommit d # 5 (on 3)
+  1 new unstables changesets
   $ qlog -r 'obsolete()'
   3
   - 0d3f46688ccc
   Working directory parent is obsolete
   $ mkcommit obsol_d # 6
   created new head
+  1 new unstables changesets
   $ hg debugobsolete 6 5
   $ qlog
   6
   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 .
   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
 
   $ 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'''
   |

tests/test-uncommit.t

   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 .
   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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.