##// END OF EJS Templates
fetch: use "getcommiteditor()" instead of explicit editor choice...
FUJIWARA Katsunori -
r21406:288a793c default
parent child Browse files
Show More
@@ -1,156 +1,155 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 nullid, 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, _('edit commit message')),
22 ('e', 'edit', None, _('edit commit message')),
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:
61 if p2 != nullid:
62 raise util.Abort(_('outstanding uncommitted merge'))
62 raise util.Abort(_('outstanding uncommitted merge'))
63
63
64 wlock = lock = None
64 wlock = lock = None
65 try:
65 try:
66 wlock = repo.wlock()
66 wlock = repo.wlock()
67 lock = repo.lock()
67 lock = repo.lock()
68 mod, add, rem, del_ = repo.status()[:4]
68 mod, add, rem, del_ = repo.status()[:4]
69
69
70 if mod or add or rem:
70 if mod or add or rem:
71 raise util.Abort(_('outstanding uncommitted changes'))
71 raise util.Abort(_('outstanding uncommitted changes'))
72 if del_:
72 if del_:
73 raise util.Abort(_('working directory is missing some files'))
73 raise util.Abort(_('working directory is missing some files'))
74 bheads = repo.branchheads(branch)
74 bheads = repo.branchheads(branch)
75 bheads = [head for head in bheads if len(repo[head].children()) == 0]
75 bheads = [head for head in bheads if len(repo[head].children()) == 0]
76 if len(bheads) > 1:
76 if len(bheads) > 1:
77 raise util.Abort(_('multiple heads in this branch '
77 raise util.Abort(_('multiple heads in this branch '
78 '(use "hg heads ." and "hg merge" to merge)'))
78 '(use "hg heads ." and "hg merge" to merge)'))
79
79
80 other = hg.peer(repo, opts, ui.expandpath(source))
80 other = hg.peer(repo, opts, ui.expandpath(source))
81 ui.status(_('pulling from %s\n') %
81 ui.status(_('pulling from %s\n') %
82 util.hidepassword(ui.expandpath(source)))
82 util.hidepassword(ui.expandpath(source)))
83 revs = None
83 revs = None
84 if opts['rev']:
84 if opts['rev']:
85 try:
85 try:
86 revs = [other.lookup(rev) for rev in opts['rev']]
86 revs = [other.lookup(rev) for rev in opts['rev']]
87 except error.CapabilityError:
87 except error.CapabilityError:
88 err = _("other repository doesn't support revision lookup, "
88 err = _("other repository doesn't support revision lookup, "
89 "so a rev cannot be specified.")
89 "so a rev cannot be specified.")
90 raise util.Abort(err)
90 raise util.Abort(err)
91
91
92 # Are there any changes at all?
92 # Are there any changes at all?
93 modheads = repo.pull(other, heads=revs)
93 modheads = repo.pull(other, heads=revs)
94 if modheads == 0:
94 if modheads == 0:
95 return 0
95 return 0
96
96
97 # Is this a simple fast-forward along the current branch?
97 # Is this a simple fast-forward along the current branch?
98 newheads = repo.branchheads(branch)
98 newheads = repo.branchheads(branch)
99 newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
99 newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
100 if len(newheads) == 1 and len(newchildren):
100 if len(newheads) == 1 and len(newchildren):
101 if newchildren[0] != parent:
101 if newchildren[0] != parent:
102 return hg.update(repo, newchildren[0])
102 return hg.update(repo, newchildren[0])
103 else:
103 else:
104 return 0
104 return 0
105
105
106 # Are there more than one additional branch heads?
106 # Are there more than one additional branch heads?
107 newchildren = [n for n in newchildren if n != parent]
107 newchildren = [n for n in newchildren if n != parent]
108 newparent = parent
108 newparent = parent
109 if newchildren:
109 if newchildren:
110 newparent = newchildren[0]
110 newparent = newchildren[0]
111 hg.clean(repo, newparent)
111 hg.clean(repo, newparent)
112 newheads = [n for n in newheads if n != newparent]
112 newheads = [n for n in newheads if n != newparent]
113 if len(newheads) > 1:
113 if len(newheads) > 1:
114 ui.status(_('not merging with %d other new branch heads '
114 ui.status(_('not merging with %d other new branch heads '
115 '(use "hg heads ." and "hg merge" to merge them)\n') %
115 '(use "hg heads ." and "hg merge" to merge them)\n') %
116 (len(newheads) - 1))
116 (len(newheads) - 1))
117 return 1
117 return 1
118
118
119 if not newheads:
119 if not newheads:
120 return 0
120 return 0
121
121
122 # Otherwise, let's merge.
122 # Otherwise, let's merge.
123 err = False
123 err = False
124 if newheads:
124 if newheads:
125 # By default, we consider the repository we're pulling
125 # By default, we consider the repository we're pulling
126 # *from* as authoritative, so we merge our changes into
126 # *from* as authoritative, so we merge our changes into
127 # theirs.
127 # theirs.
128 if opts['switch_parent']:
128 if opts['switch_parent']:
129 firstparent, secondparent = newparent, newheads[0]
129 firstparent, secondparent = newparent, newheads[0]
130 else:
130 else:
131 firstparent, secondparent = newheads[0], newparent
131 firstparent, secondparent = newheads[0], newparent
132 ui.status(_('updating to %d:%s\n') %
132 ui.status(_('updating to %d:%s\n') %
133 (repo.changelog.rev(firstparent),
133 (repo.changelog.rev(firstparent),
134 short(firstparent)))
134 short(firstparent)))
135 hg.clean(repo, firstparent)
135 hg.clean(repo, firstparent)
136 ui.status(_('merging with %d:%s\n') %
136 ui.status(_('merging with %d:%s\n') %
137 (repo.changelog.rev(secondparent), short(secondparent)))
137 (repo.changelog.rev(secondparent), short(secondparent)))
138 err = hg.merge(repo, secondparent, remind=False)
138 err = hg.merge(repo, secondparent, remind=False)
139
139
140 if not err:
140 if not err:
141 # we don't translate commit messages
141 # we don't translate commit messages
142 message = (cmdutil.logmessage(ui, opts) or
142 message = (cmdutil.logmessage(ui, opts) or
143 ('Automated merge with %s' %
143 ('Automated merge with %s' %
144 util.removeauth(other.url())))
144 util.removeauth(other.url())))
145 editor = cmdutil.commiteditor
145 editopt = opts.get('edit') or opts.get('force_editor')
146 if opts.get('force_editor') or opts.get('edit'):
146 n = repo.commit(message, opts['user'], opts['date'],
147 editor = cmdutil.commitforceeditor
147 editor=cmdutil.getcommiteditor(edit=editopt))
148 n = repo.commit(message, opts['user'], opts['date'], editor=editor)
149 ui.status(_('new changeset %d:%s merges remote changes '
148 ui.status(_('new changeset %d:%s merges remote changes '
150 'with local\n') % (repo.changelog.rev(n),
149 'with local\n') % (repo.changelog.rev(n),
151 short(n)))
150 short(n)))
152
151
153 return err
152 return err
154
153
155 finally:
154 finally:
156 release(lock, wlock)
155 release(lock, wlock)
@@ -1,414 +1,431 b''
1 $ "$TESTDIR/hghave" serve || exit 80
1 $ "$TESTDIR/hghave" serve || exit 80
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
72
72 $ hg --cwd d fetch http://localhost:$HGPORT/
73 $ HGEDITOR=cat hg --cwd d fetch --edit http://localhost:$HGPORT/
73 pulling from http://localhost:$HGPORT/
74 pulling from http://localhost:$HGPORT/
74 searching for changes
75 searching for changes
75 adding changesets
76 adding changesets
76 adding manifests
77 adding manifests
77 adding file changes
78 adding file changes
78 added 1 changesets with 1 changes to 1 files (+1 heads)
79 added 1 changesets with 1 changes to 1 files (+1 heads)
79 updating to 2:d2ae7f538514
80 updating to 2:d2ae7f538514
80 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
81 merging with 1:d36c0562f908
82 merging with 1:d36c0562f908
82 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/
85
86
87 HG: Enter commit message. Lines beginning with 'HG:' are removed.
88 HG: Leave message empty to abort commit.
89 HG: --
90 HG: user: test
91 HG: branch merge
92 HG: branch 'default'
93 HG: changed c
83 new changeset 3:* merges remote changes with local (glob)
94 new changeset 3:* merges remote changes with local (glob)
84 $ hg --cwd d tip --template '{desc}\n'
95 $ hg --cwd d tip --template '{desc}\n'
85 Automated merge with http://localhost:$HGPORT/
96 Automated merge with http://localhost:$HGPORT/
97 $ hg --cwd d status --rev 'tip^1' --rev tip
98 A c
99 $ hg --cwd d status --rev 'tip^2' --rev tip
100 A b
86
101
87 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
104 specified, even though commit message is not specified explicitly)
88
105
89 $ hg --cwd e fetch http://user:password@localhost:$HGPORT/
106 $ HGEDITOR=cat hg --cwd e fetch http://user:password@localhost:$HGPORT/
90 pulling from http://user:***@localhost:$HGPORT/
107 pulling from http://user:***@localhost:$HGPORT/
91 searching for changes
108 searching for changes
92 adding changesets
109 adding changesets
93 adding manifests
110 adding manifests
94 adding file changes
111 adding file changes
95 added 1 changesets with 1 changes to 1 files (+1 heads)
112 added 1 changesets with 1 changes to 1 files (+1 heads)
96 updating to 2:d2ae7f538514
113 updating to 2:d2ae7f538514
97 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
98 merging with 1:d36c0562f908
115 merging with 1:d36c0562f908
99 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
100 new changeset 3:* merges remote changes with local (glob)
117 new changeset 3:* merges remote changes with local (glob)
101 $ hg --cwd e tip --template '{desc}\n'
118 $ hg --cwd e tip --template '{desc}\n'
102 Automated merge with http://localhost:$HGPORT/
119 Automated merge with http://localhost:$HGPORT/
103 $ hg clone a f
120 $ hg clone a f
104 updating to branch default
121 updating to branch default
105 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
106 $ hg clone a g
123 $ hg clone a g
107 updating to branch default
124 updating to branch default
108 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
109 $ echo f > f/f
126 $ echo f > f/f
110 $ hg --cwd f ci -Amf
127 $ hg --cwd f ci -Amf
111 adding f
128 adding f
112 $ echo g > g/g
129 $ echo g > g/g
113 $ hg --cwd g ci -Amg
130 $ hg --cwd g ci -Amg
114 adding g
131 adding g
115 $ hg clone -q f h
132 $ hg clone -q f h
116 $ hg clone -q g i
133 $ hg clone -q g i
117
134
118 should merge f into g
135 should merge f into g
119
136
120 $ 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
121 pulling from ../f
138 pulling from ../f
122 searching for changes
139 searching for changes
123 adding changesets
140 adding changesets
124 adding manifests
141 adding manifests
125 adding file changes
142 adding file changes
126 added 1 changesets with 1 changes to 1 files (+1 heads)
143 added 1 changesets with 1 changes to 1 files (+1 heads)
127 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
128 merging with 3:6343ca3eff20
145 merging with 3:6343ca3eff20
129 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
130 new changeset 4:f7faa0b7d3c6 merges remote changes with local
147 new changeset 4:f7faa0b7d3c6 merges remote changes with local
131 $ rm i/g
148 $ rm i/g
132
149
133 should abort, because i is modified
150 should abort, because i is modified
134
151
135 $ hg --cwd i fetch ../h
152 $ hg --cwd i fetch ../h
136 abort: working directory is missing some files
153 abort: working directory is missing some files
137 [255]
154 [255]
138
155
139 test fetch with named branches
156 test fetch with named branches
140
157
141 $ hg init nbase
158 $ hg init nbase
142 $ echo base > nbase/a
159 $ echo base > nbase/a
143 $ hg -R nbase ci -Am base
160 $ hg -R nbase ci -Am base
144 adding a
161 adding a
145 $ hg -R nbase branch a
162 $ hg -R nbase branch a
146 marked working directory as branch a
163 marked working directory as branch a
147 (branches are permanent and global, did you want a bookmark?)
164 (branches are permanent and global, did you want a bookmark?)
148 $ echo a > nbase/a
165 $ echo a > nbase/a
149 $ hg -R nbase ci -m a
166 $ hg -R nbase ci -m a
150 $ hg -R nbase up -C 0
167 $ hg -R nbase up -C 0
151 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
152 $ hg -R nbase branch b
169 $ hg -R nbase branch b
153 marked working directory as branch b
170 marked working directory as branch b
154 (branches are permanent and global, did you want a bookmark?)
171 (branches are permanent and global, did you want a bookmark?)
155 $ echo b > nbase/b
172 $ echo b > nbase/b
156 $ hg -R nbase ci -Am b
173 $ hg -R nbase ci -Am b
157 adding b
174 adding b
158
175
159 pull in change on foreign branch
176 pull in change on foreign branch
160
177
161 $ hg clone nbase n1
178 $ hg clone nbase n1
162 updating to branch default
179 updating to branch default
163 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
164 $ hg clone nbase n2
181 $ hg clone nbase n2
165 updating to branch default
182 updating to branch default
166 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
167 $ hg -R n1 up -C a
184 $ hg -R n1 up -C a
168 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
169 $ echo aa > n1/a
186 $ echo aa > n1/a
170 $ hg -R n1 ci -m a1
187 $ hg -R n1 ci -m a1
171 $ hg -R n2 up -C b
188 $ hg -R n2 up -C b
172 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
173 $ hg -R n2 fetch -m 'merge' n1
190 $ hg -R n2 fetch -m 'merge' n1
174 pulling from n1
191 pulling from n1
175 searching for changes
192 searching for changes
176 adding changesets
193 adding changesets
177 adding manifests
194 adding manifests
178 adding file changes
195 adding file changes
179 added 1 changesets with 1 changes to 1 files
196 added 1 changesets with 1 changes to 1 files
180
197
181 parent should be 2 (no automatic update)
198 parent should be 2 (no automatic update)
182
199
183 $ hg -R n2 parents --template '{rev}\n'
200 $ hg -R n2 parents --template '{rev}\n'
184 2
201 2
185 $ rm -fr n1 n2
202 $ rm -fr n1 n2
186
203
187 pull in changes on both foreign and local branches
204 pull in changes on both foreign and local branches
188
205
189 $ hg clone nbase n1
206 $ hg clone nbase n1
190 updating to branch default
207 updating to branch default
191 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
192 $ hg clone nbase n2
209 $ hg clone nbase n2
193 updating to branch default
210 updating to branch default
194 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
195 $ hg -R n1 up -C a
212 $ hg -R n1 up -C a
196 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
197 $ echo aa > n1/a
214 $ echo aa > n1/a
198 $ hg -R n1 ci -m a1
215 $ hg -R n1 ci -m a1
199 $ hg -R n1 up -C b
216 $ hg -R n1 up -C b
200 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
201 $ echo bb > n1/b
218 $ echo bb > n1/b
202 $ hg -R n1 ci -m b1
219 $ hg -R n1 ci -m b1
203 $ hg -R n2 up -C b
220 $ hg -R n2 up -C b
204 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
205 $ hg -R n2 fetch -m 'merge' n1
222 $ hg -R n2 fetch -m 'merge' n1
206 pulling from n1
223 pulling from n1
207 searching for changes
224 searching for changes
208 adding changesets
225 adding changesets
209 adding manifests
226 adding manifests
210 adding file changes
227 adding file changes
211 added 2 changesets with 2 changes to 2 files
228 added 2 changesets with 2 changes to 2 files
212 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
213
230
214 parent should be 4 (fast forward)
231 parent should be 4 (fast forward)
215
232
216 $ hg -R n2 parents --template '{rev}\n'
233 $ hg -R n2 parents --template '{rev}\n'
217 4
234 4
218 $ rm -fr n1 n2
235 $ rm -fr n1 n2
219
236
220 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
221 with a local change
238 with a local change
222
239
223 $ hg clone nbase n1
240 $ hg clone nbase n1
224 updating to branch default
241 updating to branch default
225 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
226 $ hg clone nbase n2
243 $ hg clone nbase n2
227 updating to branch default
244 updating to branch default
228 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
229 $ hg -R n1 up -C a
246 $ hg -R n1 up -C a
230 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
231 $ echo a1 > n1/a
248 $ echo a1 > n1/a
232 $ hg -R n1 ci -m a1
249 $ hg -R n1 ci -m a1
233 $ hg -R n1 up -C b
250 $ hg -R n1 up -C b
234 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
235 $ echo bb > n1/b
252 $ echo bb > n1/b
236 $ hg -R n1 ci -m b1
253 $ hg -R n1 ci -m b1
237 $ hg -R n1 up -C 1
254 $ hg -R n1 up -C 1
238 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
239 $ echo a2 > n1/a
256 $ echo a2 > n1/a
240 $ hg -R n1 ci -m a2
257 $ hg -R n1 ci -m a2
241 created new head
258 created new head
242 $ hg -R n2 up -C b
259 $ hg -R n2 up -C b
243 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
244 $ echo change >> n2/c
261 $ echo change >> n2/c
245 $ hg -R n2 ci -A -m local
262 $ hg -R n2 ci -A -m local
246 adding c
263 adding c
247 $ hg -R n2 fetch -d '0 0' -m 'merge' n1
264 $ hg -R n2 fetch -d '0 0' -m 'merge' n1
248 pulling from n1
265 pulling from n1
249 searching for changes
266 searching for changes
250 adding changesets
267 adding changesets
251 adding manifests
268 adding manifests
252 adding file changes
269 adding file changes
253 added 3 changesets with 3 changes to 2 files (+2 heads)
270 added 3 changesets with 3 changes to 2 files (+2 heads)
254 updating to 5:3c4a837a864f
271 updating to 5:3c4a837a864f
255 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
256 merging with 3:1267f84a9ea5
273 merging with 3:1267f84a9ea5
257 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
258 new changeset 7:2cf2a1261f21 merges remote changes with local
275 new changeset 7:2cf2a1261f21 merges remote changes with local
259
276
260 parent should be 7 (new merge changeset)
277 parent should be 7 (new merge changeset)
261
278
262 $ hg -R n2 parents --template '{rev}\n'
279 $ hg -R n2 parents --template '{rev}\n'
263 7
280 7
264 $ rm -fr n1 n2
281 $ rm -fr n1 n2
265
282
266 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
267 heads) with a local change
284 heads) with a local change
268
285
269 $ hg clone nbase n1
286 $ hg clone nbase n1
270 updating to branch default
287 updating to branch default
271 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
272 $ hg clone nbase n2
289 $ hg clone nbase n2
273 updating to branch default
290 updating to branch default
274 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
275 $ hg -R n1 up -C a
292 $ hg -R n1 up -C a
276 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
277 $ hg -R n1 merge b
294 $ hg -R n1 merge b
278 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
279 (branch merge, don't forget to commit)
296 (branch merge, don't forget to commit)
280 $ hg -R n1 ci -m merge
297 $ hg -R n1 ci -m merge
281 $ hg -R n1 up -C 2
298 $ hg -R n1 up -C 2
282 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
283 $ echo c > n1/a
300 $ echo c > n1/a
284 $ hg -R n1 ci -m c
301 $ hg -R n1 ci -m c
285 $ hg -R n1 up -C 2
302 $ hg -R n1 up -C 2
286 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
287 $ echo cc > n1/a
304 $ echo cc > n1/a
288 $ hg -R n1 ci -m cc
305 $ hg -R n1 ci -m cc
289 created new head
306 created new head
290 $ hg -R n2 up -C b
307 $ hg -R n2 up -C b
291 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
292 $ echo change >> n2/b
309 $ echo change >> n2/b
293 $ hg -R n2 ci -A -m local
310 $ hg -R n2 ci -A -m local
294 $ hg -R n2 fetch -m 'merge' n1
311 $ hg -R n2 fetch -m 'merge' n1
295 pulling from n1
312 pulling from n1
296 searching for changes
313 searching for changes
297 adding changesets
314 adding changesets
298 adding manifests
315 adding manifests
299 adding file changes
316 adding file changes
300 added 3 changesets with 2 changes to 1 files (+2 heads)
317 added 3 changesets with 2 changes to 1 files (+2 heads)
301 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)
302 [1]
319 [1]
303
320
304 parent should be 3 (fetch did not merge anything)
321 parent should be 3 (fetch did not merge anything)
305
322
306 $ hg -R n2 parents --template '{rev}\n'
323 $ hg -R n2 parents --template '{rev}\n'
307 3
324 3
308 $ rm -fr n1 n2
325 $ rm -fr n1 n2
309
326
310 pull in change on different branch than dirstate
327 pull in change on different branch than dirstate
311
328
312 $ hg init n1
329 $ hg init n1
313 $ echo a > n1/a
330 $ echo a > n1/a
314 $ hg -R n1 ci -Am initial
331 $ hg -R n1 ci -Am initial
315 adding a
332 adding a
316 $ hg clone n1 n2
333 $ hg clone n1 n2
317 updating to branch default
334 updating to branch default
318 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
319 $ echo b > n1/a
336 $ echo b > n1/a
320 $ hg -R n1 ci -m next
337 $ hg -R n1 ci -m next
321 $ hg -R n2 branch topic
338 $ hg -R n2 branch topic
322 marked working directory as branch topic
339 marked working directory as branch topic
323 (branches are permanent and global, did you want a bookmark?)
340 (branches are permanent and global, did you want a bookmark?)
324 $ hg -R n2 fetch -m merge n1
341 $ hg -R n2 fetch -m merge n1
325 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)
326 [255]
343 [255]
327
344
328 parent should be 0 (fetch did not update or merge anything)
345 parent should be 0 (fetch did not update or merge anything)
329
346
330 $ hg -R n2 parents --template '{rev}\n'
347 $ hg -R n2 parents --template '{rev}\n'
331 0
348 0
332 $ rm -fr n1 n2
349 $ rm -fr n1 n2
333
350
334 test fetch with inactive branches
351 test fetch with inactive branches
335
352
336 $ hg init ib1
353 $ hg init ib1
337 $ echo a > ib1/a
354 $ echo a > ib1/a
338 $ hg --cwd ib1 ci -Am base
355 $ hg --cwd ib1 ci -Am base
339 adding a
356 adding a
340 $ hg --cwd ib1 branch second
357 $ hg --cwd ib1 branch second
341 marked working directory as branch second
358 marked working directory as branch second
342 (branches are permanent and global, did you want a bookmark?)
359 (branches are permanent and global, did you want a bookmark?)
343 $ echo b > ib1/b
360 $ echo b > ib1/b
344 $ hg --cwd ib1 ci -Am onsecond
361 $ hg --cwd ib1 ci -Am onsecond
345 adding b
362 adding b
346 $ hg --cwd ib1 branch -f default
363 $ hg --cwd ib1 branch -f default
347 marked working directory as branch default
364 marked working directory as branch default
348 (branches are permanent and global, did you want a bookmark?)
365 (branches are permanent and global, did you want a bookmark?)
349 $ echo c > ib1/c
366 $ echo c > ib1/c
350 $ hg --cwd ib1 ci -Am newdefault
367 $ hg --cwd ib1 ci -Am newdefault
351 adding c
368 adding c
352 created new head
369 created new head
353 $ hg clone ib1 ib2
370 $ hg clone ib1 ib2
354 updating to branch default
371 updating to branch default
355 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
356
373
357 fetch should succeed
374 fetch should succeed
358
375
359 $ hg --cwd ib2 fetch ../ib1
376 $ hg --cwd ib2 fetch ../ib1
360 pulling from ../ib1
377 pulling from ../ib1
361 searching for changes
378 searching for changes
362 no changes found
379 no changes found
363 $ rm -fr ib1 ib2
380 $ rm -fr ib1 ib2
364
381
365 test issue1726
382 test issue1726
366
383
367 $ hg init i1726r1
384 $ hg init i1726r1
368 $ echo a > i1726r1/a
385 $ echo a > i1726r1/a
369 $ hg --cwd i1726r1 ci -Am base
386 $ hg --cwd i1726r1 ci -Am base
370 adding a
387 adding a
371 $ hg clone i1726r1 i1726r2
388 $ hg clone i1726r1 i1726r2
372 updating to branch default
389 updating to branch default
373 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
374 $ echo b > i1726r1/a
391 $ echo b > i1726r1/a
375 $ hg --cwd i1726r1 ci -m second
392 $ hg --cwd i1726r1 ci -m second
376 $ echo c > i1726r2/a
393 $ echo c > i1726r2/a
377 $ hg --cwd i1726r2 ci -m third
394 $ hg --cwd i1726r2 ci -m third
378 $ HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1
395 $ HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1
379 pulling from ../i1726r1
396 pulling from ../i1726r1
380 searching for changes
397 searching for changes
381 adding changesets
398 adding changesets
382 adding manifests
399 adding manifests
383 adding file changes
400 adding file changes
384 added 1 changesets with 1 changes to 1 files (+1 heads)
401 added 1 changesets with 1 changes to 1 files (+1 heads)
385 updating to 2:7837755a2789
402 updating to 2:7837755a2789
386 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
387 merging with 1:d1f0c6c48ebd
404 merging with 1:d1f0c6c48ebd
388 merging a
405 merging a
389 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
390 new changeset 3:* merges remote changes with local (glob)
407 new changeset 3:* merges remote changes with local (glob)
391 $ hg --cwd i1726r2 heads default --template '{rev}\n'
408 $ hg --cwd i1726r2 heads default --template '{rev}\n'
392 3
409 3
393
410
394 test issue2047
411 test issue2047
395
412
396 $ hg -q init i2047a
413 $ hg -q init i2047a
397 $ cd i2047a
414 $ cd i2047a
398 $ echo a > a
415 $ echo a > a
399 $ hg -q ci -Am a
416 $ hg -q ci -Am a
400 $ hg -q branch stable
417 $ hg -q branch stable
401 $ echo b > b
418 $ echo b > b
402 $ hg -q ci -Am b
419 $ hg -q ci -Am b
403 $ cd ..
420 $ cd ..
404 $ hg -q clone -r 0 i2047a i2047b
421 $ hg -q clone -r 0 i2047a i2047b
405 $ cd i2047b
422 $ cd i2047b
406 $ hg fetch ../i2047a
423 $ hg fetch ../i2047a
407 pulling from ../i2047a
424 pulling from ../i2047a
408 searching for changes
425 searching for changes
409 adding changesets
426 adding changesets
410 adding manifests
427 adding manifests
411 adding file changes
428 adding file changes
412 added 1 changesets with 1 changes to 1 files
429 added 1 changesets with 1 changes to 1 files
413
430
414 $ cd ..
431 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now