##// END OF EJS Templates
fetch: use cmdutil.bailifchanged()...
Martin von Zweigbergk -
r22676:a014fdc9 default
parent child Browse files
Show More
@@ -1,155 +1,149 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 nullid, 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
14
15 cmdtable = {}
15 cmdtable = {}
16 command = cmdutil.command(cmdtable)
16 command = cmdutil.command(cmdtable)
17 testedwith = 'internal'
17 testedwith = 'internal'
18
18
19 @command('fetch',
19 @command('fetch',
20 [('r', 'rev', [],
20 [('r', 'rev', [],
21 _('a specific revision you would like to pull'), _('REV')),
21 _('a specific revision you would like to pull'), _('REV')),
22 ('e', 'edit', None, _('invoke editor on commit messages')),
22 ('e', 'edit', None, _('invoke editor on commit messages')),
23 ('', 'force-editor', None, _('edit commit message (DEPRECATED)')),
23 ('', 'force-editor', None, _('edit commit message (DEPRECATED)')),
24 ('', 'switch-parent', None, _('switch parents when merging')),
24 ('', 'switch-parent', None, _('switch parents when merging')),
25 ] + commands.commitopts + commands.commitopts2 + commands.remoteopts,
25 ] + commands.commitopts + commands.commitopts2 + commands.remoteopts,
26 _('hg fetch [SOURCE]'))
26 _('hg fetch [SOURCE]'))
27 def fetch(ui, repo, source='default', **opts):
27 def fetch(ui, repo, source='default', **opts):
28 '''pull changes from a remote repository, merge new changes if needed.
28 '''pull changes from a remote repository, merge new changes if needed.
29
29
30 This finds all changes from the repository at the specified path
30 This finds all changes from the repository at the specified path
31 or URL and adds them to the local repository.
31 or URL and adds them to the local repository.
32
32
33 If the pulled changes add a new branch head, the head is
33 If the pulled changes add a new branch head, the head is
34 automatically merged, and the result of the merge is committed.
34 automatically merged, and the result of the merge is committed.
35 Otherwise, the working directory is updated to include the new
35 Otherwise, the working directory is updated to include the new
36 changes.
36 changes.
37
37
38 When a merge is needed, the working directory is first updated to
38 When a merge is needed, the working directory is first updated to
39 the newly pulled changes. Local changes are then merged into the
39 the newly pulled changes. Local changes are then merged into the
40 pulled changes. To switch the merge order, use --switch-parent.
40 pulled changes. To switch the merge order, use --switch-parent.
41
41
42 See :hg:`help dates` for a list of formats valid for -d/--date.
42 See :hg:`help dates` for a list of formats valid for -d/--date.
43
43
44 Returns 0 on success.
44 Returns 0 on success.
45 '''
45 '''
46
46
47 date = opts.get('date')
47 date = opts.get('date')
48 if date:
48 if date:
49 opts['date'] = util.parsedate(date)
49 opts['date'] = util.parsedate(date)
50
50
51 parent, p2 = repo.dirstate.parents()
51 parent, _p2 = repo.dirstate.parents()
52 branch = repo.dirstate.branch()
52 branch = repo.dirstate.branch()
53 try:
53 try:
54 branchnode = repo.branchtip(branch)
54 branchnode = repo.branchtip(branch)
55 except error.RepoLookupError:
55 except error.RepoLookupError:
56 branchnode = None
56 branchnode = None
57 if parent != branchnode:
57 if parent != branchnode:
58 raise util.Abort(_('working dir not at branch tip '
58 raise util.Abort(_('working dir not at branch tip '
59 '(use "hg update" to check out branch tip)'))
59 '(use "hg update" to check out branch tip)'))
60
60
61 if p2 != nullid:
62 raise util.Abort(_('outstanding uncommitted merge'))
63
64 wlock = lock = None
61 wlock = lock = None
65 try:
62 try:
66 wlock = repo.wlock()
63 wlock = repo.wlock()
67 lock = repo.lock()
64 lock = repo.lock()
68 mod, add, rem, del_ = repo.status()[:4]
69
65
70 if mod or add or rem:
66 cmdutil.bailifchanged(repo)
71 raise util.Abort(_('outstanding uncommitted changes'))
67
72 if del_:
73 raise util.Abort(_('working directory is missing some files'))
74 bheads = repo.branchheads(branch)
68 bheads = repo.branchheads(branch)
75 bheads = [head for head in bheads if len(repo[head].children()) == 0]
69 bheads = [head for head in bheads if len(repo[head].children()) == 0]
76 if len(bheads) > 1:
70 if len(bheads) > 1:
77 raise util.Abort(_('multiple heads in this branch '
71 raise util.Abort(_('multiple heads in this branch '
78 '(use "hg heads ." and "hg merge" to merge)'))
72 '(use "hg heads ." and "hg merge" to merge)'))
79
73
80 other = hg.peer(repo, opts, ui.expandpath(source))
74 other = hg.peer(repo, opts, ui.expandpath(source))
81 ui.status(_('pulling from %s\n') %
75 ui.status(_('pulling from %s\n') %
82 util.hidepassword(ui.expandpath(source)))
76 util.hidepassword(ui.expandpath(source)))
83 revs = None
77 revs = None
84 if opts['rev']:
78 if opts['rev']:
85 try:
79 try:
86 revs = [other.lookup(rev) for rev in opts['rev']]
80 revs = [other.lookup(rev) for rev in opts['rev']]
87 except error.CapabilityError:
81 except error.CapabilityError:
88 err = _("other repository doesn't support revision lookup, "
82 err = _("other repository doesn't support revision lookup, "
89 "so a rev cannot be specified.")
83 "so a rev cannot be specified.")
90 raise util.Abort(err)
84 raise util.Abort(err)
91
85
92 # Are there any changes at all?
86 # Are there any changes at all?
93 modheads = repo.pull(other, heads=revs)
87 modheads = repo.pull(other, heads=revs)
94 if modheads == 0:
88 if modheads == 0:
95 return 0
89 return 0
96
90
97 # Is this a simple fast-forward along the current branch?
91 # Is this a simple fast-forward along the current branch?
98 newheads = repo.branchheads(branch)
92 newheads = repo.branchheads(branch)
99 newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
93 newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
100 if len(newheads) == 1 and len(newchildren):
94 if len(newheads) == 1 and len(newchildren):
101 if newchildren[0] != parent:
95 if newchildren[0] != parent:
102 return hg.update(repo, newchildren[0])
96 return hg.update(repo, newchildren[0])
103 else:
97 else:
104 return 0
98 return 0
105
99
106 # Are there more than one additional branch heads?
100 # Are there more than one additional branch heads?
107 newchildren = [n for n in newchildren if n != parent]
101 newchildren = [n for n in newchildren if n != parent]
108 newparent = parent
102 newparent = parent
109 if newchildren:
103 if newchildren:
110 newparent = newchildren[0]
104 newparent = newchildren[0]
111 hg.clean(repo, newparent)
105 hg.clean(repo, newparent)
112 newheads = [n for n in newheads if n != newparent]
106 newheads = [n for n in newheads if n != newparent]
113 if len(newheads) > 1:
107 if len(newheads) > 1:
114 ui.status(_('not merging with %d other new branch heads '
108 ui.status(_('not merging with %d other new branch heads '
115 '(use "hg heads ." and "hg merge" to merge them)\n') %
109 '(use "hg heads ." and "hg merge" to merge them)\n') %
116 (len(newheads) - 1))
110 (len(newheads) - 1))
117 return 1
111 return 1
118
112
119 if not newheads:
113 if not newheads:
120 return 0
114 return 0
121
115
122 # Otherwise, let's merge.
116 # Otherwise, let's merge.
123 err = False
117 err = False
124 if newheads:
118 if newheads:
125 # By default, we consider the repository we're pulling
119 # By default, we consider the repository we're pulling
126 # *from* as authoritative, so we merge our changes into
120 # *from* as authoritative, so we merge our changes into
127 # theirs.
121 # theirs.
128 if opts['switch_parent']:
122 if opts['switch_parent']:
129 firstparent, secondparent = newparent, newheads[0]
123 firstparent, secondparent = newparent, newheads[0]
130 else:
124 else:
131 firstparent, secondparent = newheads[0], newparent
125 firstparent, secondparent = newheads[0], newparent
132 ui.status(_('updating to %d:%s\n') %
126 ui.status(_('updating to %d:%s\n') %
133 (repo.changelog.rev(firstparent),
127 (repo.changelog.rev(firstparent),
134 short(firstparent)))
128 short(firstparent)))
135 hg.clean(repo, firstparent)
129 hg.clean(repo, firstparent)
136 ui.status(_('merging with %d:%s\n') %
130 ui.status(_('merging with %d:%s\n') %
137 (repo.changelog.rev(secondparent), short(secondparent)))
131 (repo.changelog.rev(secondparent), short(secondparent)))
138 err = hg.merge(repo, secondparent, remind=False)
132 err = hg.merge(repo, secondparent, remind=False)
139
133
140 if not err:
134 if not err:
141 # we don't translate commit messages
135 # we don't translate commit messages
142 message = (cmdutil.logmessage(ui, opts) or
136 message = (cmdutil.logmessage(ui, opts) or
143 ('Automated merge with %s' %
137 ('Automated merge with %s' %
144 util.removeauth(other.url())))
138 util.removeauth(other.url())))
145 editopt = opts.get('edit') or opts.get('force_editor')
139 editopt = opts.get('edit') or opts.get('force_editor')
146 editor = cmdutil.getcommiteditor(edit=editopt, editform='fetch')
140 editor = cmdutil.getcommiteditor(edit=editopt, editform='fetch')
147 n = repo.commit(message, opts['user'], opts['date'], editor=editor)
141 n = repo.commit(message, opts['user'], opts['date'], editor=editor)
148 ui.status(_('new changeset %d:%s merges remote changes '
142 ui.status(_('new changeset %d:%s merges remote changes '
149 'with local\n') % (repo.changelog.rev(n),
143 'with local\n') % (repo.changelog.rev(n),
150 short(n)))
144 short(n)))
151
145
152 return err
146 return err
153
147
154 finally:
148 finally:
155 release(lock, wlock)
149 release(lock, wlock)
@@ -1,431 +1,431 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: working directory is missing some files
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 dir not at branch tip (use "hg update" to check out branch tip)
342 abort: working dir not at branch tip (use "hg update" to check out branch tip)
343 [255]
343 [255]
344
344
345 parent should be 0 (fetch did not update or merge anything)
345 parent should be 0 (fetch did not update or merge anything)
346
346
347 $ hg -R n2 parents --template '{rev}\n'
347 $ hg -R n2 parents --template '{rev}\n'
348 0
348 0
349 $ rm -fr n1 n2
349 $ rm -fr n1 n2
350
350
351 test fetch with inactive branches
351 test fetch with inactive branches
352
352
353 $ hg init ib1
353 $ hg init ib1
354 $ echo a > ib1/a
354 $ echo a > ib1/a
355 $ hg --cwd ib1 ci -Am base
355 $ hg --cwd ib1 ci -Am base
356 adding a
356 adding a
357 $ hg --cwd ib1 branch second
357 $ hg --cwd ib1 branch second
358 marked working directory as branch second
358 marked working directory as branch second
359 (branches are permanent and global, did you want a bookmark?)
359 (branches are permanent and global, did you want a bookmark?)
360 $ echo b > ib1/b
360 $ echo b > ib1/b
361 $ hg --cwd ib1 ci -Am onsecond
361 $ hg --cwd ib1 ci -Am onsecond
362 adding b
362 adding b
363 $ hg --cwd ib1 branch -f default
363 $ hg --cwd ib1 branch -f default
364 marked working directory as branch default
364 marked working directory as branch default
365 (branches are permanent and global, did you want a bookmark?)
365 (branches are permanent and global, did you want a bookmark?)
366 $ echo c > ib1/c
366 $ echo c > ib1/c
367 $ hg --cwd ib1 ci -Am newdefault
367 $ hg --cwd ib1 ci -Am newdefault
368 adding c
368 adding c
369 created new head
369 created new head
370 $ hg clone ib1 ib2
370 $ hg clone ib1 ib2
371 updating to branch default
371 updating to branch default
372 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
372 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
373
373
374 fetch should succeed
374 fetch should succeed
375
375
376 $ hg --cwd ib2 fetch ../ib1
376 $ hg --cwd ib2 fetch ../ib1
377 pulling from ../ib1
377 pulling from ../ib1
378 searching for changes
378 searching for changes
379 no changes found
379 no changes found
380 $ rm -fr ib1 ib2
380 $ rm -fr ib1 ib2
381
381
382 test issue1726
382 test issue1726
383
383
384 $ hg init i1726r1
384 $ hg init i1726r1
385 $ echo a > i1726r1/a
385 $ echo a > i1726r1/a
386 $ hg --cwd i1726r1 ci -Am base
386 $ hg --cwd i1726r1 ci -Am base
387 adding a
387 adding a
388 $ hg clone i1726r1 i1726r2
388 $ hg clone i1726r1 i1726r2
389 updating to branch default
389 updating to branch default
390 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
390 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
391 $ echo b > i1726r1/a
391 $ echo b > i1726r1/a
392 $ hg --cwd i1726r1 ci -m second
392 $ hg --cwd i1726r1 ci -m second
393 $ echo c > i1726r2/a
393 $ echo c > i1726r2/a
394 $ hg --cwd i1726r2 ci -m third
394 $ hg --cwd i1726r2 ci -m third
395 $ HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1
395 $ HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1
396 pulling from ../i1726r1
396 pulling from ../i1726r1
397 searching for changes
397 searching for changes
398 adding changesets
398 adding changesets
399 adding manifests
399 adding manifests
400 adding file changes
400 adding file changes
401 added 1 changesets with 1 changes to 1 files (+1 heads)
401 added 1 changesets with 1 changes to 1 files (+1 heads)
402 updating to 2:7837755a2789
402 updating to 2:7837755a2789
403 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
403 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
404 merging with 1:d1f0c6c48ebd
404 merging with 1:d1f0c6c48ebd
405 merging a
405 merging a
406 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
406 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
407 new changeset 3:* merges remote changes with local (glob)
407 new changeset 3:* merges remote changes with local (glob)
408 $ hg --cwd i1726r2 heads default --template '{rev}\n'
408 $ hg --cwd i1726r2 heads default --template '{rev}\n'
409 3
409 3
410
410
411 test issue2047
411 test issue2047
412
412
413 $ hg -q init i2047a
413 $ hg -q init i2047a
414 $ cd i2047a
414 $ cd i2047a
415 $ echo a > a
415 $ echo a > a
416 $ hg -q ci -Am a
416 $ hg -q ci -Am a
417 $ hg -q branch stable
417 $ hg -q branch stable
418 $ echo b > b
418 $ echo b > b
419 $ hg -q ci -Am b
419 $ hg -q ci -Am b
420 $ cd ..
420 $ cd ..
421 $ hg -q clone -r 0 i2047a i2047b
421 $ hg -q clone -r 0 i2047a i2047b
422 $ cd i2047b
422 $ cd i2047b
423 $ hg fetch ../i2047a
423 $ hg fetch ../i2047a
424 pulling from ../i2047a
424 pulling from ../i2047a
425 searching for changes
425 searching for changes
426 adding changesets
426 adding changesets
427 adding manifests
427 adding manifests
428 adding file changes
428 adding file changes
429 added 1 changesets with 1 changes to 1 files
429 added 1 changesets with 1 changes to 1 files
430
430
431 $ cd ..
431 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now