[PATCH] export: add -B option to select a bookmark
David Demelier
markand at malikania.fr
Mon May 14 11:01:26 UTC 2018
# HG changeset patch
# User David Demelier <markand at malikania.fr>
# Date 1526295193 -7200
# Mon May 14 12:53:13 2018 +0200
# Node ID 870851c118b003e60a574670fc603b4780609c3b
# Parent 8ba0344f9fb145f5b9b909f1211defc9e0793f68
export: add -B option to select a bookmark
Just like `hg email -B`, `hg strip -B`, supports -B in export to select a list
of changesets reachable from a bookmark.
diff -r 8ba0344f9fb1 -r 870851c118b0 mercurial/commands.py
--- a/mercurial/commands.py Fri May 11 22:07:43 2018 -0400
+++ b/mercurial/commands.py Mon May 14 12:53:13 2018 +0200
@@ -50,6 +50,7 @@
pycompat,
rcutil,
registrar,
+ repair,
revsetlang,
rewriteutil,
scmutil,
@@ -1895,7 +1896,8 @@
root=opts.get('root'))
@command('^export',
- [('o', 'output', '',
+ [('B', 'bookmark', '', _('send changes only reachable by given bookmark')),
+ ('o', 'output', '',
_('print output to file with formatted name'), _('FORMAT')),
('', 'switch-parent', None, _('diff against the second parent')),
('r', 'rev', [], _('revisions to export'), _('REV')),
@@ -1938,6 +1940,9 @@
of files it detects as binary. With -a, export will generate a
diff anyway, probably with undesirable results.
+ With -B/--bookmark changesets reachable by the given bookmark are
+ selected.
+
Use the -g/--git option to generate diffs in the git extended diff
format. See :hg:`help diffs` for more information.
@@ -1966,7 +1971,18 @@
Returns 0 on success.
"""
opts = pycompat.byteskwargs(opts)
- changesets += tuple(opts.get('rev', []))
+ rev = opts.get('rev')
+ bookmark = opts.get('bookmark')
+
+ if bookmark and rev:
+ raise error.Abort(_("-r and -B are mutually exclusive"))
+ if rev:
+ changesets += tuple(opts.get('rev', []))
+ elif bookmark:
+ if bookmark not in repo._bookmarks:
+ raise error.Abort(_("bookmark '%s' not found") % bookmark)
+ changesets += tuple(repair.stripbmrevset(repo, bookmark))
+
if not changesets:
changesets = ['.']
repo = scmutil.unhidehashlikerevs(repo, changesets, 'nowarn')
diff -r 8ba0344f9fb1 -r 870851c118b0 tests/test-export.t
--- a/tests/test-export.t Fri May 11 22:07:43 2018 -0400
+++ b/tests/test-export.t Mon May 14 12:53:13 2018 +0200
@@ -101,6 +101,44 @@
$ grep HG foo-foo_3.patch | wc -l
\s*1 (re)
+Using bookmarks:
+
+ $ hg book -f -r 9 @
+ $ hg book -f -r 11 test
+ $ hg export -B test
+ # HG changeset patch
+ # User test
+ # Date 0 0
+ # Thu Jan 01 00:00:00 1970 +0000
+ # Node ID 5f17a83f5fbd9414006a5e563eab4c8a00729efd
+ # Parent 747d3c68f8ec44bb35816bfcd59aeb50b9654c2f
+ foo-10
+
+ diff -r 747d3c68f8ec -r 5f17a83f5fbd foo
+ --- a/foo Thu Jan 01 00:00:00 1970 +0000
+ +++ b/foo Thu Jan 01 00:00:00 1970 +0000
+ @@ -8,3 +8,4 @@
+ foo-7
+ foo-8
+ foo-9
+ +foo-10
+ # HG changeset patch
+ # User test
+ # Date 0 0
+ # Thu Jan 01 00:00:00 1970 +0000
+ # Node ID f3acbafac161ec68f1598af38f794f28847ca5d3
+ # Parent 5f17a83f5fbd9414006a5e563eab4c8a00729efd
+ foo-11
+
+ diff -r 5f17a83f5fbd -r f3acbafac161 foo
+ --- a/foo Thu Jan 01 00:00:00 1970 +0000
+ +++ b/foo Thu Jan 01 00:00:00 1970 +0000
+ @@ -9,3 +9,4 @@
+ foo-8
+ foo-9
+ foo-10
+ +foo-11
+
Exporting 4 changesets to a file:
$ hg export -o export_internal 1 2 3 4
More information about the Mercurial-devel
mailing list