pull: abort pull --update if config requires destination (issue5528)
authorRyan McElroy <rmcelroy@fb.com>
Fri, 07 Apr 2017 06:31:50 -0700
changeset 31845 86246530b8d2
parent 31844 478999e8281d
child 31846 1064a296a2a7
pull: abort pull --update if config requires destination (issue5528)
mercurial/commands.py
tests/test-update-dest.t
--- a/mercurial/commands.py	Fri Apr 07 05:41:03 2017 -0700
+++ b/mercurial/commands.py	Fri Apr 07 06:31:50 2017 -0700
@@ -3938,6 +3938,12 @@
 
     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)
--- a/tests/test-update-dest.t	Fri Apr 07 05:41:03 2017 -0700
+++ b/tests/test-update-dest.t	Fri Apr 07 06:31:50 2017 -0700
@@ -21,3 +21,15 @@
 
   $ 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]