Mercurial > public > mercurial-scm > hg
comparison mercurial/repair.py @ 17264:ec7b9bec19c9 stable
strip: move bookmarks to nearest ancestor rather than '.'
If you've got this graph:
0-1-2
\
3
and 3 is checked out, 2 is bookmarked with "broken", and you do "hg
strip 2", the bookmark will move to 3, not 1. That's always struck me
as a bug.
This change makes bookmarks move to the tipmost ancestor of
the stripped set rather than the currently-checked-out revision, which
is what I always expected should happen.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Thu, 26 Jul 2012 16:57:50 -0500 |
parents | c8eda7bbdcab |
children | 7c865f30e2b8 |
comparison
equal
deleted
inserted
replaced
17263:c4ebdc36c17e | 17264:ec7b9bec19c9 |
---|---|
109 if saverevs: | 109 if saverevs: |
110 descendants = set(cl.descendants(saverevs)) | 110 descendants = set(cl.descendants(saverevs)) |
111 saverevs.difference_update(descendants) | 111 saverevs.difference_update(descendants) |
112 savebases = [cl.node(r) for r in saverevs] | 112 savebases = [cl.node(r) for r in saverevs] |
113 stripbases = [cl.node(r) for r in tostrip] | 113 stripbases = [cl.node(r) for r in tostrip] |
114 rset = ' or '.join([str(r) for r in tostrip]) | |
115 newbmtarget = repo.revs('sort(heads(ancestors(%r) - (%r)), -rev)', | |
116 rset, rset) | |
117 if newbmtarget: | |
118 newbmtarget = newbmtarget[0] | |
119 else: | |
120 newbmtarget = '.' | |
114 | 121 |
115 bm = repo._bookmarks | 122 bm = repo._bookmarks |
116 updatebm = [] | 123 updatebm = [] |
117 for m in bm: | 124 for m in bm: |
118 rev = repo[bm[m]].rev() | 125 rev = repo[bm[m]].rev() |
172 except OSError, e: | 179 except OSError, e: |
173 if e.errno != errno.ENOENT: | 180 if e.errno != errno.ENOENT: |
174 ui.warn(_('error removing %s: %s\n') % (undofile, str(e))) | 181 ui.warn(_('error removing %s: %s\n') % (undofile, str(e))) |
175 | 182 |
176 for m in updatebm: | 183 for m in updatebm: |
177 bm[m] = repo['.'].node() | 184 bm[m] = repo[newbmtarget].node() |
178 bookmarks.write(repo) | 185 bookmarks.write(repo) |
179 except: # re-raises | 186 except: # re-raises |
180 if backupfile: | 187 if backupfile: |
181 ui.warn(_("strip failed, full bundle stored in '%s'\n") | 188 ui.warn(_("strip failed, full bundle stored in '%s'\n") |
182 % backupfile) | 189 % backupfile) |
190 repo.destroyed(newheadnodes) | 197 repo.destroyed(newheadnodes) |
191 else: | 198 else: |
192 # Multiple branches involved in strip. Will allow branchcache to become | 199 # Multiple branches involved in strip. Will allow branchcache to become |
193 # invalid and later on rebuilt from scratch | 200 # invalid and later on rebuilt from scratch |
194 repo.destroyed() | 201 repo.destroyed() |
195 |