--- a/mercurial/commands.py Wed Mar 09 10:47:33 2016 -0500
+++ b/mercurial/commands.py Tue Apr 12 03:40:53 2016 -0700
@@ -3063,29 +3063,22 @@
'node identifiers')
if opts.get('delete'):
- try:
- indices = [int(v) for v in opts.get('delete')]
- except ValueError:
- raise error.Abort(_('invalid index value'),
- hint=_('use integers fro indices'))
+ indices = []
+ for v in opts.get('delete'):
+ try:
+ indices.append(int(v))
+ except ValueError:
+ raise error.Abort(_('invalid index value: %r') % v,
+ hint=_('use integers for indices'))
if repo.currenttransaction():
- raise error.Abort(_('Cannot delete obsmarkers in the middle '
+ raise error.Abort(_('cannot delete obsmarkers in the middle '
'of transaction.'))
- w = repo.wlock()
- l = repo.lock()
- try:
- tr = repo.transaction('debugobsolete')
- try:
- n = repo.obsstore.delete(indices)
- ui.write(_('Deleted %i obsolescense markers\n') % n)
- tr.close()
- finally:
- tr.release()
- finally:
- l.release()
- w.release()
+ with repo.lock():
+ n = repo.obsstore.delete(indices)
+ ui.write(_('deleted %i obsolescense markers\n') % n)
+
return
if precursor is not None:
--- a/mercurial/obsolete.py Wed Mar 09 10:47:33 2016 -0500
+++ b/mercurial/obsolete.py Tue Apr 12 03:40:53 2016 -0700
@@ -629,7 +629,7 @@
return len(new)
def delete(self, indices):
- """Delete some obsmarkers from store and return the number of them
+ """Delete some obsmarkers from store and return how many were deleted
Indices is a list of ints which are the indices
of the markers to be deleted."""
--- a/tests/test-obsolete.t Wed Mar 09 10:47:33 2016 -0500
+++ b/tests/test-obsolete.t Tue Apr 12 03:40:53 2016 -0700
@@ -1106,18 +1106,17 @@
$ hg debugobsolete --index --rev "3+7"
1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 \(.*\) {'user': 'test'} (re)
3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 \(.*\) {'user': 'test'} (re)
- $ cd ..
- $ cd ..
Test the --delete option of debugobsolete command
- $ hg init dorepo
- $ cd dorepo
- $ echo a > a && hg ci -Am a
- adding a
- $ hg ci --amend -m aa
+ $ hg debugobsolete --index
+ 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 \(.*\) {'user': 'test'} (re)
+ 1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 \(.*\) {'user': 'test'} (re)
+ 2 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 \(.*\) {'user': 'test'} (re)
+ 3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 \(.*\) {'user': 'test'} (re)
+ $ hg debugobsolete --delete 1 --delete 3
+ deleted 2 obsolescense markers
$ hg debugobsolete
- cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (.*) {'user': 'test'} (re)
- $ hg debugobsolete --delete 0
- Deleted 1 obsolescense markers
- $ hg debugobsolete
+ cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 \(.*\) {'user': 'test'} (re)
+ 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 \(.*\) {'user': 'test'} (re)
$ cd ..
+