Mercurial > hg-stable
changeset 33351:154298576d44
histedit: use scmutil.cleanupnodes (BC)
This is marked as BC because the strip backup file name has changed.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sat, 08 Jul 2017 16:50:31 -0700 |
parents | b320ff822c7e |
children | 967ac37f3d45 |
files | hgext/histedit.py tests/test-histedit-arguments.t tests/test-histedit-bookmark-motion.t tests/test-histedit-commute.t tests/test-histedit-edit.t tests/test-histedit-fold.t |
diffstat | 6 files changed, 16 insertions(+), 72 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Sat Jul 08 16:50:31 2017 -0700 +++ b/hgext/histedit.py Sat Jul 08 16:50:31 2017 -0700 @@ -1173,7 +1173,7 @@ if not state.keep: if mapping: - movebookmarks(ui, repo, mapping, state.topmost, ntm) + movetopmostbookmarks(repo, state.topmost, ntm) # TODO update mq state else: mapping = {} @@ -1181,7 +1181,11 @@ for n in tmpnodes: mapping[n] = () - safecleanupnode(ui, repo, mapping) + # remove entries about unknown nodes + nodemap = repo.unfiltered().changelog.nodemap + mapping = {k: v for k, v in mapping.items() + if k in nodemap and all(n in nodemap for n in v)} + scmutil.cleanupnodes(repo, mapping, 'histedit') state.clear() if os.path.exists(repo.sjoin('undo')): @@ -1561,38 +1565,6 @@ marks[name] = newtopmost marks.recordchange(tr) -def movebookmarks(ui, repo, mapping, oldtopmost, newtopmost): - """Move bookmark from old to newly created node""" - if not mapping: - # if nothing got rewritten there is not purpose for this function - return - movetopmostbookmarks(repo, oldtopmost, newtopmost) - moves = [] - for bk, old in sorted(repo._bookmarks.iteritems()): - base = old - new = mapping.get(base, None) - if new is None: - continue - while not new: - # base is killed, trying with parent - base = repo[base].p1().node() - new = mapping.get(base, (base,)) - # nothing to move - moves.append((bk, new[-1])) - if moves: - lock = tr = None - try: - lock = repo.lock() - tr = repo.transaction('histedit') - marks = repo._bookmarks - for mark, new in moves: - old = marks[mark] - marks[mark] = new - marks.recordchange(tr) - tr.close() - finally: - release(tr, lock) - def cleanupnode(ui, repo, nodes): """strip a group of nodes from the repository @@ -1610,34 +1582,6 @@ if roots: repair.strip(ui, repo, roots) -def safecleanupnode(ui, repo, nodes): - """strip or obsolete nodes - - nodes could be either a set or dict which maps to replacements. - nodes could be unknown (outside the repo). - """ - supportsmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt) - if supportsmarkers: - if util.safehasattr(nodes, 'get'): - # nodes is a dict-like mapping - # use unfiltered repo for successors in case they are hidden - urepo = repo.unfiltered() - def getmarker(prec): - succs = tuple(urepo[n] for n in nodes.get(prec, ())) - return (repo[prec], succs) - else: - # nodes is a set-like - def getmarker(prec): - return (repo[prec], ()) - # sort by revision number because it sound "right" - sortednodes = sorted([n for n in nodes if n in repo], - key=repo.changelog.rev) - markers = [getmarker(t) for t in sortednodes] - if markers: - obsolete.createmarkers(repo, markers, operation='histedit') - else: - return cleanupnode(ui, repo, nodes) - def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): if isinstance(nodelist, str): nodelist = [nodelist]
--- a/tests/test-histedit-arguments.t Sat Jul 08 16:50:31 2017 -0700 +++ b/tests/test-histedit-arguments.t Sat Jul 08 16:50:31 2017 -0700 @@ -147,7 +147,7 @@ $ mv .hg/histedit-state.back .hg/histedit-state $ hg histedit --continue - saved backup bundle to $TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-backup.hg (glob) + saved backup bundle to $TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg (glob) $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2:: @ 4 f5ed five | @@ -157,7 +157,7 @@ | ~ - $ hg unbundle -q $TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-backup.hg + $ hg unbundle -q $TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg $ hg strip -q -r f5ed --config extensions.strip= $ hg up -q 08d98a8350f3 @@ -264,7 +264,7 @@ HG: user: test HG: branch 'default' HG: changed alpha - saved backup bundle to $TESTTMP/foo/.hg/strip-backup/*-backup.hg (glob) + saved backup bundle to $TESTTMP/foo/.hg/strip-backup/c8e68270e35a-63d8b8d8-histedit.hg (glob) $ hg update -q 2 $ echo x > x
--- a/tests/test-histedit-bookmark-motion.t Sat Jul 08 16:50:31 2017 -0700 +++ b/tests/test-histedit-bookmark-motion.t Sat Jul 08 16:50:31 2017 -0700 @@ -87,7 +87,7 @@ > fold e860deea161a 4 e > pick 652413bf663e 5 f > EOF - saved backup bundle to $TESTTMP/r/.hg/strip-backup/96e494a2d553-45c027ab-backup.hg (glob) + saved backup bundle to $TESTTMP/r/.hg/strip-backup/96e494a2d553-45c027ab-histedit.hg (glob) $ hg log --graph @ changeset: 3:cacdfd884a93 | bookmark: five @@ -141,7 +141,7 @@ > pick cacdfd884a93 3 f > pick 59d9f330561f 2 d > EOF - saved backup bundle to $TESTTMP/r/.hg/strip-backup/59d9f330561f-073008af-backup.hg (glob) + saved backup bundle to $TESTTMP/r/.hg/strip-backup/59d9f330561f-073008af-histedit.hg (glob) We expect 'five' to stay at tip, since the tipmost bookmark is most likely the useful signal.
--- a/tests/test-histedit-commute.t Sat Jul 08 16:50:31 2017 -0700 +++ b/tests/test-histedit-commute.t Sat Jul 08 16:50:31 2017 -0700 @@ -417,7 +417,7 @@ > EOF $ HGEDITOR="sh ./editor.sh" hg histedit 0 - saved backup bundle to $TESTTMP/issue4251/.hg/strip-backup/*-backup.hg (glob) + saved backup bundle to $TESTTMP/issue4251/.hg/strip-backup/b0f4233702ca-4cf5af69-histedit.hg (glob) $ hg --config diff.git=yes export 0 # HG changeset patch
--- a/tests/test-histedit-edit.t Sat Jul 08 16:50:31 2017 -0700 +++ b/tests/test-histedit-edit.t Sat Jul 08 16:50:31 2017 -0700 @@ -273,7 +273,7 @@ HG: user: test HG: branch 'default' HG: added f - saved backup bundle to $TESTTMP/r/.hg/strip-backup/b5f70786f9b0-c28d9c86-backup.hg (glob) + saved backup bundle to $TESTTMP/r/.hg/strip-backup/b5f70786f9b0-c28d9c86-histedit.hg (glob) $ hg status @@ -437,7 +437,7 @@ (hg histedit --continue to resume) [1] $ HGEDITOR=true hg histedit --continue - saved backup bundle to $TESTTMP/r0/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob) + saved backup bundle to $TESTTMP/r0/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-histedit.hg (glob) $ hg log -G @ changeset: 0:0efcea34f18a
--- a/tests/test-histedit-fold.t Sat Jul 08 16:50:31 2017 -0700 +++ b/tests/test-histedit-fold.t Sat Jul 08 16:50:31 2017 -0700 @@ -305,7 +305,7 @@ continue: hg histedit --continue $ hg histedit --continue 251d831eeec5: empty changeset - saved backup bundle to $TESTTMP/*-backup.hg (glob) + saved backup bundle to $TESTTMP/fold-to-empty-test/.hg/strip-backup/888f9082bf99-daa0b8b3-histedit.hg (glob) $ hg logt --graph @ 1:617f94f13c0f +4 | @@ -382,7 +382,7 @@ HG: user: test HG: branch 'default' HG: changed file - saved backup bundle to $TESTTMP/fold-with-dropped/.hg/strip-backup/617f94f13c0f-3d69522c-backup.hg (glob) + saved backup bundle to $TESTTMP/fold-with-dropped/.hg/strip-backup/617f94f13c0f-3d69522c-histedit.hg (glob) $ hg logt -G @ 1:10c647b2cdd5 +4 |