##// 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 None,
5344 None,
5345 _(b'run even when remote repository is unrelated'),
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 b'r',
5349 b'r',
5349 b'rev',
5350 b'rev',
@@ -5460,6 +5461,7 b' def pull(ui, repo, source=b"default", **'
5460 force=opts.get(b'force'),
5461 force=opts.get(b'force'),
5461 bookmarks=opts.get(b'bookmark', ()),
5462 bookmarks=opts.get(b'bookmark', ()),
5462 opargs=pullopargs,
5463 opargs=pullopargs,
5464 confirm=opts.get(b'confirm'),
5463 ).cgresult
5465 ).cgresult
5464
5466
5465 # brev is a name, which might be a bookmark to be activated at
5467 # brev is a name, which might be a bookmark to be activated at
@@ -1067,6 +1067,9 b' coreconfigitem('
1067 b'progress', b'width', default=dynamicdefault,
1067 b'progress', b'width', default=dynamicdefault,
1068 )
1068 )
1069 coreconfigitem(
1069 coreconfigitem(
1070 b'pull', b'confirm', default=False,
1071 )
1072 coreconfigitem(
1070 b'push', b'pushvars.server', default=False,
1073 b'push', b'pushvars.server', default=False,
1071 )
1074 )
1072 coreconfigitem(
1075 coreconfigitem(
@@ -8,6 +8,7 b''
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import collections
10 import collections
11 import weakref
11
12
12 from .i18n import _
13 from .i18n import _
13 from .node import (
14 from .node import (
@@ -1705,6 +1706,25 b' def _fullpullbundle2(repo, pullop):'
1705 pullop.rheads = set(pullop.rheads) - pullop.common
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 def pull(
1728 def pull(
1709 repo,
1729 repo,
1710 remote,
1730 remote,
@@ -1716,6 +1736,7 b' def pull('
1716 includepats=None,
1736 includepats=None,
1717 excludepats=None,
1737 excludepats=None,
1718 depth=None,
1738 depth=None,
1739 confirm=None,
1719 ):
1740 ):
1720 """Fetch repository data from a remote.
1741 """Fetch repository data from a remote.
1721
1742
@@ -1740,6 +1761,8 b' def pull('
1740 ``depth`` is an integer indicating the DAG depth of history we're
1761 ``depth`` is an integer indicating the DAG depth of history we're
1741 interested in. If defined, for each revision specified in ``heads``, we
1762 interested in. If defined, for each revision specified in ``heads``, we
1742 will fetch up to this many of its ancestors and data associated with them.
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 Returns the ``pulloperation`` created for this pull.
1767 Returns the ``pulloperation`` created for this pull.
1745 """
1768 """
@@ -1786,6 +1809,11 b' def pull('
1786 if not bookmod.bookmarksinstore(repo):
1809 if not bookmod.bookmarksinstore(repo):
1787 wlock = repo.wlock()
1810 wlock = repo.wlock()
1788 with wlock, repo.lock(), pullop.trmanager:
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 # Use the modern wire protocol, if available.
1817 # Use the modern wire protocol, if available.
1790 if remote.capable(b'command-changesetdata'):
1818 if remote.capable(b'command-changesetdata'):
1791 exchangev2.pull(pullop)
1819 exchangev2.pull(pullop)
@@ -3,6 +3,9 b''
3 * `hg purge`/`hg clean` can now delete ignored files instead of
3 * `hg purge`/`hg clean` can now delete ignored files instead of
4 untracked files, with the new -i flag.
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 * `hg log` now defaults to using an '%' symbol for commits involved
9 * `hg log` now defaults to using an '%' symbol for commits involved
7 in unresolved merge conflicts. That includes unresolved conflicts
10 in unresolved merge conflicts. That includes unresolved conflicts
8 caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
11 caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
@@ -345,7 +345,7 b' Show all commands + options'
345 parents: rev, style, template
345 parents: rev, style, template
346 paths: template
346 paths: template
347 phase: public, draft, secret, force, rev
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 push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
349 push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
350 recover: verify
350 recover: verify
351 remove: after, force, subrepos, include, exclude, dry-run
351 remove: after, force, subrepos, include, exclude, dry-run
@@ -138,12 +138,37 b' client side: pull from the server'
138
138
139 $ hg up 'desc("ROOT")'
139 $ hg up 'desc("ROOT")'
140 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
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 pulling from $TESTTMP/distributed-chain-building/server
144 pulling from $TESTTMP/distributed-chain-building/server
143 searching for changes
145 searching for changes
144 adding changesets
146 adding changesets
145 adding manifests
147 adding manifests
146 adding file changes
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 added 1 changesets with 1 changes to 1 files (+1 heads)
172 added 1 changesets with 1 changes to 1 files (+1 heads)
148 1 new obsolescence markers
173 1 new obsolescence markers
149 obsoleted 1 changesets
174 obsoleted 1 changesets
@@ -377,15 +377,53 b' Simple incoming test'
377 2:245bde4270cd (public) [ ] add original_c
377 2:245bde4270cd (public) [ ] add original_c
378 6:6f9641995072 (draft) [tip ] add n3w_3_c
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 (extinct changeset are excluded but marker are pushed)
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 pulling from ../tmpb
386 pulling from ../tmpb
385 requesting all changes
387 requesting all changes
386 adding changesets
388 adding changesets
387 adding manifests
389 adding manifests
388 adding file changes
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 added 4 changesets with 4 changes to 4 files (+1 heads)
427 added 4 changesets with 4 changes to 4 files (+1 heads)
390 5 new obsolescence markers
428 5 new obsolescence markers
391 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
429 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
@@ -326,12 +326,18 b' pulling from Publish=False to publish=Fa'
326 o 0 public a-A - 054250a37db4
326 o 0 public a-A - 054250a37db4
327
327
328 $ cd ../mu
328 $ cd ../mu
329 $ hg pull ../nu
329 $ hg pull ../nu --confirm --config ui.interactive=True<<EOF
330 > y
331 > EOF
330 pulling from ../nu
332 pulling from ../nu
331 searching for changes
333 searching for changes
332 adding changesets
334 adding changesets
333 adding manifests
335 adding manifests
334 adding file changes
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 added 2 changesets with 2 changes to 2 files
341 added 2 changesets with 2 changes to 2 files
336 new changesets d6bcb4f74035:145e75495359 (2 drafts)
342 new changesets d6bcb4f74035:145e75495359 (2 drafts)
337 4 local changesets published
343 4 local changesets published
@@ -1,3 +1,9 b''
1 $ cat <<EOF >> $HGRCPATH
2 > [ui]
3 > interactive = true
4 > EOF
5
6
1 $ hg init repo
7 $ hg init repo
2 $ cd repo
8 $ cd repo
3 $ echo foo > foo
9 $ echo foo > foo
@@ -42,12 +48,47 b' don\'t show "(+1 heads)" message when pul'
42 $ hg heads -q --closed
48 $ hg heads -q --closed
43 2:effea6de0384
49 2:effea6de0384
44 1:ed1b79f46b9a
50 1:ed1b79f46b9a
45 $ hg pull
51 $ hg pull --confirm << EOF
52 > n
53 > EOF
46 pulling from $TESTTMP/repo2
54 pulling from $TESTTMP/repo2
47 searching for changes
55 searching for changes
48 adding changesets
56 adding changesets
49 adding manifests
57 adding manifests
50 adding file changes
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 added 2 changesets with 1 changes to 1 files
92 added 2 changesets with 1 changes to 1 files
52 new changesets 8c900227dd5d:00cfe9073916
93 new changesets 8c900227dd5d:00cfe9073916
53 (run 'hg update' to get a working copy)
94 (run 'hg update' to get a working copy)
@@ -56,6 +97,12 b' don\'t show "(+1 heads)" message when pul'
56 2:effea6de0384
97 2:effea6de0384
57 1:ed1b79f46b9a
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 $ cd ..
106 $ cd ..
60
107
61 $ hg init copy
108 $ hg init copy
General Comments 0
You need to be logged in to leave comments. Login now