[PATCH] bookmarks: teach the -r option to use revsets

David Soria Parra dsp+mercurial-devel at experimentalworks.net
Sun Sep 30 20:23:13 CDT 2012


# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1349054363 -7200
# Node ID 2c1bcebd090a140886fb939ec38629ad1621b462
# Parent  6d7db5794e8cad7da042b6ae6238116c6e59a4d2
bookmarks: teach the -r option to use revsets

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -833,7 +833,7 @@
             raise util.Abort(
                 _("a bookmark cannot have the name of an existing branch"))
         if rev:
-            marks[mark] = repo.lookup(rev)
+            marks[mark] = scmutil.revsingle(repo, rev).node()
         else:
             marks[mark] = cur
         if not inactive and cur == marks[mark]:
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -154,6 +154,19 @@
    * Y                         2:db815d6d32e6
      Z                         0:f7b1eb17ad24
 
+bookmarks from a revset
+  $ hg bookmark -r '.^1' REVSET
+  $ hg bookmark -r ':tip' TIP
+  $ hg bookmarks
+     REVSET                    0:f7b1eb17ad24
+   * TIP                       2:db815d6d32e6
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+     Z                         0:f7b1eb17ad24
+
+  $ hg bookmark -d REVSET
+  $ hg bookmark -d TIP
+
 rename without new name
 
   $ hg bookmark -m Y


More information about the Mercurial-devel mailing list