# HG changeset patch # User Laurent Charignon # Date 1453854671 28800 # Tue Jan 26 16:31:11 2016 -0800 # Node ID 6dd477f76ca35ae46e82972648735867cf335d3e # Parent 7245aa2af52d09ba551ecfd26b5dfde8db42fa03 gitlikebookmark: remove test and extension Summary: This feature does not work well with inhibit, since we didn't ship it let's remove it as the test is noisy. Test Plan: N/A Reviewers: #sourcecontrol, durham, ttung Differential Revision: https://phabricator.fb.com/D2868095 diff --git a/gitlikebookmarks.py b/gitlikebookmarks.py deleted file mode 100644 --- a/gitlikebookmarks.py +++ /dev/null @@ -1,74 +0,0 @@ -# gitlikebookmarks.py - add git like behavior for bookmarks -# -# Copyright 2015 Facebook, Inc. -# -# This software may be used and distributed according to the terms of the -# GNU General Public License version 2 or any later version. - -"""add git like behavior for bookmarks: only move the active bookmark - -Add a -x specified to several commands. When the -x flag is specied, the -commands only allow the active bookmark to move. -""" - -from mercurial import extensions -from mercurial import bookmarks -from mercurial import util -from mercurial.i18n import _ - -gitlikebookmarkscommands = ( - # module name, command name - ('rebase', 'rebase'), - ('histedit', 'histedit'), -) -def _bookmarkwrite(orig, bkmstoreinst, *args, **kwargs): - repo = bkmstoreinst._repo - activebook = None - bookmarksbefore = None - - if util.safehasattr(bkmstoreinst, "oldactivebookmark"): - activebook = bkmstoreinst.oldactivebookmark - bookmarksbefore = bkmstoreinst.oldbookmarks - - if activebook is not None: - override = [] - for book in bkmstoreinst: - if book == activebook: - continue - override.append(book) - for k in override: - if k in bookmarksbefore: - bkmstoreinst[k] = bookmarksbefore[k] - if repo._activebookmark != activebook: - bookmarks.activate(repo, activebook) - - # XXX will be an issue with chg, -x will persist accross commands - # Possible fixes: - # 1) setting activebook to None here would only work - # for commands with a single transaction (we have no guarantee of that) - # 2) put all this code in _wrapfn and wrap the call to orig(...) in a - # transaction but it will rollback if rebase/histedit has conflicts (not - # intended behavior as we want to leave the conflicts in the workdir) - return orig(bkmstoreinst, *args, **kwargs) - -def _wrapfn(orig, ui, repo, *args, **kwargs): - # Normal behavior unless -x is specified - if not kwargs.get('stickybookmark'): - return orig(ui, repo, *args, **kwargs) - repo._bookmarks.oldactivebookmark = repo._bookmarks.active - repo._bookmarks.oldbookmarks = repo._bookmarks.copy() - return orig(ui, repo, *args, **kwargs) - -def extsetup(ui): - extensions.wrapfunction(bookmarks.bmstore, '_write', _bookmarkwrite) - for module, fn in gitlikebookmarkscommands: - try: - ext = extensions.find(module) - if ext: - entry = extensions.wrapcommand(ext.cmdtable, fn, _wrapfn) - entry[1].append(('x','stickybookmark', None, - _('only allow the active bookmark to move' - ' during the operation'))) - except KeyError: - # Extension not present - pass diff --git a/tests/test-gitlikebookmarks.t b/tests/test-gitlikebookmarks.t deleted file mode 100644 --- a/tests/test-gitlikebookmarks.t +++ /dev/null @@ -1,96 +0,0 @@ - $ $PYTHON -c 'import evolve' || exit 80 - $ cat >> $HGRCPATH << EOF - > [extensions] - > gitlikebookmarks=$TESTDIR/../gitlikebookmarks.py - > rebase= - > evolve= - > inhibit= - > directaccess= - > [experimental] - > evolution=createmarkers - > EOF - $ mkcommit() { - > echo "$1" > "$1" - > hg add "$1" - > echo "add $1" > msg - > echo "" >> msg - > [ -z "$2" ] || echo "Differential Revision: https://phabricator.fb.com/D$2" >> msg - > hg ci -l msg - > } - - $ hg init repo - $ cd repo - $ mkcommit _a - $ mkcommit _b - $ hg up "desc(_a)" - 0 files updated, 0 files merged, 1 files removed, 0 files unresolved - $ mkcommit _c - created new head - $ hg book first_bookmark - $ hg book second_bookmark - $ mkcommit _d - $ hg log -G - @ changeset: 3:3d974c2713ca - | bookmark: second_bookmark - | tag: tip - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add _d - | - o changeset: 2:1db8f42448cc - | bookmark: first_bookmark - | parent: 0:135f39f4bd78 - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add _c - | - | o changeset: 1:37445b16603b - |/ user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add _b - | - o changeset: 0:135f39f4bd78 - user: test - date: Thu Jan 01 00:00:00 1970 +0000 - summary: add _a - - $ hg bookmarks - first_bookmark 2:1db8f42448cc - * second_bookmark 3:3d974c2713ca - $ hg rebase -s "desc(_c)" -d "desc(_b)" -x - rebasing 2:1db8f42448cc "add _c" (first_bookmark) - rebasing 3:3d974c2713ca "add _d" (tip second_bookmark) - $ hg log -G - @ changeset: 5:15f1a0e15dd8 - | bookmark: second_bookmark - | tag: tip - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add _d - | - o changeset: 4:da71b5c6dbab - | parent: 1:37445b16603b - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add _c - | - | o changeset: 2:1db8f42448cc - | | bookmark: first_bookmark - | | parent: 0:135f39f4bd78 - | | user: test - | | date: Thu Jan 01 00:00:00 1970 +0000 - | | summary: add _c - | | - o | changeset: 1:37445b16603b - |/ user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: add _b - | - o changeset: 0:135f39f4bd78 - user: test - date: Thu Jan 01 00:00:00 1970 +0000 - summary: add _a - - $ hg bookmarks - first_bookmark 2:1db8f42448cc - * second_bookmark 5:15f1a0e15dd8