[PATCH 2 of 6 OBSOLETE-MARKERS] obsolete: add an `obsolete` command to create obsolete marker

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat May 12 12:08:50 CDT 2012


# HG changeset patch
# User Pierre-Yves.David at ens-lyon.org
# Date 1336836697 -7200
# Node ID 42dd37168856ca2f3459ca29b318f0278bf68205
# Parent  b2cecf48226020c40d448617fc6d421c4e7f6cfe
obsolete: add an `obsolete` command to create obsolete marker

For now, This function add a simple obsolete marker. No remplacement, no flag,
no metadata.

In experimental version, this command was named "kill". I decided this was a
terrible name after forget "hg" in front of "hg kill" and destroyed my X server
a few times.

This command is mark as DEPRECATED because standard user do not want to run into
it for now. Activating a specific config option may be necessary to use it in
the future. When the whole obsolete markers business will be ready enough, this
command will be advertised to the end user.

diff -r b2cecf482260 -r 42dd37168856 mercurial/commands.py
--- a/mercurial/commands.py	Sat May 12 17:21:32 2012 +0200
+++ b/mercurial/commands.py	Sat May 12 17:31:37 2012 +0200
@@ -4170,6 +4170,28 @@
     finally:
         ui.setconfig('ui', 'forcemerge', '')
 
+ at command('obsolete',
+    [('r', 'rev', [], _('mark given revision as obsolete'), _('REV')),
+    ],
+    _('[--rev] REV'))
+def obsolete(ui, repo, *revs, **opts):
+    """mark a changeset as obsolete (DEPRECATED)"""
+    revs = list(revs)
+    revs.extend(opts['rev'])
+    revs = scmutil.revrange(repo, revs)
+    if not revs:
+        raise util.Abort(_('no revisions specified'))
+
+    l = repo.lock()
+    try:
+        for obs in revs:
+            marker = (repo[obs].node(), (), 0, '')
+            repo.obsstore.add(marker)
+    finally:
+        l.release()
+
+
+
 @command('outgoing|out',
     [('f', 'force', None, _('run even when the destination is unrelated')),
     ('r', 'rev', [],
diff -r b2cecf482260 -r 42dd37168856 tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t	Sat May 12 17:21:32 2012 +0200
+++ b/tests/test-debugcomplete.t	Sat May 12 17:31:37 2012 +0200
@@ -29,6 +29,7 @@
   log
   manifest
   merge
+  obsolete
   outgoing
   parents
   paths
@@ -256,6 +257,7 @@
   incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
   locate: rev, print0, fullpath, include, exclude
   manifest: rev, all
+  obsolete: rev
   outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
   parents: rev, style, template
   paths: 
diff -r b2cecf482260 -r 42dd37168856 tests/test-obsolete.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-obsolete.t	Sat May 12 17:31:37 2012 +0200
@@ -0,0 +1,17 @@
+
+  $ mkcommit() {
+  >    echo "$1" > "$1"
+  >    hg add "$1"
+  >    hg ci -m "add $1"
+  > }
+
+  $ hg init tmpa
+  $ cd tmpa
+
+Killing a single changeset without replacement
+
+  $ mkcommit kill_me
+  $ hg obsolete
+  abort: no revisions specified
+  [255]
+  $ hg obsolete "desc('kill_me')"


More information about the Mercurial-devel mailing list