hgext/bookmarks.py
author Matt Mackall <mpm@selenic.com>
Thu, 10 Feb 2011 13:46:28 -0600
changeset 13364 ddddb76f2da3
parent 13363 999f616b09dc
child 13365 f1c5294e9119
permissions -rw-r--r--
bookmarks: merge low-level push/pull support into core
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
     1
# Mercurial extension to provide the 'hg bookmark' command
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
     2
#
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
     3
# Copyright 2008 David Soria Parra <dsp@php.net>
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
     4
#
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8087
diff changeset
     5
# This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9643
diff changeset
     6
# GNU General Public License version 2 or any later version.
7252
104a8324798e bookmarks: Avoid long lines
Joel Rosdahl <joel@rosdahl.net>
parents: 7251
diff changeset
     7
8894
868670dbc237 extensions: improve the consistency of synopses
Cédric Duval <cedricduval@free.fr>
parents: 8892
diff changeset
     8
'''track a line of development with movable markers
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
     9
9251
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    10
Bookmarks are local movable markers to changesets. Every bookmark
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    11
points to a changeset identified by its hash. If you commit a
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    12
changeset that is based on a changeset that has a bookmark on it, the
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    13
bookmark shifts to the new changeset.
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    14
11193
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 10973
diff changeset
    15
It is possible to use bookmark names in every revision lookup (e.g.
687c7d395f20 Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents: 10973
diff changeset
    16
:hg:`merge`, :hg:`update`).
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
    17
9251
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    18
By default, when several bookmarks point to the same changeset, they
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    19
will all move forward together. It is possible to obtain a more
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    20
git-like experience by adding the following configuration option to
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 12026
diff changeset
    21
your configuration file::
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
    22
8892
30b25ebaa63b bookmarks: help improvements
Cédric Duval <cedricduval@free.fr>
parents: 8862
diff changeset
    23
  [bookmarks]
30b25ebaa63b bookmarks: help improvements
Cédric Duval <cedricduval@free.fr>
parents: 8862
diff changeset
    24
  track.current = True
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
    25
9251
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    26
This will cause Mercurial to track the bookmark that you are currently
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    27
using, and only update it. This is similar to git's approach to
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    28
branching.
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    29
'''
7252
104a8324798e bookmarks: Avoid long lines
Joel Rosdahl <joel@rosdahl.net>
parents: 7251
diff changeset
    30
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    31
from mercurial.i18n import _
12714
f5178fbcd197 bookmarks: add revset for referencing bookmarks
Augie Fackler <durin42@gmail.com>
parents: 12394
diff changeset
    32
from mercurial.node import nullid, nullrev, bin, hex, short
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
    33
from mercurial import util, commands, repair, extensions, pushkey, hg, url
13359
87f248e78173 bookmarks: move revset support to core
Matt Mackall <mpm@selenic.com>
parents: 13358
diff changeset
    34
from mercurial import encoding
13350
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
    35
from mercurial import bookmarks
7638
f83a2b1d1a71 bookmarks; clean up imports and function wrapping
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
    36
import os
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    37
7255
69e431ea124d bookmarks: Rename --move to --rename
Joel Rosdahl <joel@rosdahl.net>
parents: 7254
diff changeset
    38
def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, rename=None):
8894
868670dbc237 extensions: improve the consistency of synopses
Cédric Duval <cedricduval@free.fr>
parents: 8892
diff changeset
    39
    '''track a line of development with movable markers
7250
352627bcafc3 bookmarks: Remove trailing space
Joel Rosdahl <joel@rosdahl.net>
parents: 7239
diff changeset
    40
9251
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    41
    Bookmarks are pointers to certain commits that move when
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    42
    committing. Bookmarks are local. They can be renamed, copied and
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10956
diff changeset
    43
    deleted. It is possible to use bookmark names in :hg:`merge` and
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10956
diff changeset
    44
    :hg:`update` to merge and update respectively to a given bookmark.
7250
352627bcafc3 bookmarks: Remove trailing space
Joel Rosdahl <joel@rosdahl.net>
parents: 7239
diff changeset
    45
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10956
diff changeset
    46
    You can use :hg:`bookmark NAME` to set a bookmark on the working
9251
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    47
    directory's parent revision with the given name. If you specify
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    48
    a revision using -r REV (where REV may be an existing bookmark),
6bddba3973bc bookmarks: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9202
diff changeset
    49
    the bookmark is assigned to that revision.
12772
4212fdc4db18 bookmarks: add paragraph on pushing and pulling to help
Kevin Bullock <kbullock@ringworld.org>
parents: 12747
diff changeset
    50
4212fdc4db18 bookmarks: add paragraph on pushing and pulling to help
Kevin Bullock <kbullock@ringworld.org>
parents: 12747
diff changeset
    51
    Bookmarks can be pushed and pulled between repositories (see :hg:`help
4212fdc4db18 bookmarks: add paragraph on pushing and pulling to help
Kevin Bullock <kbullock@ringworld.org>
parents: 12747
diff changeset
    52
    push` and :hg:`help pull`). This requires the bookmark extension to be
4212fdc4db18 bookmarks: add paragraph on pushing and pulling to help
Kevin Bullock <kbullock@ringworld.org>
parents: 12747
diff changeset
    53
    enabled for both the local and remote repositories.
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    54
    '''
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    55
    hexfn = ui.debugflag and hex or short
10105
dc5b5cc5ca34 bookmarks: turn repo._bookmarks into a propertycache
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 9643
diff changeset
    56
    marks = repo._bookmarks
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    57
    cur   = repo.changectx('.').node()
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    58
7255
69e431ea124d bookmarks: Rename --move to --rename
Joel Rosdahl <joel@rosdahl.net>
parents: 7254
diff changeset
    59
    if rename:
69e431ea124d bookmarks: Rename --move to --rename
Joel Rosdahl <joel@rosdahl.net>
parents: 7254
diff changeset
    60
        if rename not in marks:
7251
444d88175e33 bookmarks: Fix spelling and grammar
Joel Rosdahl <joel@rosdahl.net>
parents: 7250
diff changeset
    61
            raise util.Abort(_("a bookmark of this name does not exist"))
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    62
        if mark in marks and not force:
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    63
            raise util.Abort(_("a bookmark of the same name already exists"))
7254
d892211d670e bookmarks: Require new bookmark name when renaming
Joel Rosdahl <joel@rosdahl.net>
parents: 7253
diff changeset
    64
        if mark is None:
d892211d670e bookmarks: Require new bookmark name when renaming
Joel Rosdahl <joel@rosdahl.net>
parents: 7253
diff changeset
    65
            raise util.Abort(_("new bookmark name required"))
7255
69e431ea124d bookmarks: Rename --move to --rename
Joel Rosdahl <joel@rosdahl.net>
parents: 7254
diff changeset
    66
        marks[mark] = marks[rename]
69e431ea124d bookmarks: Rename --move to --rename
Joel Rosdahl <joel@rosdahl.net>
parents: 7254
diff changeset
    67
        del marks[rename]
10107
c03f467423f3 bookmarks: repo._bookmarkcurrent should be a propertycache
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10106
diff changeset
    68
        if repo._bookmarkcurrent == rename:
13350
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
    69
            bookmarks.setcurrent(repo, mark)
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
    70
        bookmarks.write(repo)
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    71
        return
7250
352627bcafc3 bookmarks: Remove trailing space
Joel Rosdahl <joel@rosdahl.net>
parents: 7239
diff changeset
    72
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    73
    if delete:
8527
f9a80054dd3c use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
    74
        if mark is None:
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    75
            raise util.Abort(_("bookmark name required"))
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    76
        if mark not in marks:
7251
444d88175e33 bookmarks: Fix spelling and grammar
Joel Rosdahl <joel@rosdahl.net>
parents: 7250
diff changeset
    77
            raise util.Abort(_("a bookmark of this name does not exist"))
10107
c03f467423f3 bookmarks: repo._bookmarkcurrent should be a propertycache
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10106
diff changeset
    78
        if mark == repo._bookmarkcurrent:
13350
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
    79
            bookmarks.setcurrent(repo, None)
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    80
        del marks[mark]
13350
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
    81
        bookmarks.write(repo)
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    82
        return
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    83
13031
3da456d0c885 code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler <mg@aragost.com>
parents: 12881
diff changeset
    84
    if mark is not None:
7259
18c23375861f bookmarks: Correctly reject newlines in bookmark names
Joel Rosdahl <joel@rosdahl.net>
parents: 7258
diff changeset
    85
        if "\n" in mark:
18c23375861f bookmarks: Correctly reject newlines in bookmark names
Joel Rosdahl <joel@rosdahl.net>
parents: 7258
diff changeset
    86
            raise util.Abort(_("bookmark name cannot contain newlines"))
7260
eb91b9ce2c19 bookmarks: Strip bookmark names of whitespace, just like tag names
Joel Rosdahl <joel@rosdahl.net>
parents: 7259
diff changeset
    87
        mark = mark.strip()
11704
18c47562d331 bookmarks: don't allow name to contain whitespaces only
Idan Kamara <idankk86@gmail.com>
parents: 11641
diff changeset
    88
        if not mark:
18c47562d331 bookmarks: don't allow name to contain whitespaces only
Idan Kamara <idankk86@gmail.com>
parents: 11641
diff changeset
    89
            raise util.Abort(_("bookmark names cannot consist entirely of "
18c47562d331 bookmarks: don't allow name to contain whitespaces only
Idan Kamara <idankk86@gmail.com>
parents: 11641
diff changeset
    90
                               "whitespace"))
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    91
        if mark in marks and not force:
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    92
            raise util.Abort(_("a bookmark of the same name already exists"))
7250
352627bcafc3 bookmarks: Remove trailing space
Joel Rosdahl <joel@rosdahl.net>
parents: 7239
diff changeset
    93
        if ((mark in repo.branchtags() or mark == repo.dirstate.branch())
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    94
            and not force):
7252
104a8324798e bookmarks: Avoid long lines
Joel Rosdahl <joel@rosdahl.net>
parents: 7251
diff changeset
    95
            raise util.Abort(
104a8324798e bookmarks: Avoid long lines
Joel Rosdahl <joel@rosdahl.net>
parents: 7251
diff changeset
    96
                _("a bookmark cannot have the name of an existing branch"))
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    97
        if rev:
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    98
            marks[mark] = repo.lookup(rev)
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
    99
        else:
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   100
            marks[mark] = repo.changectx('.').node()
13350
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
   101
        bookmarks.setcurrent(repo, mark)
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
   102
        bookmarks.write(repo)
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   103
        return
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   104
8527
f9a80054dd3c use 'x is None' instead of 'x == None'
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
   105
    if mark is None:
7258
9bd051efbdd6 bookmarks: Require a bookmark name when a revision is specified
Joel Rosdahl <joel@rosdahl.net>
parents: 7257
diff changeset
   106
        if rev:
9bd051efbdd6 bookmarks: Require a bookmark name when a revision is specified
Joel Rosdahl <joel@rosdahl.net>
parents: 7257
diff changeset
   107
            raise util.Abort(_("bookmark name required"))
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   108
        if len(marks) == 0:
10510
f77f3383c666 i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10463
diff changeset
   109
            ui.status(_("no bookmarks set\n"))
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   110
        else:
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   111
            for bmark, n in marks.iteritems():
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   112
                if ui.configbool('bookmarks', 'track.current'):
10107
c03f467423f3 bookmarks: repo._bookmarkcurrent should be a propertycache
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10106
diff changeset
   113
                    current = repo._bookmarkcurrent
10820
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   114
                    if bmark == current and n == cur:
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   115
                        prefix, label = '*', 'bookmarks.current'
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   116
                    else:
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   117
                        prefix, label = ' ', ''
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   118
                else:
10820
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   119
                    if n == cur:
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   120
                        prefix, label = '*', 'bookmarks.current'
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   121
                    else:
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   122
                        prefix, label = ' ', ''
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   123
9459
3b283adcc720 bookmarks: support --quiet
Steve Losh <steve@stevelosh.com>
parents: 9282
diff changeset
   124
                if ui.quiet:
10820
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   125
                    ui.write("%s\n" % bmark, label=label)
9459
3b283adcc720 bookmarks: support --quiet
Steve Losh <steve@stevelosh.com>
parents: 9282
diff changeset
   126
                else:
3b283adcc720 bookmarks: support --quiet
Steve Losh <steve@stevelosh.com>
parents: 9282
diff changeset
   127
                    ui.write(" %s %-25s %d:%s\n" % (
10820
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   128
                        prefix, bmark, repo.changelog.rev(n), hexfn(n)),
da809085bc9f bookmark: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents: 10597
diff changeset
   129
                        label=label)
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   130
        return
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   131
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   132
def reposetup(ui, repo):
9643
013cc052a926 bookmarks: use API to determine if repo is local
Alexander Solovyov <piranha@piranha.org.ua>
parents: 9459
diff changeset
   133
    if not repo.local():
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   134
        return
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   135
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   136
    class bookmark_repo(repo.__class__):
11442
ee1ed6afac21 addchangegroup: pass in lock to release it before changegroup hook is called
Matt Mackall <mpm@selenic.com>
parents: 11440
diff changeset
   137
        def addchangegroup(self, *args, **kwargs):
ee1ed6afac21 addchangegroup: pass in lock to release it before changegroup hook is called
Matt Mackall <mpm@selenic.com>
parents: 11440
diff changeset
   138
            result = super(bookmark_repo, self).addchangegroup(*args, **kwargs)
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   139
            if result > 1:
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   140
                # We have more heads than before
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   141
                return result
8944
dda4ad7c9ea9 bookmarks: Change references to "repo" by references to "self" (issue1611)
Isaac Jurado <diptongo@gmail.com>
parents: 8894
diff changeset
   142
            node = self.changelog.tip()
13032
e41e2b79883d dirstate: warn on invalid parents rather than aborting
Matt Mackall <mpm@selenic.com>
parents: 13031
diff changeset
   143
            parents = self.dirstate.parents()
13352
f9cd37fca5ba bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents: 13351
diff changeset
   144
            bookmarks.update(self, parents, node)
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   145
            return result
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   146
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   147
    repo.__class__ = bookmark_repo
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   148
11378
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   149
def pull(oldpull, ui, repo, source="default", **opts):
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   150
    # translate bookmark args to rev args for actual pull
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   151
    if opts.get('bookmark'):
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   152
        # this is an unpleasant hack as pull will do this internally
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   153
        source, branches = hg.parseurl(ui.expandpath(source),
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   154
                                       opts.get('branch'))
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   155
        other = hg.repository(hg.remoteui(repo, opts), source)
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   156
        rb = other.listkeys('bookmarks')
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   157
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   158
        for b in opts['bookmark']:
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   159
            if b not in rb:
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   160
                raise util.Abort(_('remote bookmark %s not found!') % b)
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   161
            opts.setdefault('rev', []).append(b)
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   162
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   163
    result = oldpull(ui, repo, source, **opts)
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   164
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   165
    # update specified bookmarks
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   166
    if opts.get('bookmark'):
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   167
        for b in opts['bookmark']:
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   168
            # explicit pull overrides local bookmark if any
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   169
            ui.status(_("importing bookmark %s\n") % b)
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   170
            repo._bookmarks[b] = repo[rb[b]].node()
13350
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
   171
        bookmarks.write(repo)
11378
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   172
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   173
    return result
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   174
11379
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   175
def push(oldpush, ui, repo, dest=None, **opts):
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   176
    dopush = True
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   177
    if opts.get('bookmark'):
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   178
        dopush = False
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   179
        for b in opts['bookmark']:
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   180
            if b in repo._bookmarks:
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   181
                dopush = True
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   182
                opts.setdefault('rev', []).append(b)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   183
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   184
    result = 0
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   185
    if dopush:
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   186
        result = oldpush(ui, repo, dest, **opts)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   187
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   188
    if opts.get('bookmark'):
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   189
        # this is an unpleasant hack as push will do this internally
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   190
        dest = ui.expandpath(dest or 'default-push', dest or 'default')
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   191
        dest, branches = hg.parseurl(dest, opts.get('branch'))
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   192
        other = hg.repository(hg.remoteui(repo, opts), dest)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   193
        rb = other.listkeys('bookmarks')
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   194
        for b in opts['bookmark']:
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   195
            # explicit push overrides remote bookmark if any
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   196
            if b in repo._bookmarks:
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   197
                ui.status(_("exporting bookmark %s\n") % b)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   198
                new = repo[b].hex()
11994
31dde4c3bb83 bookmarks: Check if the bookmark to delete exists on the remote
David Soria Parra <dsp@php.net>
parents: 11704
diff changeset
   199
            elif b in rb:
11379
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   200
                ui.status(_("deleting remote bookmark %s\n") % b)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   201
                new = '' # delete
11994
31dde4c3bb83 bookmarks: Check if the bookmark to delete exists on the remote
David Soria Parra <dsp@php.net>
parents: 11704
diff changeset
   202
            else:
12146
4d12c42fe932 bookmarks: break long line found by check-code
Martin Geisler <mg@lazybytes.net>
parents: 12083
diff changeset
   203
                ui.warn(_('bookmark %s does not exist on the local '
4d12c42fe932 bookmarks: break long line found by check-code
Martin Geisler <mg@lazybytes.net>
parents: 12083
diff changeset
   204
                          'or remote repository!\n') % b)
11994
31dde4c3bb83 bookmarks: Check if the bookmark to delete exists on the remote
David Soria Parra <dsp@php.net>
parents: 11704
diff changeset
   205
                return 2
11379
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   206
            old = rb.get(b, '')
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   207
            r = other.pushkey('bookmarks', b, old, new)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   208
            if not r:
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   209
                ui.warn(_('updating bookmark %s failed!\n') % b)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   210
                if not result:
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   211
                    result = 2
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   212
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   213
    return result
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   214
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   215
def incoming(oldincoming, ui, repo, source="default", **opts):
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   216
    if opts.get('bookmarks'):
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   217
        source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   218
        other = hg.repository(hg.remoteui(repo, opts), source)
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   219
        ui.status(_('comparing with %s\n') % url.hidepassword(source))
13354
4e1ba6ead69c bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents: 13353
diff changeset
   220
        return bookmarks.diff(ui, repo, other)
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   221
    else:
11444
b9a46acdfe1f bookmarks: fix in/out return values
Matt Mackall <mpm@selenic.com>
parents: 11443
diff changeset
   222
        return oldincoming(ui, repo, source, **opts)
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   223
11443
9e1bc1aafdb1 bookmarks: fix bogus cut and paste for outgoing
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
   224
def outgoing(oldoutgoing, ui, repo, dest=None, **opts):
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   225
    if opts.get('bookmarks'):
11443
9e1bc1aafdb1 bookmarks: fix bogus cut and paste for outgoing
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
   226
        dest = ui.expandpath(dest or 'default-push', dest or 'default')
9e1bc1aafdb1 bookmarks: fix bogus cut and paste for outgoing
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
   227
        dest, branches = hg.parseurl(dest, opts.get('branch'))
9e1bc1aafdb1 bookmarks: fix bogus cut and paste for outgoing
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
   228
        other = hg.repository(hg.remoteui(repo, opts), dest)
9e1bc1aafdb1 bookmarks: fix bogus cut and paste for outgoing
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
   229
        ui.status(_('comparing with %s\n') % url.hidepassword(dest))
13354
4e1ba6ead69c bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents: 13353
diff changeset
   230
        return bookmarks.diff(ui, other, repo)
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   231
    else:
11444
b9a46acdfe1f bookmarks: fix in/out return values
Matt Mackall <mpm@selenic.com>
parents: 11443
diff changeset
   232
        return oldoutgoing(ui, repo, dest, **opts)
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   233
7638
f83a2b1d1a71 bookmarks; clean up imports and function wrapping
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   234
def uisetup(ui):
f83a2b1d1a71 bookmarks; clean up imports and function wrapping
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   235
    if ui.configbool('bookmarks', 'track.current'):
f83a2b1d1a71 bookmarks; clean up imports and function wrapping
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   236
        extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
11378
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   237
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   238
    entry = extensions.wrapcommand(commands.table, 'pull', pull)
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   239
    entry[1].append(('B', 'bookmark', [],
12302
6ad36bca3a8a bookmarks: set VALUE in push/pull
Will Maier <willmaier@ml1.net>
parents: 12152
diff changeset
   240
                     _("bookmark to import"),
6ad36bca3a8a bookmarks: set VALUE in push/pull
Will Maier <willmaier@ml1.net>
parents: 12152
diff changeset
   241
                     _('BOOKMARK')))
11379
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   242
    entry = extensions.wrapcommand(commands.table, 'push', push)
e1a145eebb6a bookmarks: add support for push --bookmark to export bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11378
diff changeset
   243
    entry[1].append(('B', 'bookmark', [],
12302
6ad36bca3a8a bookmarks: set VALUE in push/pull
Will Maier <willmaier@ml1.net>
parents: 12152
diff changeset
   244
                     _("bookmark to export"),
6ad36bca3a8a bookmarks: set VALUE in push/pull
Will Maier <willmaier@ml1.net>
parents: 12152
diff changeset
   245
                     _('BOOKMARK')))
11431
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   246
    entry = extensions.wrapcommand(commands.table, 'incoming', incoming)
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   247
    entry[1].append(('B', 'bookmarks', False,
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   248
                     _("compare bookmark")))
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   249
    entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   250
    entry[1].append(('B', 'bookmarks', False,
cac256790aa4 bookmarks: Add -B option to incoming/outgoing to compare bookmarks
David Soria Parra <dsp@php.net>
parents: 11379
diff changeset
   251
                     _("compare bookmark")))
11378
cb21fb1b55ba bookmarks: add support for pull --bookmark to import remote bookmarks
Matt Mackall <mpm@selenic.com>
parents: 11374
diff changeset
   252
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   253
def updatecurbookmark(orig, ui, repo, *args, **opts):
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   254
    '''Set the current bookmark
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   255
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   256
    If the user updates to a bookmark we update the .hg/bookmarks.current
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   257
    file.
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   258
    '''
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   259
    res = orig(ui, repo, *args, **opts)
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   260
    rev = opts['rev']
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   261
    if not rev and len(args) > 0:
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   262
        rev = args[0]
13350
a7376b92caaa bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents: 13313
diff changeset
   263
    bookmarks.setcurrent(repo, rev)
7481
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   264
    return res
5f681a143ede bookmarks: more git-like branches
David Soria Parra <dsp@php.net>
parents: 7480
diff changeset
   265
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   266
cmdtable = {
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   267
    "bookmarks":
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   268
        (bookmark,
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   269
         [('f', 'force', False, _('force')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11193
diff changeset
   270
          ('r', 'rev', '', _('revision'), _('REV')),
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   271
          ('d', 'delete', False, _('delete a given bookmark')),
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 11193
diff changeset
   272
          ('m', 'rename', '', _('rename a given bookmark'), _('NAME'))],
7818
b6b9065c20b3 bookmarks: change NAME to REV
Benoit Allard <benoit@aeteurope.nl>
parents: 7817
diff changeset
   273
         _('hg bookmarks [-f] [-d] [-m NAME] [-r REV] [NAME]')),
7239
135003a470f3 Bookmarks: Add the bookmarks extension
David Soria Parra <dsp@php.net>
parents:
diff changeset
   274
}