Patchwork [2,of,2] pull: abort pull --update if config requires destination (issue5528)

login
register
mail settings
Submitter Ryan McElroy
Date April 7, 2017, 1:32 p.m.
Message ID <1a7c8af860b2bec03496.1491571943@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/20000/
State Accepted
Headers show

Comments

Ryan McElroy - April 7, 2017, 1:32 p.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1491571910 25200
#      Fri Apr 07 06:31:50 2017 -0700
# Node ID 1a7c8af860b2bec0349661a82d2f449c9d2944bb
# Parent  3d5f4ddecd504abf742f89c7c5d27064e301bda8
pull: abort pull --update if config requires destination (issue5528)
Yuya Nishihara - April 8, 2017, 7:58 a.m.
On Fri, 7 Apr 2017 06:32:23 -0700, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy@fb.com>
> # Date 1491571910 25200
> #      Fri Apr 07 06:31:50 2017 -0700
> # Node ID 1a7c8af860b2bec0349661a82d2f449c9d2944bb
> # Parent  3d5f4ddecd504abf742f89c7c5d27064e301bda8
> pull: abort pull --update if config requires destination (issue5528)

The patch looks good in what it does. Queued, thanks.

I don't follow the discussion about whether the rebase destination is obvious
enough. If that is true, we can unblock these restrictions.

https://bz.mercurial-scm.org/show_bug.cgi?id=5514#c8

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3935,6 +3935,12 @@  def pull(ui, repo, source="default", **o
 
     Returns 0 on success, 1 if an update had unresolved files.
     """
+
+    if ui.configbool('commands', 'update.requiredest') and opts.get('update'):
+        msg = _('update destination required by configuration')
+        hint = _('use hg pull followed by hg update DEST')
+        raise error.Abort(msg, hint=hint)
+
     source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
     ui.status(_('pulling from %s\n') % util.hidepassword(source))
     other = hg.peer(repo, opts, source)
diff --git a/tests/test-update-dest.t b/tests/test-update-dest.t
--- a/tests/test-update-dest.t
+++ b/tests/test-update-dest.t
@@ -21,3 +21,15 @@  Test update.requiredest
 
   $ cd ..
 
+Check update.requiredest interaction with pull --update
+  $ hg clone repo clone
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd repo
+  $ echo a >> a
+  $ hg commit -qAm aa
+  $ cd ../clone
+  $ hg pull --update
+  abort: update destination required by configuration
+  (use hg pull followed by hg update DEST)
+  [255]