[PATCH 1 of 2] update: add flag to require update destination

Ryan McElroy rm at fb.com
Sun Mar 12 02:03:12 UTC 2017


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1489283988 28800
#      Sat Mar 11 17:59:48 2017 -0800
# Node ID a788a4660443dfc33c5c1c58eec78e20150404d9
# Parent  62939e0148f170b67ca8c7374f36c413b67fd387
update: add flag to require update destination

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5345,6 +5345,11 @@ def update(ui, repo, node=None, rev=None
     if rev and node:
         raise error.Abort(_("please specify just one revision"))
 
+    if ui.configbool('update', 'requiredest', False):
+        if not node and not rev and not date:
+            raise error.Abort(_('you must specify a destination'),
+                              hint=_('for example: hg update ".::"'))
+
     if rev is None or rev == '':
         rev = node
 
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -2016,6 +2016,15 @@ User interface controls.
     Increase the amount of output printed. (default: False)
 
 
+``update``
+----------
+
+``requiredest``
+    Require that the user pass a destination when running ``hg update``.
+    For example, ``hg update .::`` will be allowed, but a plain ``hg update``
+    will be disallowed.
+    (default: False)
+
 ``web``
 -------
 
diff --git a/tests/test-update-names.t b/tests/test-update-names.t
--- a/tests/test-update-names.t
+++ b/tests/test-update-names.t
@@ -88,3 +88,19 @@ Test that warning is printed if cwd is d
   (consider changing to repo root: $TESTTMP/r1/r4)
 
 #endif
+
+  $ cd $TESTTMP
+  $ cat >> $HGRCPATH <<EOF
+  > [update]
+  > requiredest = True
+  > EOF
+  $ hg init dest
+  $ cd dest
+  $ echo a >> a
+  $ hg commit -qAm aa
+  $ hg up
+  abort: you must specify a destination
+  (for example: hg update ".::")
+  [255]
+  $ hg up .
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list