##// END OF EJS Templates
fetch: use an abort hint where appropriate
Yuya Nishihara -
r24368:55fd99a2 default
parent child Browse files
Show More
@@ -1,150 +1,150 b''
1 # fetch.py - pull and merge remote changes
1 # fetch.py - pull and merge remote changes
2 #
2 #
3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''pull, update and merge in one command (DEPRECATED)'''
8 '''pull, update and merge in one command (DEPRECATED)'''
9
9
10 from mercurial.i18n import _
10 from mercurial.i18n import _
11 from mercurial.node import short
11 from mercurial.node import short
12 from mercurial import commands, cmdutil, hg, util, error
12 from mercurial import commands, cmdutil, hg, util, error
13 from mercurial.lock import release
13 from mercurial.lock import release
14 from mercurial import exchange
14 from mercurial import exchange
15
15
16 cmdtable = {}
16 cmdtable = {}
17 command = cmdutil.command(cmdtable)
17 command = cmdutil.command(cmdtable)
18 testedwith = 'internal'
18 testedwith = 'internal'
19
19
20 @command('fetch',
20 @command('fetch',
21 [('r', 'rev', [],
21 [('r', 'rev', [],
22 _('a specific revision you would like to pull'), _('REV')),
22 _('a specific revision you would like to pull'), _('REV')),
23 ('e', 'edit', None, _('invoke editor on commit messages')),
23 ('e', 'edit', None, _('invoke editor on commit messages')),
24 ('', 'force-editor', None, _('edit commit message (DEPRECATED)')),
24 ('', 'force-editor', None, _('edit commit message (DEPRECATED)')),
25 ('', 'switch-parent', None, _('switch parents when merging')),
25 ('', 'switch-parent', None, _('switch parents when merging')),
26 ] + commands.commitopts + commands.commitopts2 + commands.remoteopts,
26 ] + commands.commitopts + commands.commitopts2 + commands.remoteopts,
27 _('hg fetch [SOURCE]'))
27 _('hg fetch [SOURCE]'))
28 def fetch(ui, repo, source='default', **opts):
28 def fetch(ui, repo, source='default', **opts):
29 '''pull changes from a remote repository, merge new changes if needed.
29 '''pull changes from a remote repository, merge new changes if needed.
30
30
31 This finds all changes from the repository at the specified path
31 This finds all changes from the repository at the specified path
32 or URL and adds them to the local repository.
32 or URL and adds them to the local repository.
33
33
34 If the pulled changes add a new branch head, the head is
34 If the pulled changes add a new branch head, the head is
35 automatically merged, and the result of the merge is committed.
35 automatically merged, and the result of the merge is committed.
36 Otherwise, the working directory is updated to include the new
36 Otherwise, the working directory is updated to include the new
37 changes.
37 changes.
38
38
39 When a merge is needed, the working directory is first updated to
39 When a merge is needed, the working directory is first updated to
40 the newly pulled changes. Local changes are then merged into the
40 the newly pulled changes. Local changes are then merged into the
41 pulled changes. To switch the merge order, use --switch-parent.
41 pulled changes. To switch the merge order, use --switch-parent.
42
42
43 See :hg:`help dates` for a list of formats valid for -d/--date.
43 See :hg:`help dates` for a list of formats valid for -d/--date.
44
44
45 Returns 0 on success.
45 Returns 0 on success.
46 '''
46 '''
47
47
48 date = opts.get('date')
48 date = opts.get('date')
49 if date:
49 if date:
50 opts['date'] = util.parsedate(date)
50 opts['date'] = util.parsedate(date)
51
51
52 parent, _p2 = repo.dirstate.parents()
52 parent, _p2 = repo.dirstate.parents()
53 branch = repo.dirstate.branch()
53 branch = repo.dirstate.branch()
54 try:
54 try:
55 branchnode = repo.branchtip(branch)
55 branchnode = repo.branchtip(branch)
56 except error.RepoLookupError:
56 except error.RepoLookupError:
57 branchnode = None
57 branchnode = None
58 if parent != branchnode:
58 if parent != branchnode:
59 raise util.Abort(_('working directory not at branch tip '
59 raise util.Abort(_('working directory not at branch tip'),
60 '(use "hg update" to check out branch tip)'))
60 hint=_('use "hg update" to check out branch tip'))
61
61
62 wlock = lock = None
62 wlock = lock = None
63 try:
63 try:
64 wlock = repo.wlock()
64 wlock = repo.wlock()
65 lock = repo.lock()
65 lock = repo.lock()
66
66
67 cmdutil.bailifchanged(repo)
67 cmdutil.bailifchanged(repo)
68
68
69 bheads = repo.branchheads(branch)
69 bheads = repo.branchheads(branch)
70 bheads = [head for head in bheads if len(repo[head].children()) == 0]
70 bheads = [head for head in bheads if len(repo[head].children()) == 0]
71 if len(bheads) > 1:
71 if len(bheads) > 1:
72 raise util.Abort(_('multiple heads in this branch '
72 raise util.Abort(_('multiple heads in this branch '
73 '(use "hg heads ." and "hg merge" to merge)'))
73 '(use "hg heads ." and "hg merge" to merge)'))
74
74
75 other = hg.peer(repo, opts, ui.expandpath(source))
75 other = hg.peer(repo, opts, ui.expandpath(source))
76 ui.status(_('pulling from %s\n') %
76 ui.status(_('pulling from %s\n') %
77 util.hidepassword(ui.expandpath(source)))
77 util.hidepassword(ui.expandpath(source)))
78 revs = None
78 revs = None
79 if opts['rev']:
79 if opts['rev']:
80 try:
80 try:
81 revs = [other.lookup(rev) for rev in opts['rev']]
81 revs = [other.lookup(rev) for rev in opts['rev']]
82 except error.CapabilityError:
82 except error.CapabilityError:
83 err = _("other repository doesn't support revision lookup, "
83 err = _("other repository doesn't support revision lookup, "
84 "so a rev cannot be specified.")
84 "so a rev cannot be specified.")
85 raise util.Abort(err)
85 raise util.Abort(err)
86
86
87 # Are there any changes at all?
87 # Are there any changes at all?
88 modheads = exchange.pull(repo, other, heads=revs).cgresult
88 modheads = exchange.pull(repo, other, heads=revs).cgresult
89 if modheads == 0:
89 if modheads == 0:
90 return 0
90 return 0
91
91
92 # Is this a simple fast-forward along the current branch?
92 # Is this a simple fast-forward along the current branch?
93 newheads = repo.branchheads(branch)
93 newheads = repo.branchheads(branch)
94 newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
94 newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
95 if len(newheads) == 1 and len(newchildren):
95 if len(newheads) == 1 and len(newchildren):
96 if newchildren[0] != parent:
96 if newchildren[0] != parent:
97 return hg.update(repo, newchildren[0])
97 return hg.update(repo, newchildren[0])
98 else:
98 else:
99 return 0
99 return 0
100
100
101 # Are there more than one additional branch heads?
101 # Are there more than one additional branch heads?
102 newchildren = [n for n in newchildren if n != parent]
102 newchildren = [n for n in newchildren if n != parent]
103 newparent = parent
103 newparent = parent
104 if newchildren:
104 if newchildren:
105 newparent = newchildren[0]
105 newparent = newchildren[0]
106 hg.clean(repo, newparent)
106 hg.clean(repo, newparent)
107 newheads = [n for n in newheads if n != newparent]
107 newheads = [n for n in newheads if n != newparent]
108 if len(newheads) > 1:
108 if len(newheads) > 1:
109 ui.status(_('not merging with %d other new branch heads '
109 ui.status(_('not merging with %d other new branch heads '
110 '(use "hg heads ." and "hg merge" to merge them)\n') %
110 '(use "hg heads ." and "hg merge" to merge them)\n') %
111 (len(newheads) - 1))
111 (len(newheads) - 1))
112 return 1
112 return 1
113
113
114 if not newheads:
114 if not newheads:
115 return 0
115 return 0
116
116
117 # Otherwise, let's merge.
117 # Otherwise, let's merge.
118 err = False
118 err = False
119 if newheads:
119 if newheads:
120 # By default, we consider the repository we're pulling
120 # By default, we consider the repository we're pulling
121 # *from* as authoritative, so we merge our changes into
121 # *from* as authoritative, so we merge our changes into
122 # theirs.
122 # theirs.
123 if opts['switch_parent']:
123 if opts['switch_parent']:
124 firstparent, secondparent = newparent, newheads[0]
124 firstparent, secondparent = newparent, newheads[0]
125 else:
125 else:
126 firstparent, secondparent = newheads[0], newparent
126 firstparent, secondparent = newheads[0], newparent
127 ui.status(_('updating to %d:%s\n') %
127 ui.status(_('updating to %d:%s\n') %
128 (repo.changelog.rev(firstparent),
128 (repo.changelog.rev(firstparent),
129 short(firstparent)))
129 short(firstparent)))
130 hg.clean(repo, firstparent)
130 hg.clean(repo, firstparent)
131 ui.status(_('merging with %d:%s\n') %
131 ui.status(_('merging with %d:%s\n') %
132 (repo.changelog.rev(secondparent), short(secondparent)))
132 (repo.changelog.rev(secondparent), short(secondparent)))
133 err = hg.merge(repo, secondparent, remind=False)
133 err = hg.merge(repo, secondparent, remind=False)
134
134
135 if not err:
135 if not err:
136 # we don't translate commit messages
136 # we don't translate commit messages
137 message = (cmdutil.logmessage(ui, opts) or
137 message = (cmdutil.logmessage(ui, opts) or
138 ('Automated merge with %s' %
138 ('Automated merge with %s' %
139 util.removeauth(other.url())))
139 util.removeauth(other.url())))
140 editopt = opts.get('edit') or opts.get('force_editor')
140 editopt = opts.get('edit') or opts.get('force_editor')
141 editor = cmdutil.getcommiteditor(edit=editopt, editform='fetch')
141 editor = cmdutil.getcommiteditor(edit=editopt, editform='fetch')
142 n = repo.commit(message, opts['user'], opts['date'], editor=editor)
142 n = repo.commit(message, opts['user'], opts['date'], editor=editor)
143 ui.status(_('new changeset %d:%s merges remote changes '
143 ui.status(_('new changeset %d:%s merges remote changes '
144 'with local\n') % (repo.changelog.rev(n),
144 'with local\n') % (repo.changelog.rev(n),
145 short(n)))
145 short(n)))
146
146
147 return err
147 return err
148
148
149 finally:
149 finally:
150 release(lock, wlock)
150 release(lock, wlock)
@@ -1,431 +1,432 b''
1 #require serve
1 #require serve
2
2
3 $ echo "[extensions]" >> $HGRCPATH
3 $ echo "[extensions]" >> $HGRCPATH
4 $ echo "fetch=" >> $HGRCPATH
4 $ echo "fetch=" >> $HGRCPATH
5
5
6 test fetch with default branches only
6 test fetch with default branches only
7
7
8 $ hg init a
8 $ hg init a
9 $ echo a > a/a
9 $ echo a > a/a
10 $ hg --cwd a commit -Ama
10 $ hg --cwd a commit -Ama
11 adding a
11 adding a
12 $ hg clone a b
12 $ hg clone a b
13 updating to branch default
13 updating to branch default
14 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
14 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
15 $ hg clone a c
15 $ hg clone a c
16 updating to branch default
16 updating to branch default
17 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
17 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
18 $ echo b > a/b
18 $ echo b > a/b
19 $ hg --cwd a commit -Amb
19 $ hg --cwd a commit -Amb
20 adding b
20 adding b
21 $ hg --cwd a parents -q
21 $ hg --cwd a parents -q
22 1:d2ae7f538514
22 1:d2ae7f538514
23
23
24 should pull one change
24 should pull one change
25
25
26 $ hg --cwd b fetch ../a
26 $ hg --cwd b fetch ../a
27 pulling from ../a
27 pulling from ../a
28 searching for changes
28 searching for changes
29 adding changesets
29 adding changesets
30 adding manifests
30 adding manifests
31 adding file changes
31 adding file changes
32 added 1 changesets with 1 changes to 1 files
32 added 1 changesets with 1 changes to 1 files
33 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
33 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 $ hg --cwd b parents -q
34 $ hg --cwd b parents -q
35 1:d2ae7f538514
35 1:d2ae7f538514
36 $ echo c > c/c
36 $ echo c > c/c
37 $ hg --cwd c commit -Amc
37 $ hg --cwd c commit -Amc
38 adding c
38 adding c
39 $ hg clone c d
39 $ hg clone c d
40 updating to branch default
40 updating to branch default
41 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
41 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 $ hg clone c e
42 $ hg clone c e
43 updating to branch default
43 updating to branch default
44 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
44 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
45
45
46 We cannot use the default commit message if fetching from a local
46 We cannot use the default commit message if fetching from a local
47 repo, because the path of the repo will be included in the commit
47 repo, because the path of the repo will be included in the commit
48 message, making every commit appear different.
48 message, making every commit appear different.
49 should merge c into a
49 should merge c into a
50
50
51 $ hg --cwd c fetch -d '0 0' -m 'automated merge' ../a
51 $ hg --cwd c fetch -d '0 0' -m 'automated merge' ../a
52 pulling from ../a
52 pulling from ../a
53 searching for changes
53 searching for changes
54 adding changesets
54 adding changesets
55 adding manifests
55 adding manifests
56 adding file changes
56 adding file changes
57 added 1 changesets with 1 changes to 1 files (+1 heads)
57 added 1 changesets with 1 changes to 1 files (+1 heads)
58 updating to 2:d2ae7f538514
58 updating to 2:d2ae7f538514
59 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
59 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
60 merging with 1:d36c0562f908
60 merging with 1:d36c0562f908
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
62 new changeset 3:a323a0c43ec4 merges remote changes with local
62 new changeset 3:a323a0c43ec4 merges remote changes with local
63 $ ls c
63 $ ls c
64 a
64 a
65 b
65 b
66 c
66 c
67 $ hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid
67 $ hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid
68 $ cat a/hg.pid >> "$DAEMON_PIDS"
68 $ cat a/hg.pid >> "$DAEMON_PIDS"
69
69
70 fetch over http, no auth
70 fetch over http, no auth
71 (this also tests that editor is invoked if '--edit' is specified)
71 (this also tests that editor is invoked if '--edit' is specified)
72
72
73 $ HGEDITOR=cat hg --cwd d fetch --edit http://localhost:$HGPORT/
73 $ HGEDITOR=cat hg --cwd d fetch --edit http://localhost:$HGPORT/
74 pulling from http://localhost:$HGPORT/
74 pulling from http://localhost:$HGPORT/
75 searching for changes
75 searching for changes
76 adding changesets
76 adding changesets
77 adding manifests
77 adding manifests
78 adding file changes
78 adding file changes
79 added 1 changesets with 1 changes to 1 files (+1 heads)
79 added 1 changesets with 1 changes to 1 files (+1 heads)
80 updating to 2:d2ae7f538514
80 updating to 2:d2ae7f538514
81 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
81 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
82 merging with 1:d36c0562f908
82 merging with 1:d36c0562f908
83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
84 Automated merge with http://localhost:$HGPORT/
84 Automated merge with http://localhost:$HGPORT/
85
85
86
86
87 HG: Enter commit message. Lines beginning with 'HG:' are removed.
87 HG: Enter commit message. Lines beginning with 'HG:' are removed.
88 HG: Leave message empty to abort commit.
88 HG: Leave message empty to abort commit.
89 HG: --
89 HG: --
90 HG: user: test
90 HG: user: test
91 HG: branch merge
91 HG: branch merge
92 HG: branch 'default'
92 HG: branch 'default'
93 HG: changed c
93 HG: changed c
94 new changeset 3:* merges remote changes with local (glob)
94 new changeset 3:* merges remote changes with local (glob)
95 $ hg --cwd d tip --template '{desc}\n'
95 $ hg --cwd d tip --template '{desc}\n'
96 Automated merge with http://localhost:$HGPORT/
96 Automated merge with http://localhost:$HGPORT/
97 $ hg --cwd d status --rev 'tip^1' --rev tip
97 $ hg --cwd d status --rev 'tip^1' --rev tip
98 A c
98 A c
99 $ hg --cwd d status --rev 'tip^2' --rev tip
99 $ hg --cwd d status --rev 'tip^2' --rev tip
100 A b
100 A b
101
101
102 fetch over http with auth (should be hidden in desc)
102 fetch over http with auth (should be hidden in desc)
103 (this also tests that editor is not invoked if '--edit' is not
103 (this also tests that editor is not invoked if '--edit' is not
104 specified, even though commit message is not specified explicitly)
104 specified, even though commit message is not specified explicitly)
105
105
106 $ HGEDITOR=cat hg --cwd e fetch http://user:password@localhost:$HGPORT/
106 $ HGEDITOR=cat hg --cwd e fetch http://user:password@localhost:$HGPORT/
107 pulling from http://user:***@localhost:$HGPORT/
107 pulling from http://user:***@localhost:$HGPORT/
108 searching for changes
108 searching for changes
109 adding changesets
109 adding changesets
110 adding manifests
110 adding manifests
111 adding file changes
111 adding file changes
112 added 1 changesets with 1 changes to 1 files (+1 heads)
112 added 1 changesets with 1 changes to 1 files (+1 heads)
113 updating to 2:d2ae7f538514
113 updating to 2:d2ae7f538514
114 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
114 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
115 merging with 1:d36c0562f908
115 merging with 1:d36c0562f908
116 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
116 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
117 new changeset 3:* merges remote changes with local (glob)
117 new changeset 3:* merges remote changes with local (glob)
118 $ hg --cwd e tip --template '{desc}\n'
118 $ hg --cwd e tip --template '{desc}\n'
119 Automated merge with http://localhost:$HGPORT/
119 Automated merge with http://localhost:$HGPORT/
120 $ hg clone a f
120 $ hg clone a f
121 updating to branch default
121 updating to branch default
122 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
123 $ hg clone a g
123 $ hg clone a g
124 updating to branch default
124 updating to branch default
125 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
125 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
126 $ echo f > f/f
126 $ echo f > f/f
127 $ hg --cwd f ci -Amf
127 $ hg --cwd f ci -Amf
128 adding f
128 adding f
129 $ echo g > g/g
129 $ echo g > g/g
130 $ hg --cwd g ci -Amg
130 $ hg --cwd g ci -Amg
131 adding g
131 adding g
132 $ hg clone -q f h
132 $ hg clone -q f h
133 $ hg clone -q g i
133 $ hg clone -q g i
134
134
135 should merge f into g
135 should merge f into g
136
136
137 $ hg --cwd g fetch -d '0 0' --switch -m 'automated merge' ../f
137 $ hg --cwd g fetch -d '0 0' --switch -m 'automated merge' ../f
138 pulling from ../f
138 pulling from ../f
139 searching for changes
139 searching for changes
140 adding changesets
140 adding changesets
141 adding manifests
141 adding manifests
142 adding file changes
142 adding file changes
143 added 1 changesets with 1 changes to 1 files (+1 heads)
143 added 1 changesets with 1 changes to 1 files (+1 heads)
144 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
144 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
145 merging with 3:6343ca3eff20
145 merging with 3:6343ca3eff20
146 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
146 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
147 new changeset 4:f7faa0b7d3c6 merges remote changes with local
147 new changeset 4:f7faa0b7d3c6 merges remote changes with local
148 $ rm i/g
148 $ rm i/g
149
149
150 should abort, because i is modified
150 should abort, because i is modified
151
151
152 $ hg --cwd i fetch ../h
152 $ hg --cwd i fetch ../h
153 abort: uncommitted changes
153 abort: uncommitted changes
154 [255]
154 [255]
155
155
156 test fetch with named branches
156 test fetch with named branches
157
157
158 $ hg init nbase
158 $ hg init nbase
159 $ echo base > nbase/a
159 $ echo base > nbase/a
160 $ hg -R nbase ci -Am base
160 $ hg -R nbase ci -Am base
161 adding a
161 adding a
162 $ hg -R nbase branch a
162 $ hg -R nbase branch a
163 marked working directory as branch a
163 marked working directory as branch a
164 (branches are permanent and global, did you want a bookmark?)
164 (branches are permanent and global, did you want a bookmark?)
165 $ echo a > nbase/a
165 $ echo a > nbase/a
166 $ hg -R nbase ci -m a
166 $ hg -R nbase ci -m a
167 $ hg -R nbase up -C 0
167 $ hg -R nbase up -C 0
168 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
168 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
169 $ hg -R nbase branch b
169 $ hg -R nbase branch b
170 marked working directory as branch b
170 marked working directory as branch b
171 (branches are permanent and global, did you want a bookmark?)
171 (branches are permanent and global, did you want a bookmark?)
172 $ echo b > nbase/b
172 $ echo b > nbase/b
173 $ hg -R nbase ci -Am b
173 $ hg -R nbase ci -Am b
174 adding b
174 adding b
175
175
176 pull in change on foreign branch
176 pull in change on foreign branch
177
177
178 $ hg clone nbase n1
178 $ hg clone nbase n1
179 updating to branch default
179 updating to branch default
180 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
180 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
181 $ hg clone nbase n2
181 $ hg clone nbase n2
182 updating to branch default
182 updating to branch default
183 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
183 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
184 $ hg -R n1 up -C a
184 $ hg -R n1 up -C a
185 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
185 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
186 $ echo aa > n1/a
186 $ echo aa > n1/a
187 $ hg -R n1 ci -m a1
187 $ hg -R n1 ci -m a1
188 $ hg -R n2 up -C b
188 $ hg -R n2 up -C b
189 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
189 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
190 $ hg -R n2 fetch -m 'merge' n1
190 $ hg -R n2 fetch -m 'merge' n1
191 pulling from n1
191 pulling from n1
192 searching for changes
192 searching for changes
193 adding changesets
193 adding changesets
194 adding manifests
194 adding manifests
195 adding file changes
195 adding file changes
196 added 1 changesets with 1 changes to 1 files
196 added 1 changesets with 1 changes to 1 files
197
197
198 parent should be 2 (no automatic update)
198 parent should be 2 (no automatic update)
199
199
200 $ hg -R n2 parents --template '{rev}\n'
200 $ hg -R n2 parents --template '{rev}\n'
201 2
201 2
202 $ rm -fr n1 n2
202 $ rm -fr n1 n2
203
203
204 pull in changes on both foreign and local branches
204 pull in changes on both foreign and local branches
205
205
206 $ hg clone nbase n1
206 $ hg clone nbase n1
207 updating to branch default
207 updating to branch default
208 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
208 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
209 $ hg clone nbase n2
209 $ hg clone nbase n2
210 updating to branch default
210 updating to branch default
211 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
211 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
212 $ hg -R n1 up -C a
212 $ hg -R n1 up -C a
213 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
214 $ echo aa > n1/a
214 $ echo aa > n1/a
215 $ hg -R n1 ci -m a1
215 $ hg -R n1 ci -m a1
216 $ hg -R n1 up -C b
216 $ hg -R n1 up -C b
217 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
217 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
218 $ echo bb > n1/b
218 $ echo bb > n1/b
219 $ hg -R n1 ci -m b1
219 $ hg -R n1 ci -m b1
220 $ hg -R n2 up -C b
220 $ hg -R n2 up -C b
221 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
221 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
222 $ hg -R n2 fetch -m 'merge' n1
222 $ hg -R n2 fetch -m 'merge' n1
223 pulling from n1
223 pulling from n1
224 searching for changes
224 searching for changes
225 adding changesets
225 adding changesets
226 adding manifests
226 adding manifests
227 adding file changes
227 adding file changes
228 added 2 changesets with 2 changes to 2 files
228 added 2 changesets with 2 changes to 2 files
229 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
229 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
230
230
231 parent should be 4 (fast forward)
231 parent should be 4 (fast forward)
232
232
233 $ hg -R n2 parents --template '{rev}\n'
233 $ hg -R n2 parents --template '{rev}\n'
234 4
234 4
235 $ rm -fr n1 n2
235 $ rm -fr n1 n2
236
236
237 pull changes on foreign (2 new heads) and local (1 new head) branches
237 pull changes on foreign (2 new heads) and local (1 new head) branches
238 with a local change
238 with a local change
239
239
240 $ hg clone nbase n1
240 $ hg clone nbase n1
241 updating to branch default
241 updating to branch default
242 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
242 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
243 $ hg clone nbase n2
243 $ hg clone nbase n2
244 updating to branch default
244 updating to branch default
245 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
245 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
246 $ hg -R n1 up -C a
246 $ hg -R n1 up -C a
247 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
247 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
248 $ echo a1 > n1/a
248 $ echo a1 > n1/a
249 $ hg -R n1 ci -m a1
249 $ hg -R n1 ci -m a1
250 $ hg -R n1 up -C b
250 $ hg -R n1 up -C b
251 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
251 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
252 $ echo bb > n1/b
252 $ echo bb > n1/b
253 $ hg -R n1 ci -m b1
253 $ hg -R n1 ci -m b1
254 $ hg -R n1 up -C 1
254 $ hg -R n1 up -C 1
255 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
255 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
256 $ echo a2 > n1/a
256 $ echo a2 > n1/a
257 $ hg -R n1 ci -m a2
257 $ hg -R n1 ci -m a2
258 created new head
258 created new head
259 $ hg -R n2 up -C b
259 $ hg -R n2 up -C b
260 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
260 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
261 $ echo change >> n2/c
261 $ echo change >> n2/c
262 $ hg -R n2 ci -A -m local
262 $ hg -R n2 ci -A -m local
263 adding c
263 adding c
264 $ hg -R n2 fetch -d '0 0' -m 'merge' n1
264 $ hg -R n2 fetch -d '0 0' -m 'merge' n1
265 pulling from n1
265 pulling from n1
266 searching for changes
266 searching for changes
267 adding changesets
267 adding changesets
268 adding manifests
268 adding manifests
269 adding file changes
269 adding file changes
270 added 3 changesets with 3 changes to 2 files (+2 heads)
270 added 3 changesets with 3 changes to 2 files (+2 heads)
271 updating to 5:3c4a837a864f
271 updating to 5:3c4a837a864f
272 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
272 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
273 merging with 3:1267f84a9ea5
273 merging with 3:1267f84a9ea5
274 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
274 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 new changeset 7:2cf2a1261f21 merges remote changes with local
275 new changeset 7:2cf2a1261f21 merges remote changes with local
276
276
277 parent should be 7 (new merge changeset)
277 parent should be 7 (new merge changeset)
278
278
279 $ hg -R n2 parents --template '{rev}\n'
279 $ hg -R n2 parents --template '{rev}\n'
280 7
280 7
281 $ rm -fr n1 n2
281 $ rm -fr n1 n2
282
282
283 pull in changes on foreign (merge of local branch) and local (2 new
283 pull in changes on foreign (merge of local branch) and local (2 new
284 heads) with a local change
284 heads) with a local change
285
285
286 $ hg clone nbase n1
286 $ hg clone nbase n1
287 updating to branch default
287 updating to branch default
288 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
289 $ hg clone nbase n2
289 $ hg clone nbase n2
290 updating to branch default
290 updating to branch default
291 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
291 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
292 $ hg -R n1 up -C a
292 $ hg -R n1 up -C a
293 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
293 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
294 $ hg -R n1 merge b
294 $ hg -R n1 merge b
295 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
295 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
296 (branch merge, don't forget to commit)
296 (branch merge, don't forget to commit)
297 $ hg -R n1 ci -m merge
297 $ hg -R n1 ci -m merge
298 $ hg -R n1 up -C 2
298 $ hg -R n1 up -C 2
299 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
299 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
300 $ echo c > n1/a
300 $ echo c > n1/a
301 $ hg -R n1 ci -m c
301 $ hg -R n1 ci -m c
302 $ hg -R n1 up -C 2
302 $ hg -R n1 up -C 2
303 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
303 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
304 $ echo cc > n1/a
304 $ echo cc > n1/a
305 $ hg -R n1 ci -m cc
305 $ hg -R n1 ci -m cc
306 created new head
306 created new head
307 $ hg -R n2 up -C b
307 $ hg -R n2 up -C b
308 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
308 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
309 $ echo change >> n2/b
309 $ echo change >> n2/b
310 $ hg -R n2 ci -A -m local
310 $ hg -R n2 ci -A -m local
311 $ hg -R n2 fetch -m 'merge' n1
311 $ hg -R n2 fetch -m 'merge' n1
312 pulling from n1
312 pulling from n1
313 searching for changes
313 searching for changes
314 adding changesets
314 adding changesets
315 adding manifests
315 adding manifests
316 adding file changes
316 adding file changes
317 added 3 changesets with 2 changes to 1 files (+2 heads)
317 added 3 changesets with 2 changes to 1 files (+2 heads)
318 not merging with 1 other new branch heads (use "hg heads ." and "hg merge" to merge them)
318 not merging with 1 other new branch heads (use "hg heads ." and "hg merge" to merge them)
319 [1]
319 [1]
320
320
321 parent should be 3 (fetch did not merge anything)
321 parent should be 3 (fetch did not merge anything)
322
322
323 $ hg -R n2 parents --template '{rev}\n'
323 $ hg -R n2 parents --template '{rev}\n'
324 3
324 3
325 $ rm -fr n1 n2
325 $ rm -fr n1 n2
326
326
327 pull in change on different branch than dirstate
327 pull in change on different branch than dirstate
328
328
329 $ hg init n1
329 $ hg init n1
330 $ echo a > n1/a
330 $ echo a > n1/a
331 $ hg -R n1 ci -Am initial
331 $ hg -R n1 ci -Am initial
332 adding a
332 adding a
333 $ hg clone n1 n2
333 $ hg clone n1 n2
334 updating to branch default
334 updating to branch default
335 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
335 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
336 $ echo b > n1/a
336 $ echo b > n1/a
337 $ hg -R n1 ci -m next
337 $ hg -R n1 ci -m next
338 $ hg -R n2 branch topic
338 $ hg -R n2 branch topic
339 marked working directory as branch topic
339 marked working directory as branch topic
340 (branches are permanent and global, did you want a bookmark?)
340 (branches are permanent and global, did you want a bookmark?)
341 $ hg -R n2 fetch -m merge n1
341 $ hg -R n2 fetch -m merge n1
342 abort: working directory not at branch tip (use "hg update" to check out branch tip)
342 abort: working directory not at branch tip
343 (use "hg update" to check out branch tip)
343 [255]
344 [255]
344
345
345 parent should be 0 (fetch did not update or merge anything)
346 parent should be 0 (fetch did not update or merge anything)
346
347
347 $ hg -R n2 parents --template '{rev}\n'
348 $ hg -R n2 parents --template '{rev}\n'
348 0
349 0
349 $ rm -fr n1 n2
350 $ rm -fr n1 n2
350
351
351 test fetch with inactive branches
352 test fetch with inactive branches
352
353
353 $ hg init ib1
354 $ hg init ib1
354 $ echo a > ib1/a
355 $ echo a > ib1/a
355 $ hg --cwd ib1 ci -Am base
356 $ hg --cwd ib1 ci -Am base
356 adding a
357 adding a
357 $ hg --cwd ib1 branch second
358 $ hg --cwd ib1 branch second
358 marked working directory as branch second
359 marked working directory as branch second
359 (branches are permanent and global, did you want a bookmark?)
360 (branches are permanent and global, did you want a bookmark?)
360 $ echo b > ib1/b
361 $ echo b > ib1/b
361 $ hg --cwd ib1 ci -Am onsecond
362 $ hg --cwd ib1 ci -Am onsecond
362 adding b
363 adding b
363 $ hg --cwd ib1 branch -f default
364 $ hg --cwd ib1 branch -f default
364 marked working directory as branch default
365 marked working directory as branch default
365 (branches are permanent and global, did you want a bookmark?)
366 (branches are permanent and global, did you want a bookmark?)
366 $ echo c > ib1/c
367 $ echo c > ib1/c
367 $ hg --cwd ib1 ci -Am newdefault
368 $ hg --cwd ib1 ci -Am newdefault
368 adding c
369 adding c
369 created new head
370 created new head
370 $ hg clone ib1 ib2
371 $ hg clone ib1 ib2
371 updating to branch default
372 updating to branch default
372 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
373 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
373
374
374 fetch should succeed
375 fetch should succeed
375
376
376 $ hg --cwd ib2 fetch ../ib1
377 $ hg --cwd ib2 fetch ../ib1
377 pulling from ../ib1
378 pulling from ../ib1
378 searching for changes
379 searching for changes
379 no changes found
380 no changes found
380 $ rm -fr ib1 ib2
381 $ rm -fr ib1 ib2
381
382
382 test issue1726
383 test issue1726
383
384
384 $ hg init i1726r1
385 $ hg init i1726r1
385 $ echo a > i1726r1/a
386 $ echo a > i1726r1/a
386 $ hg --cwd i1726r1 ci -Am base
387 $ hg --cwd i1726r1 ci -Am base
387 adding a
388 adding a
388 $ hg clone i1726r1 i1726r2
389 $ hg clone i1726r1 i1726r2
389 updating to branch default
390 updating to branch default
390 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
391 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
391 $ echo b > i1726r1/a
392 $ echo b > i1726r1/a
392 $ hg --cwd i1726r1 ci -m second
393 $ hg --cwd i1726r1 ci -m second
393 $ echo c > i1726r2/a
394 $ echo c > i1726r2/a
394 $ hg --cwd i1726r2 ci -m third
395 $ hg --cwd i1726r2 ci -m third
395 $ HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1
396 $ HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1
396 pulling from ../i1726r1
397 pulling from ../i1726r1
397 searching for changes
398 searching for changes
398 adding changesets
399 adding changesets
399 adding manifests
400 adding manifests
400 adding file changes
401 adding file changes
401 added 1 changesets with 1 changes to 1 files (+1 heads)
402 added 1 changesets with 1 changes to 1 files (+1 heads)
402 updating to 2:7837755a2789
403 updating to 2:7837755a2789
403 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
404 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
404 merging with 1:d1f0c6c48ebd
405 merging with 1:d1f0c6c48ebd
405 merging a
406 merging a
406 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
407 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
407 new changeset 3:* merges remote changes with local (glob)
408 new changeset 3:* merges remote changes with local (glob)
408 $ hg --cwd i1726r2 heads default --template '{rev}\n'
409 $ hg --cwd i1726r2 heads default --template '{rev}\n'
409 3
410 3
410
411
411 test issue2047
412 test issue2047
412
413
413 $ hg -q init i2047a
414 $ hg -q init i2047a
414 $ cd i2047a
415 $ cd i2047a
415 $ echo a > a
416 $ echo a > a
416 $ hg -q ci -Am a
417 $ hg -q ci -Am a
417 $ hg -q branch stable
418 $ hg -q branch stable
418 $ echo b > b
419 $ echo b > b
419 $ hg -q ci -Am b
420 $ hg -q ci -Am b
420 $ cd ..
421 $ cd ..
421 $ hg -q clone -r 0 i2047a i2047b
422 $ hg -q clone -r 0 i2047a i2047b
422 $ cd i2047b
423 $ cd i2047b
423 $ hg fetch ../i2047a
424 $ hg fetch ../i2047a
424 pulling from ../i2047a
425 pulling from ../i2047a
425 searching for changes
426 searching for changes
426 adding changesets
427 adding changesets
427 adding manifests
428 adding manifests
428 adding file changes
429 adding file changes
429 added 1 changesets with 1 changes to 1 files
430 added 1 changesets with 1 changes to 1 files
430
431
431 $ cd ..
432 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now