5 """ |
5 """ |
6 from mercurial.i18n import _ |
6 from mercurial.i18n import _ |
7 from mercurial.node import nullid |
7 from mercurial.node import nullid |
8 from mercurial.lock import release |
8 from mercurial.lock import release |
9 from mercurial import cmdutil, hg, scmutil, util, error |
9 from mercurial import cmdutil, hg, scmutil, util, error |
10 from mercurial import repair, bookmarks, merge |
10 from mercurial import repair, bookmarks as bookmarksmod , merge |
11 |
11 |
12 cmdtable = {} |
12 cmdtable = {} |
13 command = cmdutil.command(cmdtable) |
13 command = cmdutil.command(cmdtable) |
14 # Note for extension authors: ONLY specify testedwith = 'internal' for |
14 # Note for extension authors: ONLY specify testedwith = 'internal' for |
15 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
15 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
60 hg.clean(repo, urev) |
60 hg.clean(repo, urev) |
61 repo.dirstate.write(repo.currenttransaction()) |
61 repo.dirstate.write(repo.currenttransaction()) |
62 |
62 |
63 repair.strip(ui, repo, revs, backup) |
63 repair.strip(ui, repo, revs, backup) |
64 |
64 |
65 marks = repo._bookmarks |
65 repomarks = repo._bookmarks |
66 if bookmark: |
66 if bookmark: |
67 if bookmark == repo._activebookmark: |
67 if bookmark == repo._activebookmark: |
68 bookmarks.deactivate(repo) |
68 bookmarksmod.deactivate(repo) |
69 del marks[bookmark] |
69 del repomarks[bookmark] |
70 marks.write() |
70 repomarks.write() |
71 ui.write(_("bookmark '%s' deleted\n") % bookmark) |
71 ui.write(_("bookmark '%s' deleted\n") % bookmark) |
72 finally: |
72 finally: |
73 release(lock, wlock) |
73 release(lock, wlock) |
74 |
74 |
75 |
75 |
125 revs = list(revs) + opts.get('rev') |
125 revs = list(revs) + opts.get('rev') |
126 revs = set(scmutil.revrange(repo, revs)) |
126 revs = set(scmutil.revrange(repo, revs)) |
127 |
127 |
128 wlock = repo.wlock() |
128 wlock = repo.wlock() |
129 try: |
129 try: |
130 if opts.get('bookmark'): |
130 bookmark = opts.get('bookmark') |
131 mark = opts.get('bookmark') |
131 if bookmark: |
132 marks = repo._bookmarks |
132 repomarks = repo._bookmarks |
133 if mark not in marks: |
133 if bookmark not in repomarks: |
134 raise error.Abort(_("bookmark '%s' not found") % mark) |
134 raise error.Abort(_("bookmark '%s' not found") % bookmark) |
135 |
135 |
136 # If the requested bookmark is not the only one pointing to a |
136 # If the requested bookmark is not the only one pointing to a |
137 # a revision we have to only delete the bookmark and not strip |
137 # a revision we have to only delete the bookmark and not strip |
138 # anything. revsets cannot detect that case. |
138 # anything. revsets cannot detect that case. |
139 uniquebm = True |
139 uniquebm = True |
140 for m, n in marks.iteritems(): |
140 for m, n in repomarks.iteritems(): |
141 if m != mark and n == repo[mark].node(): |
141 if m != bookmark and n == repo[bookmark].node(): |
142 uniquebm = False |
142 uniquebm = False |
143 break |
143 break |
144 if uniquebm: |
144 if uniquebm: |
145 rsrevs = repair.stripbmrevset(repo, mark) |
145 rsrevs = repair.stripbmrevset(repo, bookmark) |
146 revs.update(set(rsrevs)) |
146 revs.update(set(rsrevs)) |
147 if not revs: |
147 if not revs: |
148 del marks[mark] |
148 del repomarks[bookmark] |
149 marks.write() |
149 repomarks.write() |
150 ui.write(_("bookmark '%s' deleted\n") % mark) |
150 ui.write(_("bookmark '%s' deleted\n") % bookmark) |
151 |
151 |
152 if not revs: |
152 if not revs: |
153 raise error.Abort(_('empty revision set')) |
153 raise error.Abort(_('empty revision set')) |
154 |
154 |
155 descendants = set(cl.descendants(revs)) |
155 descendants = set(cl.descendants(revs)) |