##// END OF EJS Templates
pull: add `--confirm` flag to confirm before writing changes...
Pulkit Goyal -
r45033:bd7b2c8d default
parent child Browse files
Show More
@@ -5344,6 +5344,7 b' def postincoming(ui, repo, modheads, opt'
5344 5344 None,
5345 5345 _(b'run even when remote repository is unrelated'),
5346 5346 ),
5347 (b'', b'confirm', None, _(b'confirm pull before applying changes'),),
5347 5348 (
5348 5349 b'r',
5349 5350 b'rev',
@@ -5460,6 +5461,7 b' def pull(ui, repo, source=b"default", **'
5460 5461 force=opts.get(b'force'),
5461 5462 bookmarks=opts.get(b'bookmark', ()),
5462 5463 opargs=pullopargs,
5464 confirm=opts.get(b'confirm'),
5463 5465 ).cgresult
5464 5466
5465 5467 # brev is a name, which might be a bookmark to be activated at
@@ -1067,6 +1067,9 b' coreconfigitem('
1067 1067 b'progress', b'width', default=dynamicdefault,
1068 1068 )
1069 1069 coreconfigitem(
1070 b'pull', b'confirm', default=False,
1071 )
1072 coreconfigitem(
1070 1073 b'push', b'pushvars.server', default=False,
1071 1074 )
1072 1075 coreconfigitem(
@@ -8,6 +8,7 b''
8 8 from __future__ import absolute_import
9 9
10 10 import collections
11 import weakref
11 12
12 13 from .i18n import _
13 14 from .node import (
@@ -1705,6 +1706,25 b' def _fullpullbundle2(repo, pullop):'
1705 1706 pullop.rheads = set(pullop.rheads) - pullop.common
1706 1707
1707 1708
1709 def add_confirm_callback(repo, pullop):
1710 """ adds a finalize callback to transaction which can be used to show stats
1711 to user and confirm the pull before committing transaction """
1712
1713 tr = pullop.trmanager.transaction()
1714 scmutil.registersummarycallback(
1715 repo, tr, txnname=b'pull', as_validator=True
1716 )
1717 reporef = weakref.ref(repo.unfiltered())
1718
1719 def prompt(tr):
1720 repo = reporef()
1721 cm = _(b'accept incoming changes (yn)?$$ &Yes $$ &No')
1722 if repo.ui.promptchoice(cm):
1723 raise error.Abort("user aborted")
1724
1725 tr.addvalidator(b'900-pull-prompt', prompt)
1726
1727
1708 1728 def pull(
1709 1729 repo,
1710 1730 remote,
@@ -1716,6 +1736,7 b' def pull('
1716 1736 includepats=None,
1717 1737 excludepats=None,
1718 1738 depth=None,
1739 confirm=None,
1719 1740 ):
1720 1741 """Fetch repository data from a remote.
1721 1742
@@ -1740,6 +1761,8 b' def pull('
1740 1761 ``depth`` is an integer indicating the DAG depth of history we're
1741 1762 interested in. If defined, for each revision specified in ``heads``, we
1742 1763 will fetch up to this many of its ancestors and data associated with them.
1764 ``confirm`` is a boolean indicating whether the pull should be confirmed
1765 before committing the transaction. This overrides HGPLAIN.
1743 1766
1744 1767 Returns the ``pulloperation`` created for this pull.
1745 1768 """
@@ -1786,6 +1809,11 b' def pull('
1786 1809 if not bookmod.bookmarksinstore(repo):
1787 1810 wlock = repo.wlock()
1788 1811 with wlock, repo.lock(), pullop.trmanager:
1812 if confirm or (
1813 repo.ui.configbool(b"pull", b"confirm") and not repo.ui.plain()
1814 ):
1815 add_confirm_callback(repo, pullop)
1816
1789 1817 # Use the modern wire protocol, if available.
1790 1818 if remote.capable(b'command-changesetdata'):
1791 1819 exchangev2.pull(pullop)
@@ -3,6 +3,9 b''
3 3 * `hg purge`/`hg clean` can now delete ignored files instead of
4 4 untracked files, with the new -i flag.
5 5
6 * `hg pull` now has a `--confirm` flag to prompt before applying changes.
7 Config option `pull.confirm` is also added for that.
8
6 9 * `hg log` now defaults to using an '%' symbol for commits involved
7 10 in unresolved merge conflicts. That includes unresolved conflicts
8 11 caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
@@ -345,7 +345,7 b' Show all commands + options'
345 345 parents: rev, style, template
346 346 paths: template
347 347 phase: public, draft, secret, force, rev
348 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
348 pull: update, force, confirm, rev, bookmark, branch, ssh, remotecmd, insecure
349 349 push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
350 350 recover: verify
351 351 remove: after, force, subrepos, include, exclude, dry-run
@@ -138,12 +138,37 b' client side: pull from the server'
138 138
139 139 $ hg up 'desc("ROOT")'
140 140 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
141 $ hg pull
141 $ hg pull --confirm --config ui.interactive=True << EOF
142 > n
143 > EOF
142 144 pulling from $TESTTMP/distributed-chain-building/server
143 145 searching for changes
144 146 adding changesets
145 147 adding manifests
146 148 adding file changes
149 adding 1 changesets with 1 changes to 1 files (+1 heads)
150 1 new obsolescence markers
151 obsoleting 1 changesets
152 new changesets 391a2bf12b1b (1 drafts)
153 accept incoming changes (yn)? n
154 transaction abort!
155 rollback completed
156 abort: user aborted
157 [255]
158
159 $ hg pull --confirm --config ui.interactive=True << EOF
160 > y
161 > EOF
162 pulling from $TESTTMP/distributed-chain-building/server
163 searching for changes
164 adding changesets
165 adding manifests
166 adding file changes
167 adding 1 changesets with 1 changes to 1 files (+1 heads)
168 1 new obsolescence markers
169 obsoleting 1 changesets
170 new changesets 391a2bf12b1b (1 drafts)
171 accept incoming changes (yn)? y
147 172 added 1 changesets with 1 changes to 1 files (+1 heads)
148 173 1 new obsolescence markers
149 174 obsoleted 1 changesets
@@ -377,15 +377,53 b' Simple incoming test'
377 377 2:245bde4270cd (public) [ ] add original_c
378 378 6:6f9641995072 (draft) [tip ] add n3w_3_c
379 379
380 Try to pull markers
380 Try to pull markers while testing pull --confirm
381 381 (extinct changeset are excluded but marker are pushed)
382 382
383 $ hg pull ../tmpb
383 $ hg pull ../tmpb --confirm --config ui.interactive=true <<EOF
384 > n
385 > EOF
384 386 pulling from ../tmpb
385 387 requesting all changes
386 388 adding changesets
387 389 adding manifests
388 390 adding file changes
391 adding 4 changesets with 4 changes to 4 files (+1 heads)
392 5 new obsolescence markers
393 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
394 accept incoming changes (yn)? n
395 transaction abort!
396 rollback completed
397 abort: user aborted
398 [255]
399 $ HGPLAIN=1 hg pull ../tmpb --confirm --config ui.interactive=true <<EOF
400 > n
401 > EOF
402 pulling from ../tmpb
403 requesting all changes
404 adding changesets
405 adding manifests
406 adding file changes
407 adding 4 changesets with 4 changes to 4 files (+1 heads)
408 5 new obsolescence markers
409 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
410 accept incoming changes (yn)? n
411 transaction abort!
412 rollback completed
413 abort: user aborted
414 [255]
415 $ hg pull ../tmpb --confirm --config ui.interactive=true <<EOF
416 > y
417 > EOF
418 pulling from ../tmpb
419 requesting all changes
420 adding changesets
421 adding manifests
422 adding file changes
423 adding 4 changesets with 4 changes to 4 files (+1 heads)
424 5 new obsolescence markers
425 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
426 accept incoming changes (yn)? y
389 427 added 4 changesets with 4 changes to 4 files (+1 heads)
390 428 5 new obsolescence markers
391 429 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
@@ -326,12 +326,18 b' pulling from Publish=False to publish=Fa'
326 326 o 0 public a-A - 054250a37db4
327 327
328 328 $ cd ../mu
329 $ hg pull ../nu
329 $ hg pull ../nu --confirm --config ui.interactive=True<<EOF
330 > y
331 > EOF
330 332 pulling from ../nu
331 333 searching for changes
332 334 adding changesets
333 335 adding manifests
334 336 adding file changes
337 adding 2 changesets with 2 changes to 2 files
338 new changesets d6bcb4f74035:145e75495359 (2 drafts)
339 4 local changesets will be published
340 accept incoming changes (yn)? y
335 341 added 2 changesets with 2 changes to 2 files
336 342 new changesets d6bcb4f74035:145e75495359 (2 drafts)
337 343 4 local changesets published
@@ -1,3 +1,9 b''
1 $ cat <<EOF >> $HGRCPATH
2 > [ui]
3 > interactive = true
4 > EOF
5
6
1 7 $ hg init repo
2 8 $ cd repo
3 9 $ echo foo > foo
@@ -42,12 +48,47 b' don\'t show "(+1 heads)" message when pul'
42 48 $ hg heads -q --closed
43 49 2:effea6de0384
44 50 1:ed1b79f46b9a
45 $ hg pull
51 $ hg pull --confirm << EOF
52 > n
53 > EOF
46 54 pulling from $TESTTMP/repo2
47 55 searching for changes
48 56 adding changesets
49 57 adding manifests
50 58 adding file changes
59 adding 2 changesets with 1 changes to 1 files
60 new changesets 8c900227dd5d:00cfe9073916
61 accept incoming changes (yn)? n
62 transaction abort!
63 rollback completed
64 abort: user aborted
65 [255]
66 $ hg pull --config pull.confirm=true << EOF
67 > n
68 > EOF
69 pulling from $TESTTMP/repo2
70 searching for changes
71 adding changesets
72 adding manifests
73 adding file changes
74 adding 2 changesets with 1 changes to 1 files
75 new changesets 8c900227dd5d:00cfe9073916
76 accept incoming changes (yn)? n
77 transaction abort!
78 rollback completed
79 abort: user aborted
80 [255]
81 $ hg pull --confirm << EOF
82 > y
83 > EOF
84 pulling from $TESTTMP/repo2
85 searching for changes
86 adding changesets
87 adding manifests
88 adding file changes
89 adding 2 changesets with 1 changes to 1 files
90 new changesets 8c900227dd5d:00cfe9073916
91 accept incoming changes (yn)? y
51 92 added 2 changesets with 1 changes to 1 files
52 93 new changesets 8c900227dd5d:00cfe9073916
53 94 (run 'hg update' to get a working copy)
@@ -56,6 +97,12 b' don\'t show "(+1 heads)" message when pul'
56 97 2:effea6de0384
57 98 1:ed1b79f46b9a
58 99
100 pull--confirm config option should be ignored if HGPLAIN is set
101 $ HGPLAIN=1 hg pull --config pull.confirm=True
102 pulling from $TESTTMP/repo2
103 searching for changes
104 no changes found
105
59 106 $ cd ..
60 107
61 108 $ hg init copy
General Comments 0
You need to be logged in to leave comments. Login now