Commits

Dan Villiom Podlaski Christiansen  committed ddbea2f

evolve: allow updating to the successor if the parent is obsolete

Although 'hg update' handles this as well, it will also update to
tipmost descendent of the successor, if any.

  • Participants
  • Parent commits f728edc
  • Branches default

Comments (0)

Files changed (4)

 - amend: drop the deprecated note option
 - amend: use core mechanism for amend (fix multiple bugs)
 - parents command: add "working directory parent is obsolete" message
+- evolve command: allow updating to the successor if the parent is
+  obsolete
 
 3.1.0 -- 2013-02-11
 

File hgext/evolve.py

     - rebase unstable changeset to make it stable again,
     - create proper diff from bumped changeset,
     - merge divergent changesets.
+    - update to a successor if the working directory parent is
+      obsolete
 
     By default, take the first trouble changeset that looks relevant.
 
 
     tr = _picknexttroubled(ui, repo, anyopt or allopt)
     if tr is None:
+        if repo['.'].obsolete():
+            displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
+            successors = set()
+
+            for successorsset in obsolete.successorssets(repo, repo['.'].node()):
+                for nodeid in successorsset:
+                    successors.add(repo[nodeid])
+
+            if not successors:
+                ui.warn(_('parent is obsolete without successors; ' +
+                          'likely killed\n'))
+                return 2
+
+            elif len(successors) > 1:
+                ui.warn(_('parent is obsolete with multiple successors:\n'))
+
+                for ctx in sorted(successors, key=lambda ctx: ctx.rev()):
+                    displayer.show(ctx)
+
+                return 2
+
+            else:
+                ctx = successors.pop()
+
+                ui.status(_('update:'))
+                if not ui.quiet:
+                    displayer.show(ctx)
+
+                if dryrunopt:
+                    print 'hg update %s' % ctx.rev()
+                    return 0
+                else:
+                    return hg.update(repo, ctx.rev())
+
         troubled = repo.revs('troubled()')
         if troubled:
             ui.write_err(_('nothing to evolve here\n'))

File tests/test-obsolete.t

   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add obsolet_conflicting_d
   
+
+  $ hg up --hidden 3 -q
+  working directory parent is obsolete!
+  $ hg evolve
+  parent is obsolete with multiple successors:
+  [4] add obsol_c'
+  [10] add obsol_c
+  [2]
+  $ hg olog
+  changeset:   2:4538525df7e2
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     add c
+  

File tests/test-tutorial.t

   no changes found
   working directory parent is obsolete!
 
-  $ hg up ee942144f952
+now let's see where we are, and update to the successor
+
+  $ hg parents
+  bf1b0d202029 (draft): animals
+  working directory parent is obsolete!
+  $ hg evolve
+  update:[8] animals
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Relocating unstable change after prune