Commits

Dan Villiom Podlaski Christiansen committed 5c3ae06

allow evolve to handle obsolete parents

Comments (0)

Files changed (3)

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

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
+  

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