Commits

Pierre-Yves David committed 69a37d5

evolve: issue the "%i new unstable changeset" in more place

most command able to create unstability now issue the warning

Comments (0)

Files changed (2)

docs/tutorials/tutorial.t

   9ca060c80d74 (public): SPAM
   7e82d3f3c2cb (public): Monthy Python Shopping list
 
-Rebasing unstable change after update
+Rebasing unstable change after pull
 ----------------------------------------------
 
 Remotely someone add a new changeset on top of our mutable "bathroom" on.
 
 When we pull from remote again we get an unstable state!
 
+
   $ hg pull remote
   pulling from $TESTTMP/remote
   searching for changes
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
   (run 'hg heads .' to see heads, 'hg merge' to merge)
+  1 new unstables changesets
   $ hg log
   9ac5d0e790a2 (secret): animals
   ffa278c50818 (draft): bathroom stuff
 
 In the mean time I noticed you can't buy animals in a super market and I kill the animal changeset:
 
-  $ hg kill 437efbcaf700 # XXX issue a warning here
+  $ hg kill 437efbcaf700
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   working directory now at ffa278c50818
+  1 new unstables changesets
 
 
 The animals changeset is still displayed because the "SPAM SPAM SPAM" changeset
     return map(repo.changelog.node,
                scmutil.revrange(repo, revsets))
 
+
+
+def warnunstable(orig, ui, repo, *args, **kwargs):
+    """display warning is the command resulted in more instable changeset"""
+    priorunstables = len(repo.revs('unstable()'))
+    #print orig, priorunstables
+    #print len(repo.revs('secret() - obsolete()'))
+    try:
+        return orig(ui, repo, *args, **kwargs)
+    finally:
+        newunstables = len(repo.revs('unstable()')) - priorunstables
+        #print orig, newunstables
+        #print len(repo.revs('secret() - obsolete()'))
+        if newunstables > 0:
+            ui.warn(_('%i new unstables changesets\n') % newunstables)
+
+
 ### extension check
 #############################
 
-def extsetup(ui):
-    try:
-        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
 #############################
             if not old.phase():
                 raise util.Abort(_("can not rewrite immutable changeset %s") % old)
 
-            # store the amount of unstable prior update
-            if old.children():
-                priorunstables = len(repo.revs('unstable()'))
-            else:
-                #no children mean no change for unstable changeset
-                priorunstables = None
-
             # commit current changes as update
             # code copied from commands.commit to avoid noisy messages
             ciopts = dict(opts)
             phases.retractboundary(repo, old.phase(), [newid])
             repo.dirstate.setparents(newid, node.nullid)
 
-            if priorunstables is not None:
-                newunstables = len(repo.revs('unstable()')) - priorunstables
-                if newunstables > 0:
-                    ui.warn(_('%i new unstables changesets\n') % newunstables)
         finally:
             wlock.release()
     finally:
         lock.release()
 
+
+
+
 def commitwrapper(orig, ui, repo, *arg, **kwargs):
     lock = repo.lock()
     try:
         lock.release()
 
 def extsetup(ui):
+    try:
+        obsolete = extensions.find('obsolete')
+    except KeyError:
+        raise error.Abort(_('evolution extension require obsolete extension.'))
+    try:
+        rebase = extensions.find('rebase')
+    except KeyError:
+        rebase = None
+        raise error.Abort(_('evolution extension require rebase extension.'))
+
     entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper)
     entry[1].append(('o', 'obsolete', [], _("this commit obsolet this revision")))
     entry = extensions.wrapcommand(commands.table, 'graft', graftwrapper)
     entry[1].append(('o', 'obsolete', [], _("this graft obsolet this revision")))
     entry[1].append(('O', 'old-obsolete', False, _("graft result obsolete graft source")))
+
+    # warning about more obsolete
+    for cmd in ['commit', 'push', 'pull', 'graft']:
+        entry = extensions.wrapcommand(commands.table, cmd, warnunstable)
+    for cmd in ['kill', 'amend']:
+        entry = extensions.wrapcommand(cmdtable, cmd, warnunstable)
+
+    if rebase is not None:
+        entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnunstable)
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.