changeset 716:4c0f6d555032 stable

prune: add --user and --date options They control the metadata writen to the obsolescence marker.
author Levi Bard <levi@unity3d.com>
date Mon, 11 Feb 2013 09:21:22 +0000
parents 070bbbb0e6f2
children cdb52bbbe5b8
files README hgext/evolve.py tests/test-prune.t
diffstat 3 files changed, 35 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/README	Mon Feb 11 09:21:11 2013 +0000
+++ b/README	Mon Feb 11 09:21:22 2013 +0000
@@ -53,6 +53,7 @@
 - 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	Mon Feb 11 09:21:11 2013 +0000
+++ b/hgext/evolve.py	Mon Feb 11 09:21:22 2013 +0000
@@ -829,6 +829,13 @@
 #############################
 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|solve',
     [('n', 'dry-run', False, 'do not perform actions, print what to be done'),
@@ -1272,15 +1279,26 @@
     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")),
      ('B', 'bookmark', '', _("remove revs only reachable from given"
-                             " bookmark"))],
+                             " 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
@@ -1299,6 +1317,7 @@
     revs = set(scmutil.revrange(repo, list(revs) + opts.get('rev')))
     succs = opts['new'] + opts['succ']
     bookmark = opts.get('bookmark')
+    metadata = _getmetadata(**opts)
 
     if bookmark:
         marks,revs = _reachablefrombookmark(repo, revs, bookmark)
@@ -1332,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
@@ -1383,6 +1403,7 @@
 
     # determine updates to subsume
     old = scmutil.revsingle(repo, '.')
+    metadata = _getmetadata(**opts)
 
     lock = repo.lock()
     try:
--- a/tests/test-prune.t	Mon Feb 11 09:21:11 2013 +0000
+++ b/tests/test-prune.t	Mon Feb 11 09:21:22 2013 +0000
@@ -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)