Pierre-Yves David avatar Pierre-Yves David committed 7de0554 Merge

merge with stable

Comments (0)

Files changed (6)

 d43e80504e55db9ad4826e860e50530103a27b0f 2.0.0
 f9d305deeff3dba782e65faf4ef3fd1569995859 2.1.0
 862b6b71a35836e81f090ba7229c2888e8ed2f9f 3.0.0
+cdb52bbbe5b8770d5e68943b7e73bee4ba136ecc 3.1.0
 Changelog
 ==================
 
-3.1.0 --
+3.1.0 -- 2013-02-11
 
-- prune: various minor improvements
 - amend: drop deprecated --change option for amend
 - alias: add a grab aliast to be used instead of graft -O
 - touch: add a --duplicate option to *not* obsolete the old version
 - touch: fix touching multiple revision at the same time
 - evolve: add a --all option
+- prune: various minor improvements
+- prune: add option to prune a specific bookmark
+- prune: add -u and -d option to control metadata
 
 3.0.0 -- 2013-02-02
 
 #############################
 cmdtable = {}
 command = cmdutil.command(cmdtable)
+metadataopts = [
+    ('d', 'date', '',
+     _('record the specified date in metadata'), _('DATE')),
+    ('u', 'user', '',
+     _('record the specified user in metadata'), _('USER')),
+]
 
-@command('^evolve|stabilize|evolve|solve',
+
+@command('^evolve|stabilize|solve',
     [('n', 'dry-run', False, 'do not perform actions, print what to be done'),
     ('A', 'any', False, 'evolve any troubled changeset'),
     ('a', 'all', False, 'evolve all troubled changesets'),
         ui.warn(_('Multiple non-obsolete children, explicitly update to one\n'))
         return 1
 
+def _reachablefrombookmark(repo, revs, mark):
+    """filter revisions and bookmarks reachable from the given bookmark
+    yoinked from mq.py
+    """
+    marks = repo._bookmarks
+    if mark not in marks:
+        raise util.Abort(_("bookmark '%s' not found") % mark)
+
+    # If the requested bookmark is not the only one pointing to a
+    # a revision we have to only delete the bookmark and not strip
+    # anything. revsets cannot detect that case.
+    uniquebm = True
+    for m, n in marks.iteritems():
+        if m != mark and n == repo[mark].node():
+            uniquebm = False
+            break
+    if uniquebm:
+        rsrevs = repo.revs("ancestors(bookmark(%s)) - "
+                           "ancestors(head() and not bookmark(%s)) - "
+                           "ancestors(bookmark() and not bookmark(%s)) - "
+                           "obsolete()",
+                           mark, mark, mark)
+        revs.update(set(rsrevs))
+    return marks,revs
+
+def _deletebookmark(ui, marks, mark):
+    del marks[mark]
+    marks.write()
+    ui.write(_("bookmark '%s' deleted\n") % mark)
+
+
+
+def _getmetadata(**opts):
+    metadata = {}
+    date = opts.get('date')
+    user = opts.get('user')
+    if date and '0 0' != date:
+        metadata['date'] = '%i %i' % util.parsedate(date)
+    if user:
+        metadata['user'] = user
+    return metadata
+
+
 @command('^prune|obsolete|kill',
     [('n', 'new', [], _("successor changeset (DEPRECATED)")),
      ('s', 'succ', [], _("successor changeset")),
-     ('r', 'rev', [], _("revisions to prune"))],
+     ('r', 'rev', [], _("revisions to prune")),
+     ('B', 'bookmark', '', _("remove revs only reachable from given"
+                             " bookmark"))] + metadataopts,
     _('[OPTION] [-r] REV...'))
-    # -d --date
-    # -u --user
     # -U  --noupdate option to prevent wc update and or bookmarks update ?
 def cmdprune(ui, repo, *revs, **opts):
     """get rid of changesets by marking them obsolete
 
     you can use the ``--succ`` option to informs mercurial that a newer version
     of the pruned changeset exists.
+    """
+    revs = set(scmutil.revrange(repo, list(revs) + opts.get('rev')))
+    succs = opts['new'] + opts['succ']
+    bookmark = opts.get('bookmark')
+    metadata = _getmetadata(**opts)
 
-    XXX this commands needs bookmarks support.
-    """
-    revs = list(revs)
-    revs.extend(opts['rev'])
-    succs = opts['new'] + opts['succ']
+    if bookmark:
+        marks,revs = _reachablefrombookmark(repo, revs, bookmark)
+        if not revs:
+            # no revisions to prune - delete bookmark immediately
+            _deletebookmark(ui, marks, bookmark)
+
+    if not revs:
+        raise util.Abort(_('nothing to prune'))
+
     wlock = lock = None
     wlock = repo.wlock()
     sortedrevs = lambda specs: sorted(set(scmutil.revrange(repo, specs)))
             msg = "Can't use multiple successors for multiple precursors"
             raise util.Abort(msg)
         # create markers
-        createmarkers(repo, [(p, sucs) for p in precs])
+        createmarkers(repo, [(p, sucs) for p in precs], metadata=metadata)
+
         # informs that changeset have been pruned
         ui.status(_('%i changesets pruned\n') % len(precs))
         # update to an unkilled parent
         if newnode.node() != wdp.node():
             commands.update(ui, repo, newnode.rev())
             ui.status(_('working directory now at %s\n') % newnode)
-        # upVdate bookmarks
+        # update bookmarks
+        if bookmark:
+            _deletebookmark(ui, marks, bookmark)
         for ctx in repo.unfiltered().set('bookmark() and %ld', precs):
             ldest = list(repo.set('max((::%d) - obsolete())', ctx))
             if ldest:
                 dest = ldest[0]
                 updatebookmarks = _bookmarksupdater(repo, ctx.node())
                 updatebookmarks(dest.node())
-            else:
-                # delete bookmarks
-                pass
     finally:
         lockmod.release(lock, wlock)
 
 
     # determine updates to subsume
     old = scmutil.revsingle(repo, '.')
+    metadata = _getmetadata(**opts)
 
     lock = repo.lock()
     try:
 
 setup(
     name='hg-evolve',
-    version='3.0.0',
+    version='3.1.0',
     author='Pierre-Yves David',
     maintainer='Pierre-Yves David',
     maintainer_email='pierre-yves.david@logilab.fr',

tests/test-prune.t

 
 prune current and tip changeset
 
-  $ hg prune .
+  $ hg prune --user blah --date '1979-12-15' .
   1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at 47d2a3944de8
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
 
 prune leaving unstability behind
 
   1 changesets pruned
   2 new unstable changesets
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
 
 pruning multiple changeset at once
   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
   working directory now at 1f0dee641bb7
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
   4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {'date': '*', 'user': 'test'} (glob)
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {'date': '*', 'user': 'test'} (glob)
   (see "hg help phases" for details)
   [255]
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
   4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {'date': '*', 'user': 'test'} (glob)
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {'date': '*', 'user': 'test'} (glob)
   $ hg prune 'desc("add ee")' -s 'desc("add nE")'
   1 changesets pruned
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
   4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {'date': '*', 'user': 'test'} (glob)
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {'date': '*', 'user': 'test'} (glob)
   $ hg prune 'desc("add dd")' -s 'desc("add nD")' -s 'desc("add nC")'
   1 changesets pruned
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
   4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {'date': '*', 'user': 'test'} (glob)
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {'date': '*', 'user': 'test'} (glob)
   abort: Can't use multiple successors for multiple precursors
   [255]
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
   4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {'date': '*', 'user': 'test'} (glob)
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {'date': '*', 'user': 'test'} (glob)
   $ hg prune 'desc("add cc")' 'desc("add bb")' -s 'desc("add nB")'
   2 changesets pruned
   $ hg debugobsolete
-  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '*', 'user': 'test'} (glob)
+  9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
   4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {'date': '*', 'user': 'test'} (glob)
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {'date': '*', 'user': 'test'} (glob)
   00ded550b1e28bba454bd34cec1269d22cf3ef25 aa96dc3f04c2c2341fe6880aeb6dc9fbffff9ef9 8ee176ff1d4b2034ce51e3efc579c2de346b631d 0 {'date': '**', 'user': 'test'} (glob)
   814c38b95e72dfe2cbf675b1649ea9d780c89a80 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 {'date': '*', 'user': 'test'} (glob)
   354011cd103f58bbbd9091a3cee6d6a6bd0dddf7 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 {'date': '*', 'user': 'test'} (glob)
+
+test hg prune -B bookmark
+yoinked from test-mq-strip.t
+
+  $ cd ..
+  $ hg init bookmarks
+  $ cd bookmarks
+  $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b'
+  $ hg bookmark -r 'a' 'todelete'
+  $ hg bookmark -r 'b' 'B'
+  $ hg bookmark -r 'b' 'nostrip'
+  $ hg bookmark -r 'c' 'delete'
+  $ hg up -C todelete
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg prune -B nostrip
+  bookmark 'nostrip' deleted
+  abort: nothing to prune
+  [255]
+  $ hg prune -B todelete
+  1 changesets pruned
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory now at d62d843c9a01
+  bookmark 'todelete' deleted
+  $ hg id -ir dcbb326fdec2
+  abort: 00changelog.i@dcbb326fdec2*: no node! (glob)
+  [255]
+  $ hg id -ir d62d843c9a01
+  d62d843c9a01
+  $ hg bookmarks
+     B                         10:ff43616e5d0f
+     delete                    6:2702dd0c91e7
+  $ hg prune -B delete
+  3 changesets pruned
+  bookmark 'delete' deleted
+  $ hg id -ir 6:2702dd0c91e7
+  abort: 00changelog.i@2702dd0c91e7*: no node! (glob)
+  [255]
+

tests/test-stabilize-order.t

   o  0:c471ef929e6a@default(draft) addroot
   
   $ hg evolve -v
-  no troubled changeset
+  no troubled changesets
   [1]
 
 Test behaviour with --any
   o  0:c471ef929e6a@default(draft) addroot
   
   $ hg evolve --any -v
-  no troubled changeset
+  no troubled changesets
   [1]
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.