changeset 720:7de0554bf190

merge with stable
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 11 Feb 2013 10:46:38 +0100
parents 29abdb2aeccb (current diff) a0c5d1679354 (diff)
children 06cd220141ba
files
diffstat 6 files changed, 129 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sun Feb 10 16:14:45 2013 +0100
+++ b/.hgtags	Mon Feb 11 10:46:38 2013 +0100
@@ -17,3 +17,4 @@
 d43e80504e55db9ad4826e860e50530103a27b0f 2.0.0
 f9d305deeff3dba782e65faf4ef3fd1569995859 2.1.0
 862b6b71a35836e81f090ba7229c2888e8ed2f9f 3.0.0
+cdb52bbbe5b8770d5e68943b7e73bee4ba136ecc 3.1.0
--- a/README	Sun Feb 10 16:14:45 2013 +0100
+++ b/README	Mon Feb 11 10:46:38 2013 +0100
@@ -44,14 +44,16 @@
 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
 
--- a/hgext/evolve.py	Sun Feb 10 16:14:45 2013 +0100
+++ b/hgext/evolve.py	Mon Feb 11 10:46:38 2013 +0100
@@ -829,8 +829,15 @@
 #############################
 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'),
@@ -1242,13 +1249,56 @@
         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
@@ -1263,12 +1313,21 @@
 
     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)))
@@ -1292,7 +1351,8 @@
             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
@@ -1303,16 +1363,15 @@
         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)
 
@@ -1344,6 +1403,7 @@
 
     # determine updates to subsume
     old = scmutil.revsingle(repo, '.')
+    metadata = _getmetadata(**opts)
 
     lock = repo.lock()
     try:
--- a/setup.py	Sun Feb 10 16:14:45 2013 +0100
+++ b/setup.py	Mon Feb 11 10:46:38 2013 +0100
@@ -5,7 +5,7 @@
 
 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',
--- a/tests/test-prune.t	Sun Feb 10 16:14:45 2013 +0100
+++ b/tests/test-prune.t	Mon Feb 11 10:46:38 2013 +0100
@@ -38,12 +38,12 @@
 
 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
 
@@ -51,7 +51,7 @@
   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
@@ -61,7 +61,7 @@
   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)
@@ -73,7 +73,7 @@
   (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)
@@ -118,7 +118,7 @@
   $ 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)
@@ -146,7 +146,7 @@
   $ 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)
@@ -174,7 +174,7 @@
   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)
@@ -186,7 +186,7 @@
   $ 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)
@@ -194,3 +194,41 @@
   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]
+
--- a/tests/test-stabilize-order.t	Sun Feb 10 16:14:45 2013 +0100
+++ b/tests/test-stabilize-order.t	Mon Feb 11 10:46:38 2013 +0100
@@ -117,7 +117,7 @@
   o  0:c471ef929e6a@default(draft) addroot
   
   $ hg evolve -v
-  no troubled changeset
+  no troubled changesets
   [1]
 
 Test behaviour with --any
@@ -164,5 +164,5 @@
   o  0:c471ef929e6a@default(draft) addroot
   
   $ hg evolve --any -v
-  no troubled changeset
+  no troubled changesets
   [1]