Submitter | David Soria Parra |
---|---|
Date | July 8, 2014, 11:26 p.m. |
Message ID | <4006d4f3cfa71a300b71.1404861974@dev544.prn1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/5135/ |
State | Accepted |
Commit | 3278818912ea64cdc206a686688da692921ce6e1 |
Headers | show |
Comments
On Tue, Jul 08, 2014 at 04:26:14PM -0700, David Soria Parra wrote: > # HG changeset patch > # User David Soria Parra <davidsp@fb.com> > # Date 1404861863 25200 > # Tue Jul 08 16:24:23 2014 -0700 > # Node ID 4006d4f3cfa71a300b71b501d587ea13a7065eb9 > # Parent 61b333b982ea7baab198a188306fc05fb2850179 > strip: remove bookmarks after strip succeed (issue4295) > queued, thanks > > In case we have revs to strip, delete the bookmark after the strip succeeds, not > beforehand as we might still abort due to dirty working directory, etc. > > diff --git a/hgext/strip.py b/hgext/strip.py > --- a/hgext/strip.py > +++ b/hgext/strip.py > @@ -42,7 +42,7 @@ > raise util.Abort(_("local changed subrepos found" + excsuffix)) > return m, a, r, d > > -def strip(ui, repo, revs, update=True, backup="all", force=None): > +def strip(ui, repo, revs, update=True, backup="all", force=None, bookmark=None): > wlock = lock = None > try: > wlock = repo.wlock() > @@ -59,6 +59,14 @@ > repo.dirstate.write() > > repair.strip(ui, repo, revs, backup) > + > + marks = repo._bookmarks > + if bookmark: > + if bookmark == repo._bookmarkcurrent: > + bookmarks.unsetcurrent(repo) > + del marks[bookmark] > + marks.write() > + ui.write(_("bookmark '%s' deleted\n") % bookmark) > finally: > release(lock, wlock) > > @@ -205,15 +213,9 @@ > repo.dirstate.write() > update = False > > - if opts.get('bookmark'): > - if mark == repo._bookmarkcurrent: > - bookmarks.unsetcurrent(repo) > - del marks[mark] > - marks.write() > - ui.write(_("bookmark '%s' deleted\n") % mark) > > strip(ui, repo, revs, backup=backup, update=update, > - force=opts.get('force')) > + force=opts.get('force'), bookmark=opts.get('bookmark')) > finally: > wlock.release() > > diff --git a/tests/test-strip.t b/tests/test-strip.t > --- a/tests/test-strip.t > +++ b/tests/test-strip.t > @@ -496,9 +496,9 @@ > abort: empty revision set > [255] > $ hg strip -B todelete > - bookmark 'todelete' deleted > 0 files updated, 0 files merged, 0 files removed, 0 files unresolved > saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) > + bookmark 'todelete' deleted > $ hg id -ir dcbb326fdec2 > abort: unknown revision 'dcbb326fdec2'! > [255] > @@ -508,10 +508,20 @@ > B 9:ff43616e5d0f > delete 6:2702dd0c91e7 > $ hg strip -B delete > + saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) > bookmark 'delete' deleted > - saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) > $ hg id -ir 6:2702dd0c91e7 > abort: unknown revision '2702dd0c91e7'! > [255] > + $ hg update B > + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved > + (activating bookmark B) > + $ echo a > a > + $ hg add a > + $ hg strip -B B > + abort: local changes found > + [255] > + $ hg bookmarks > + * B 6:ff43616e5d0f > > $ cd .. > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/hgext/strip.py b/hgext/strip.py --- a/hgext/strip.py +++ b/hgext/strip.py @@ -42,7 +42,7 @@ raise util.Abort(_("local changed subrepos found" + excsuffix)) return m, a, r, d -def strip(ui, repo, revs, update=True, backup="all", force=None): +def strip(ui, repo, revs, update=True, backup="all", force=None, bookmark=None): wlock = lock = None try: wlock = repo.wlock() @@ -59,6 +59,14 @@ repo.dirstate.write() repair.strip(ui, repo, revs, backup) + + marks = repo._bookmarks + if bookmark: + if bookmark == repo._bookmarkcurrent: + bookmarks.unsetcurrent(repo) + del marks[bookmark] + marks.write() + ui.write(_("bookmark '%s' deleted\n") % bookmark) finally: release(lock, wlock) @@ -205,15 +213,9 @@ repo.dirstate.write() update = False - if opts.get('bookmark'): - if mark == repo._bookmarkcurrent: - bookmarks.unsetcurrent(repo) - del marks[mark] - marks.write() - ui.write(_("bookmark '%s' deleted\n") % mark) strip(ui, repo, revs, backup=backup, update=update, - force=opts.get('force')) + force=opts.get('force'), bookmark=opts.get('bookmark')) finally: wlock.release() diff --git a/tests/test-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -496,9 +496,9 @@ abort: empty revision set [255] $ hg strip -B todelete - bookmark 'todelete' deleted 0 files updated, 0 files merged, 0 files removed, 0 files unresolved saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) + bookmark 'todelete' deleted $ hg id -ir dcbb326fdec2 abort: unknown revision 'dcbb326fdec2'! [255] @@ -508,10 +508,20 @@ B 9:ff43616e5d0f delete 6:2702dd0c91e7 $ hg strip -B delete + saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) bookmark 'delete' deleted - saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) $ hg id -ir 6:2702dd0c91e7 abort: unknown revision '2702dd0c91e7'! [255] + $ hg update B + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark B) + $ echo a > a + $ hg add a + $ hg strip -B B + abort: local changes found + [255] + $ hg bookmarks + * B 6:ff43616e5d0f $ cd ..