Show More
@@ -1,141 +1,142 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 |
|
5 | # This software may be used and distributed according to the terms | |
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 | '''pulling, updating and merging in one command''' |
|
7 | '''pulling, updating and merging in one command''' | |
8 |
|
8 | |||
9 | from mercurial.i18n import _ |
|
9 | from mercurial.i18n import _ | |
10 | from mercurial.node import nullid, short |
|
10 | from mercurial.node import nullid, short | |
11 | from mercurial import commands, cmdutil, hg, util |
|
11 | from mercurial import commands, cmdutil, hg, util | |
12 |
|
12 | |||
13 | def fetch(ui, repo, source='default', **opts): |
|
13 | def fetch(ui, repo, source='default', **opts): | |
14 | '''Pull changes from a remote repository, merge new changes if needed. |
|
14 | '''Pull changes from a remote repository, merge new changes if needed. | |
15 |
|
15 | |||
16 | This finds all changes from the repository at the specified path |
|
16 | This finds all changes from the repository at the specified path | |
17 | or URL and adds them to the local repository. |
|
17 | or URL and adds them to the local repository. | |
18 |
|
18 | |||
19 | If the pulled changes add a new branch head, the head is automatically |
|
19 | If the pulled changes add a new branch head, the head is automatically | |
20 | merged, and the result of the merge is committed. Otherwise, the |
|
20 | merged, and the result of the merge is committed. Otherwise, the | |
21 | working directory is updated to include the new changes. |
|
21 | working directory is updated to include the new changes. | |
22 |
|
22 | |||
23 | When a merge occurs, the newly pulled changes are assumed to be |
|
23 | When a merge occurs, the newly pulled changes are assumed to be | |
24 | "authoritative". The head of the new changes is used as the first |
|
24 | "authoritative". The head of the new changes is used as the first | |
25 | parent, with local changes as the second. To switch the merge |
|
25 | parent, with local changes as the second. To switch the merge | |
26 | order, use --switch-parent. |
|
26 | order, use --switch-parent. | |
27 |
|
27 | |||
28 | See 'hg help dates' for a list of formats valid for -d/--date. |
|
28 | See 'hg help dates' for a list of formats valid for -d/--date. | |
29 | ''' |
|
29 | ''' | |
30 |
|
30 | |||
31 | date = opts.get('date') |
|
31 | date = opts.get('date') | |
32 | if date: |
|
32 | if date: | |
33 | opts['date'] = util.parsedate(date) |
|
33 | opts['date'] = util.parsedate(date) | |
34 |
|
34 | |||
35 | parent, p2 = repo.dirstate.parents() |
|
35 | parent, p2 = repo.dirstate.parents() | |
36 |
branch = repo |
|
36 | branch = repo.dirstate.branch() | |
37 | if parent != repo[branch].node(): |
|
37 | branchnode = repo.branchtags().get(branch) | |
|
38 | if parent != branchnode: | |||
38 | raise util.Abort(_('working dir not at branch tip ' |
|
39 | raise util.Abort(_('working dir not at branch tip ' | |
39 | '(use "hg update" to check out branch tip)')) |
|
40 | '(use "hg update" to check out branch tip)')) | |
40 |
|
41 | |||
41 | if p2 != nullid: |
|
42 | if p2 != nullid: | |
42 | raise util.Abort(_('outstanding uncommitted merge')) |
|
43 | raise util.Abort(_('outstanding uncommitted merge')) | |
43 |
|
44 | |||
44 | wlock = lock = None |
|
45 | wlock = lock = None | |
45 | try: |
|
46 | try: | |
46 | wlock = repo.wlock() |
|
47 | wlock = repo.wlock() | |
47 | lock = repo.lock() |
|
48 | lock = repo.lock() | |
48 | mod, add, rem, del_ = repo.status()[:4] |
|
49 | mod, add, rem, del_ = repo.status()[:4] | |
49 |
|
50 | |||
50 | if mod or add or rem: |
|
51 | if mod or add or rem: | |
51 | raise util.Abort(_('outstanding uncommitted changes')) |
|
52 | raise util.Abort(_('outstanding uncommitted changes')) | |
52 | if del_: |
|
53 | if del_: | |
53 | raise util.Abort(_('working directory is missing some files')) |
|
54 | raise util.Abort(_('working directory is missing some files')) | |
54 | if len(repo.branchheads(branch)) > 1: |
|
55 | if len(repo.branchheads(branch)) > 1: | |
55 | raise util.Abort(_('multiple heads in this branch ' |
|
56 | raise util.Abort(_('multiple heads in this branch ' | |
56 | '(use "hg heads ." and "hg merge" to merge)')) |
|
57 | '(use "hg heads ." and "hg merge" to merge)')) | |
57 |
|
58 | |||
58 | cmdutil.setremoteconfig(ui, opts) |
|
59 | cmdutil.setremoteconfig(ui, opts) | |
59 |
|
60 | |||
60 | other = hg.repository(ui, ui.expandpath(source)) |
|
61 | other = hg.repository(ui, ui.expandpath(source)) | |
61 | ui.status(_('pulling from %s\n') % |
|
62 | ui.status(_('pulling from %s\n') % | |
62 | util.hidepassword(ui.expandpath(source))) |
|
63 | util.hidepassword(ui.expandpath(source))) | |
63 | revs = None |
|
64 | revs = None | |
64 | if opts['rev']: |
|
65 | if opts['rev']: | |
65 | if not other.local(): |
|
66 | if not other.local(): | |
66 | raise util.Abort(_("fetch -r doesn't work for remote " |
|
67 | raise util.Abort(_("fetch -r doesn't work for remote " | |
67 | "repositories yet")) |
|
68 | "repositories yet")) | |
68 | else: |
|
69 | else: | |
69 | revs = [other.lookup(rev) for rev in opts['rev']] |
|
70 | revs = [other.lookup(rev) for rev in opts['rev']] | |
70 |
|
71 | |||
71 | # Are there any changes at all? |
|
72 | # Are there any changes at all? | |
72 | modheads = repo.pull(other, heads=revs) |
|
73 | modheads = repo.pull(other, heads=revs) | |
73 | if modheads == 0: |
|
74 | if modheads == 0: | |
74 | return 0 |
|
75 | return 0 | |
75 |
|
76 | |||
76 | # Is this a simple fast-forward along the current branch? |
|
77 | # Is this a simple fast-forward along the current branch? | |
77 | newheads = repo.branchheads(branch) |
|
78 | newheads = repo.branchheads(branch) | |
78 | newchildren = repo.changelog.nodesbetween([parent], newheads)[2] |
|
79 | newchildren = repo.changelog.nodesbetween([parent], newheads)[2] | |
79 | if len(newheads) == 1: |
|
80 | if len(newheads) == 1: | |
80 | if newchildren[0] != parent: |
|
81 | if newchildren[0] != parent: | |
81 | return hg.clean(repo, newchildren[0]) |
|
82 | return hg.clean(repo, newchildren[0]) | |
82 | else: |
|
83 | else: | |
83 | return |
|
84 | return | |
84 |
|
85 | |||
85 | # Are there more than one additional branch heads? |
|
86 | # Are there more than one additional branch heads? | |
86 | newchildren = [n for n in newchildren if n != parent] |
|
87 | newchildren = [n for n in newchildren if n != parent] | |
87 | newparent = parent |
|
88 | newparent = parent | |
88 | if newchildren: |
|
89 | if newchildren: | |
89 | newparent = newchildren[0] |
|
90 | newparent = newchildren[0] | |
90 | hg.clean(repo, newparent) |
|
91 | hg.clean(repo, newparent) | |
91 | newheads = [n for n in newheads if n != newparent] |
|
92 | newheads = [n for n in newheads if n != newparent] | |
92 | if len(newheads) > 1: |
|
93 | if len(newheads) > 1: | |
93 | ui.status(_('not merging with %d other new branch heads ' |
|
94 | ui.status(_('not merging with %d other new branch heads ' | |
94 | '(use "hg heads ." and "hg merge" to merge them)\n') % |
|
95 | '(use "hg heads ." and "hg merge" to merge them)\n') % | |
95 | (len(newheads) - 1)) |
|
96 | (len(newheads) - 1)) | |
96 | return |
|
97 | return | |
97 |
|
98 | |||
98 | # Otherwise, let's merge. |
|
99 | # Otherwise, let's merge. | |
99 | err = False |
|
100 | err = False | |
100 | if newheads: |
|
101 | if newheads: | |
101 | # By default, we consider the repository we're pulling |
|
102 | # By default, we consider the repository we're pulling | |
102 | # *from* as authoritative, so we merge our changes into |
|
103 | # *from* as authoritative, so we merge our changes into | |
103 | # theirs. |
|
104 | # theirs. | |
104 | if opts['switch_parent']: |
|
105 | if opts['switch_parent']: | |
105 | firstparent, secondparent = newparent, newheads[0] |
|
106 | firstparent, secondparent = newparent, newheads[0] | |
106 | else: |
|
107 | else: | |
107 | firstparent, secondparent = newheads[0], newparent |
|
108 | firstparent, secondparent = newheads[0], newparent | |
108 | ui.status(_('updating to %d:%s\n') % |
|
109 | ui.status(_('updating to %d:%s\n') % | |
109 | (repo.changelog.rev(firstparent), |
|
110 | (repo.changelog.rev(firstparent), | |
110 | short(firstparent))) |
|
111 | short(firstparent))) | |
111 | hg.clean(repo, firstparent) |
|
112 | hg.clean(repo, firstparent) | |
112 | ui.status(_('merging with %d:%s\n') % |
|
113 | ui.status(_('merging with %d:%s\n') % | |
113 | (repo.changelog.rev(secondparent), short(secondparent))) |
|
114 | (repo.changelog.rev(secondparent), short(secondparent))) | |
114 | err = hg.merge(repo, secondparent, remind=False) |
|
115 | err = hg.merge(repo, secondparent, remind=False) | |
115 |
|
116 | |||
116 | if not err: |
|
117 | if not err: | |
117 | mod, add, rem = repo.status()[:3] |
|
118 | mod, add, rem = repo.status()[:3] | |
118 | message = (cmdutil.logmessage(opts) or |
|
119 | message = (cmdutil.logmessage(opts) or | |
119 | (_('Automated merge with %s') % |
|
120 | (_('Automated merge with %s') % | |
120 | util.removeauth(other.url()))) |
|
121 | util.removeauth(other.url()))) | |
121 | force_editor = opts.get('force_editor') or opts.get('edit') |
|
122 | force_editor = opts.get('force_editor') or opts.get('edit') | |
122 | n = repo.commit(mod + add + rem, message, |
|
123 | n = repo.commit(mod + add + rem, message, | |
123 | opts['user'], opts['date'], force=True, |
|
124 | opts['user'], opts['date'], force=True, | |
124 | force_editor=force_editor) |
|
125 | force_editor=force_editor) | |
125 | ui.status(_('new changeset %d:%s merges remote changes ' |
|
126 | ui.status(_('new changeset %d:%s merges remote changes ' | |
126 | 'with local\n') % (repo.changelog.rev(n), |
|
127 | 'with local\n') % (repo.changelog.rev(n), | |
127 | short(n))) |
|
128 | short(n))) | |
128 |
|
129 | |||
129 | finally: |
|
130 | finally: | |
130 | del lock, wlock |
|
131 | del lock, wlock | |
131 |
|
132 | |||
132 | cmdtable = { |
|
133 | cmdtable = { | |
133 | 'fetch': |
|
134 | 'fetch': | |
134 | (fetch, |
|
135 | (fetch, | |
135 | [('r', 'rev', [], _('a specific revision you would like to pull')), |
|
136 | [('r', 'rev', [], _('a specific revision you would like to pull')), | |
136 | ('e', 'edit', None, _('edit commit message')), |
|
137 | ('e', 'edit', None, _('edit commit message')), | |
137 | ('', 'force-editor', None, _('edit commit message (DEPRECATED)')), |
|
138 | ('', 'force-editor', None, _('edit commit message (DEPRECATED)')), | |
138 | ('', 'switch-parent', None, _('switch parents when merging')), |
|
139 | ('', 'switch-parent', None, _('switch parents when merging')), | |
139 | ] + commands.commitopts + commands.commitopts2 + commands.remoteopts, |
|
140 | ] + commands.commitopts + commands.commitopts2 + commands.remoteopts, | |
140 | _('hg fetch [SOURCE]')), |
|
141 | _('hg fetch [SOURCE]')), | |
141 | } |
|
142 | } |
@@ -1,159 +1,172 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
3 | # adjust to non-default HGPORT, e.g. with run-tests.py -j |
|
3 | # adjust to non-default HGPORT, e.g. with run-tests.py -j | |
4 | hideport() { sed "s/localhost:$HGPORT/localhost:20059/"; } |
|
4 | hideport() { sed "s/localhost:$HGPORT/localhost:20059/"; } | |
5 | hidehash() { sed "s/changeset 3:............ merges/changeset 3:... merges/"; } |
|
5 | hidehash() { sed "s/changeset 3:............ merges/changeset 3:... merges/"; } | |
6 |
|
6 | |||
7 | echo "[extensions]" >> $HGRCPATH |
|
7 | echo "[extensions]" >> $HGRCPATH | |
8 | echo "fetch=" >> $HGRCPATH |
|
8 | echo "fetch=" >> $HGRCPATH | |
9 |
|
9 | |||
10 | echo % test fetch with default branches only |
|
10 | echo % test fetch with default branches only | |
11 | hg init a |
|
11 | hg init a | |
12 | echo a > a/a |
|
12 | echo a > a/a | |
13 | hg --cwd a commit -d '1 0' -Ama |
|
13 | hg --cwd a commit -d '1 0' -Ama | |
14 |
|
14 | |||
15 | hg clone a b |
|
15 | hg clone a b | |
16 | hg clone a c |
|
16 | hg clone a c | |
17 |
|
17 | |||
18 | echo b > a/b |
|
18 | echo b > a/b | |
19 | hg --cwd a commit -d '2 0' -Amb |
|
19 | hg --cwd a commit -d '2 0' -Amb | |
20 | hg --cwd a parents -q |
|
20 | hg --cwd a parents -q | |
21 |
|
21 | |||
22 | echo % should pull one change |
|
22 | echo % should pull one change | |
23 | hg --cwd b fetch ../a |
|
23 | hg --cwd b fetch ../a | |
24 | hg --cwd b parents -q |
|
24 | hg --cwd b parents -q | |
25 |
|
25 | |||
26 | echo c > c/c |
|
26 | echo c > c/c | |
27 | hg --cwd c commit -d '3 0' -Amc |
|
27 | hg --cwd c commit -d '3 0' -Amc | |
28 |
|
28 | |||
29 | hg clone c d |
|
29 | hg clone c d | |
30 | hg clone c e |
|
30 | hg clone c e | |
31 |
|
31 | |||
32 | # We cannot use the default commit message if fetching from a local |
|
32 | # We cannot use the default commit message if fetching from a local | |
33 | # repo, because the path of the repo will be included in the commit |
|
33 | # repo, because the path of the repo will be included in the commit | |
34 | # message, making every commit appear different. |
|
34 | # message, making every commit appear different. | |
35 |
|
35 | |||
36 | echo % should merge c into a |
|
36 | echo % should merge c into a | |
37 | hg --cwd c fetch -d '4 0' -m 'automated merge' ../a |
|
37 | hg --cwd c fetch -d '4 0' -m 'automated merge' ../a | |
38 | ls c |
|
38 | ls c | |
39 |
|
39 | |||
40 | hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid |
|
40 | hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid | |
41 | cat a/hg.pid >> "$DAEMON_PIDS" |
|
41 | cat a/hg.pid >> "$DAEMON_PIDS" | |
42 |
|
42 | |||
43 | echo '% fetch over http, no auth' |
|
43 | echo '% fetch over http, no auth' | |
44 | hg --cwd d fetch -d '5 0' http://localhost:$HGPORT/ | hideport | hidehash |
|
44 | hg --cwd d fetch -d '5 0' http://localhost:$HGPORT/ | hideport | hidehash | |
45 | hg --cwd d tip --template '{desc}\n' | hideport |
|
45 | hg --cwd d tip --template '{desc}\n' | hideport | |
46 |
|
46 | |||
47 | echo '% fetch over http with auth (should be hidden in desc)' |
|
47 | echo '% fetch over http with auth (should be hidden in desc)' | |
48 | hg --cwd e fetch -d '5 0' http://user:password@localhost:$HGPORT/ | hideport | hidehash |
|
48 | hg --cwd e fetch -d '5 0' http://user:password@localhost:$HGPORT/ | hideport | hidehash | |
49 | hg --cwd e tip --template '{desc}\n' | hideport |
|
49 | hg --cwd e tip --template '{desc}\n' | hideport | |
50 |
|
50 | |||
51 | hg clone a f |
|
51 | hg clone a f | |
52 | hg clone a g |
|
52 | hg clone a g | |
53 |
|
53 | |||
54 | echo f > f/f |
|
54 | echo f > f/f | |
55 | hg --cwd f ci -d '6 0' -Amf |
|
55 | hg --cwd f ci -d '6 0' -Amf | |
56 |
|
56 | |||
57 | echo g > g/g |
|
57 | echo g > g/g | |
58 | hg --cwd g ci -d '6 0' -Amg |
|
58 | hg --cwd g ci -d '6 0' -Amg | |
59 |
|
59 | |||
60 | hg clone -q f h |
|
60 | hg clone -q f h | |
61 | hg clone -q g i |
|
61 | hg clone -q g i | |
62 |
|
62 | |||
63 | echo % should merge f into g |
|
63 | echo % should merge f into g | |
64 | hg --cwd g fetch -d '7 0' --switch -m 'automated merge' ../f |
|
64 | hg --cwd g fetch -d '7 0' --switch -m 'automated merge' ../f | |
65 |
|
65 | |||
66 | rm i/g |
|
66 | rm i/g | |
67 | echo % should abort, because i is modified |
|
67 | echo % should abort, because i is modified | |
68 | hg --cwd i fetch ../h |
|
68 | hg --cwd i fetch ../h | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | echo % test fetch with named branches |
|
71 | echo % test fetch with named branches | |
72 | hg init nbase |
|
72 | hg init nbase | |
73 | echo base > nbase/a |
|
73 | echo base > nbase/a | |
74 | hg -R nbase ci -d '1 0' -Am base |
|
74 | hg -R nbase ci -d '1 0' -Am base | |
75 | hg -R nbase branch a |
|
75 | hg -R nbase branch a | |
76 | echo a > nbase/a |
|
76 | echo a > nbase/a | |
77 | hg -R nbase ci -d '2 0' -m a |
|
77 | hg -R nbase ci -d '2 0' -m a | |
78 | hg -R nbase up -C 0 |
|
78 | hg -R nbase up -C 0 | |
79 | hg -R nbase branch b |
|
79 | hg -R nbase branch b | |
80 | echo b > nbase/b |
|
80 | echo b > nbase/b | |
81 | hg -R nbase ci -Ad '3 0' -m b |
|
81 | hg -R nbase ci -Ad '3 0' -m b | |
82 |
|
82 | |||
83 | echo |
|
83 | echo | |
84 | echo % pull in change on foreign branch |
|
84 | echo % pull in change on foreign branch | |
85 | hg clone nbase n1 |
|
85 | hg clone nbase n1 | |
86 | hg clone nbase n2 |
|
86 | hg clone nbase n2 | |
87 | hg -R n1 up -C a |
|
87 | hg -R n1 up -C a | |
88 | echo aa > n1/a |
|
88 | echo aa > n1/a | |
89 | hg -R n1 ci -d '4 0' -m a1 |
|
89 | hg -R n1 ci -d '4 0' -m a1 | |
90 |
|
90 | |||
91 | hg -R n2 up -C b |
|
91 | hg -R n2 up -C b | |
92 | hg -R n2 fetch -d '9 0' -m 'merge' n1 |
|
92 | hg -R n2 fetch -d '9 0' -m 'merge' n1 | |
93 | echo '% parent should be 2 (no automatic update)' |
|
93 | echo '% parent should be 2 (no automatic update)' | |
94 | hg -R n2 parents --template '{rev}\n' |
|
94 | hg -R n2 parents --template '{rev}\n' | |
95 | rm -fr n1 n2 |
|
95 | rm -fr n1 n2 | |
96 |
|
96 | |||
97 | echo |
|
97 | echo | |
98 | echo % pull in changes on both foreign and local branches |
|
98 | echo % pull in changes on both foreign and local branches | |
99 | hg clone nbase n1 |
|
99 | hg clone nbase n1 | |
100 | hg clone nbase n2 |
|
100 | hg clone nbase n2 | |
101 | hg -R n1 up -C a |
|
101 | hg -R n1 up -C a | |
102 | echo aa > n1/a |
|
102 | echo aa > n1/a | |
103 | hg -R n1 ci -d '4 0' -m a1 |
|
103 | hg -R n1 ci -d '4 0' -m a1 | |
104 | hg -R n1 up -C b |
|
104 | hg -R n1 up -C b | |
105 | echo bb > n1/b |
|
105 | echo bb > n1/b | |
106 | hg -R n1 ci -d '5 0' -m b1 |
|
106 | hg -R n1 ci -d '5 0' -m b1 | |
107 |
|
107 | |||
108 | hg -R n2 up -C b |
|
108 | hg -R n2 up -C b | |
109 | hg -R n2 fetch -d '9 0' -m 'merge' n1 |
|
109 | hg -R n2 fetch -d '9 0' -m 'merge' n1 | |
110 | echo '% parent should be 4 (fast forward)' |
|
110 | echo '% parent should be 4 (fast forward)' | |
111 | hg -R n2 parents --template '{rev}\n' |
|
111 | hg -R n2 parents --template '{rev}\n' | |
112 | rm -fr n1 n2 |
|
112 | rm -fr n1 n2 | |
113 |
|
113 | |||
114 | echo |
|
114 | echo | |
115 | echo '% pull changes on foreign (2 new heads) and local (1 new head) branches' |
|
115 | echo '% pull changes on foreign (2 new heads) and local (1 new head) branches' | |
116 | echo % with a local change |
|
116 | echo % with a local change | |
117 | hg clone nbase n1 |
|
117 | hg clone nbase n1 | |
118 | hg clone nbase n2 |
|
118 | hg clone nbase n2 | |
119 | hg -R n1 up -C a |
|
119 | hg -R n1 up -C a | |
120 | echo a1 > n1/a |
|
120 | echo a1 > n1/a | |
121 | hg -R n1 ci -d '4 0' -m a1 |
|
121 | hg -R n1 ci -d '4 0' -m a1 | |
122 | hg -R n1 up -C b |
|
122 | hg -R n1 up -C b | |
123 | echo bb > n1/b |
|
123 | echo bb > n1/b | |
124 | hg -R n1 ci -d '5 0' -m b1 |
|
124 | hg -R n1 ci -d '5 0' -m b1 | |
125 | hg -R n1 up -C 1 |
|
125 | hg -R n1 up -C 1 | |
126 | echo a2 > n1/a |
|
126 | echo a2 > n1/a | |
127 | hg -R n1 ci -d '6 0' -m a2 |
|
127 | hg -R n1 ci -d '6 0' -m a2 | |
128 |
|
128 | |||
129 | hg -R n2 up -C b |
|
129 | hg -R n2 up -C b | |
130 | echo change >> n2/c |
|
130 | echo change >> n2/c | |
131 | hg -R n2 ci -Ad '7 0' -m local |
|
131 | hg -R n2 ci -Ad '7 0' -m local | |
132 | hg -R n2 fetch -d '9 0' -m 'merge' n1 |
|
132 | hg -R n2 fetch -d '9 0' -m 'merge' n1 | |
133 | echo '% parent should be 7 (new merge changeset)' |
|
133 | echo '% parent should be 7 (new merge changeset)' | |
134 | hg -R n2 parents --template '{rev}\n' |
|
134 | hg -R n2 parents --template '{rev}\n' | |
135 | rm -fr n1 n2 |
|
135 | rm -fr n1 n2 | |
136 |
|
136 | |||
137 | echo '% pull in changes on foreign (merge of local branch) and local (2 new' |
|
137 | echo '% pull in changes on foreign (merge of local branch) and local (2 new' | |
138 | echo '% heads) with a local change' |
|
138 | echo '% heads) with a local change' | |
139 | hg clone nbase n1 |
|
139 | hg clone nbase n1 | |
140 | hg clone nbase n2 |
|
140 | hg clone nbase n2 | |
141 | hg -R n1 up -C a |
|
141 | hg -R n1 up -C a | |
142 | hg -R n1 merge b |
|
142 | hg -R n1 merge b | |
143 | hg -R n1 ci -d '4 0' -m merge |
|
143 | hg -R n1 ci -d '4 0' -m merge | |
144 | hg -R n1 up -C 2 |
|
144 | hg -R n1 up -C 2 | |
145 | echo c > n1/a |
|
145 | echo c > n1/a | |
146 | hg -R n1 ci -d '5 0' -m c |
|
146 | hg -R n1 ci -d '5 0' -m c | |
147 | hg -R n1 up -C 2 |
|
147 | hg -R n1 up -C 2 | |
148 | echo cc > n1/a |
|
148 | echo cc > n1/a | |
149 | hg -R n1 ci -d '6 0' -m cc |
|
149 | hg -R n1 ci -d '6 0' -m cc | |
150 |
|
150 | |||
151 | hg -R n2 up -C b |
|
151 | hg -R n2 up -C b | |
152 | echo change >> n2/b |
|
152 | echo change >> n2/b | |
153 | hg -R n2 ci -Ad '7 0' -m local |
|
153 | hg -R n2 ci -Ad '7 0' -m local | |
154 | hg -R n2 fetch -d '9 0' -m 'merge' n1 |
|
154 | hg -R n2 fetch -d '9 0' -m 'merge' n1 | |
155 | echo '% parent should be 3 (fetch did not merge anything)' |
|
155 | echo '% parent should be 3 (fetch did not merge anything)' | |
156 | hg -R n2 parents --template '{rev}\n' |
|
156 | hg -R n2 parents --template '{rev}\n' | |
157 | rm -fr n1 n2 |
|
157 | rm -fr n1 n2 | |
158 |
|
158 | |||
|
159 | echo % pull in change on different branch than dirstate | |||
|
160 | hg init n1 | |||
|
161 | echo a > n1/a | |||
|
162 | hg -R n1 ci -Am initial | |||
|
163 | hg clone n1 n2 | |||
|
164 | echo b > n1/a | |||
|
165 | hg -R n1 ci -m next | |||
|
166 | hg -R n2 branch topic | |||
|
167 | hg -R n2 fetch -d '0 0' -m merge n1 | |||
|
168 | echo '% parent should be 0 (fetch did not update or merge anything)' | |||
|
169 | hg -R n2 parents --template '{rev}\n' | |||
|
170 | rm -fr n1 n2 | |||
|
171 | ||||
159 | true |
|
172 | true |
@@ -1,172 +1,180 b'' | |||||
1 | % test fetch with default branches only |
|
1 | % test fetch with default branches only | |
2 | adding a |
|
2 | adding a | |
3 | updating working directory |
|
3 | updating working directory | |
4 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
4 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
5 | updating working directory |
|
5 | updating working directory | |
6 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
6 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
7 | adding b |
|
7 | adding b | |
8 | 1:97d72e5f12c7 |
|
8 | 1:97d72e5f12c7 | |
9 | % should pull one change |
|
9 | % should pull one change | |
10 | pulling from ../a |
|
10 | pulling from ../a | |
11 | searching for changes |
|
11 | searching for changes | |
12 | adding changesets |
|
12 | adding changesets | |
13 | adding manifests |
|
13 | adding manifests | |
14 | adding file changes |
|
14 | adding file changes | |
15 | added 1 changesets with 1 changes to 1 files |
|
15 | added 1 changesets with 1 changes to 1 files | |
16 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
16 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
17 | 1:97d72e5f12c7 |
|
17 | 1:97d72e5f12c7 | |
18 | adding c |
|
18 | adding c | |
19 | updating working directory |
|
19 | updating working directory | |
20 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
20 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
21 | updating working directory |
|
21 | updating working directory | |
22 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
22 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
23 | % should merge c into a |
|
23 | % should merge c into a | |
24 | pulling from ../a |
|
24 | pulling from ../a | |
25 | searching for changes |
|
25 | searching for changes | |
26 | adding changesets |
|
26 | adding changesets | |
27 | adding manifests |
|
27 | adding manifests | |
28 | adding file changes |
|
28 | adding file changes | |
29 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
29 | added 1 changesets with 1 changes to 1 files (+1 heads) | |
30 | updating to 2:97d72e5f12c7 |
|
30 | updating to 2:97d72e5f12c7 | |
31 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
31 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
32 | merging with 1:5e056962225c |
|
32 | merging with 1:5e056962225c | |
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 | new changeset 3:cd3a41621cf0 merges remote changes with local |
|
34 | new changeset 3:cd3a41621cf0 merges remote changes with local | |
35 | a |
|
35 | a | |
36 | b |
|
36 | b | |
37 | c |
|
37 | c | |
38 | % fetch over http, no auth |
|
38 | % fetch over http, no auth | |
39 | pulling from http://localhost:20059/ |
|
39 | pulling from http://localhost:20059/ | |
40 | searching for changes |
|
40 | searching for changes | |
41 | adding changesets |
|
41 | adding changesets | |
42 | adding manifests |
|
42 | adding manifests | |
43 | adding file changes |
|
43 | adding file changes | |
44 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
44 | added 1 changesets with 1 changes to 1 files (+1 heads) | |
45 | updating to 2:97d72e5f12c7 |
|
45 | updating to 2:97d72e5f12c7 | |
46 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
46 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
47 | merging with 1:5e056962225c |
|
47 | merging with 1:5e056962225c | |
48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
49 | new changeset 3:... merges remote changes with local |
|
49 | new changeset 3:... merges remote changes with local | |
50 | Automated merge with http://localhost:20059/ |
|
50 | Automated merge with http://localhost:20059/ | |
51 | % fetch over http with auth (should be hidden in desc) |
|
51 | % fetch over http with auth (should be hidden in desc) | |
52 | pulling from http://user:***@localhost:20059/ |
|
52 | pulling from http://user:***@localhost:20059/ | |
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:97d72e5f12c7 |
|
58 | updating to 2:97d72e5f12c7 | |
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:5e056962225c |
|
60 | merging with 1:5e056962225c | |
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:... merges remote changes with local |
|
62 | new changeset 3:... merges remote changes with local | |
63 | Automated merge with http://localhost:20059/ |
|
63 | Automated merge with http://localhost:20059/ | |
64 | updating working directory |
|
64 | updating working directory | |
65 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
65 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
66 | updating working directory |
|
66 | updating working directory | |
67 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
67 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
68 | adding f |
|
68 | adding f | |
69 | adding g |
|
69 | adding g | |
70 | % should merge f into g |
|
70 | % should merge f into g | |
71 | pulling from ../f |
|
71 | pulling from ../f | |
72 | searching for changes |
|
72 | searching for changes | |
73 | adding changesets |
|
73 | adding changesets | |
74 | adding manifests |
|
74 | adding manifests | |
75 | adding file changes |
|
75 | adding file changes | |
76 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
76 | added 1 changesets with 1 changes to 1 files (+1 heads) | |
77 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
77 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
78 | merging with 3:cc6a3744834d |
|
78 | merging with 3:cc6a3744834d | |
79 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
79 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
80 | new changeset 4:55aa4f32ec59 merges remote changes with local |
|
80 | new changeset 4:55aa4f32ec59 merges remote changes with local | |
81 | % should abort, because i is modified |
|
81 | % should abort, because i is modified | |
82 | abort: working directory is missing some files |
|
82 | abort: working directory is missing some files | |
83 | % test fetch with named branches |
|
83 | % test fetch with named branches | |
84 | adding a |
|
84 | adding a | |
85 | marked working directory as branch a |
|
85 | marked working directory as branch a | |
86 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
86 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
87 | marked working directory as branch b |
|
87 | marked working directory as branch b | |
88 | adding b |
|
88 | adding b | |
89 | created new head |
|
89 | created new head | |
90 |
|
90 | |||
91 | % pull in change on foreign branch |
|
91 | % pull in change on foreign branch | |
92 | updating working directory |
|
92 | updating working directory | |
93 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
93 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
94 | updating working directory |
|
94 | updating working directory | |
95 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
95 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
96 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
96 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
97 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
97 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
98 | pulling from n1 |
|
98 | pulling from n1 | |
99 | searching for changes |
|
99 | searching for changes | |
100 | adding changesets |
|
100 | adding changesets | |
101 | adding manifests |
|
101 | adding manifests | |
102 | adding file changes |
|
102 | adding file changes | |
103 | added 1 changesets with 1 changes to 1 files |
|
103 | added 1 changesets with 1 changes to 1 files | |
104 | % parent should be 2 (no automatic update) |
|
104 | % parent should be 2 (no automatic update) | |
105 | 2 |
|
105 | 2 | |
106 |
|
106 | |||
107 | % pull in changes on both foreign and local branches |
|
107 | % pull in changes on both foreign and local branches | |
108 | updating working directory |
|
108 | updating working directory | |
109 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
109 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
110 | updating working directory |
|
110 | updating working directory | |
111 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
111 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
112 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
112 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
113 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
113 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
114 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
114 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
115 | pulling from n1 |
|
115 | pulling from n1 | |
116 | searching for changes |
|
116 | searching for changes | |
117 | adding changesets |
|
117 | adding changesets | |
118 | adding manifests |
|
118 | adding manifests | |
119 | adding file changes |
|
119 | adding file changes | |
120 | added 2 changesets with 2 changes to 2 files |
|
120 | added 2 changesets with 2 changes to 2 files | |
121 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
121 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
122 | % parent should be 4 (fast forward) |
|
122 | % parent should be 4 (fast forward) | |
123 | 4 |
|
123 | 4 | |
124 |
|
124 | |||
125 | % pull changes on foreign (2 new heads) and local (1 new head) branches |
|
125 | % pull changes on foreign (2 new heads) and local (1 new head) branches | |
126 | % with a local change |
|
126 | % with a local change | |
127 | updating working directory |
|
127 | updating working directory | |
128 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
128 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
129 | updating working directory |
|
129 | updating working directory | |
130 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
130 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
131 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
131 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
132 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
132 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
133 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
133 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
134 | created new head |
|
134 | created new head | |
135 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
135 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
136 | adding c |
|
136 | adding c | |
137 | pulling from n1 |
|
137 | pulling from n1 | |
138 | searching for changes |
|
138 | searching for changes | |
139 | adding changesets |
|
139 | adding changesets | |
140 | adding manifests |
|
140 | adding manifests | |
141 | adding file changes |
|
141 | adding file changes | |
142 | added 3 changesets with 3 changes to 2 files (+2 heads) |
|
142 | added 3 changesets with 3 changes to 2 files (+2 heads) | |
143 | updating to 5:708c6cce3d26 |
|
143 | updating to 5:708c6cce3d26 | |
144 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
144 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
145 | merging with 3:d83427717b1f |
|
145 | merging with 3:d83427717b1f | |
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 7:48f1a33f52af merges remote changes with local |
|
147 | new changeset 7:48f1a33f52af merges remote changes with local | |
148 | % parent should be 7 (new merge changeset) |
|
148 | % parent should be 7 (new merge changeset) | |
149 | 7 |
|
149 | 7 | |
150 | % pull in changes on foreign (merge of local branch) and local (2 new |
|
150 | % pull in changes on foreign (merge of local branch) and local (2 new | |
151 | % heads) with a local change |
|
151 | % heads) with a local change | |
152 | updating working directory |
|
152 | updating working directory | |
153 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
153 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
154 | updating working directory |
|
154 | updating working directory | |
155 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
155 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
156 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
156 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
157 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
157 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
158 | (branch merge, don't forget to commit) |
|
158 | (branch merge, don't forget to commit) | |
159 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
159 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
160 | created new head |
|
160 | created new head | |
161 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
161 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
162 | created new head |
|
162 | created new head | |
163 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
163 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
164 | pulling from n1 |
|
164 | pulling from n1 | |
165 | searching for changes |
|
165 | searching for changes | |
166 | adding changesets |
|
166 | adding changesets | |
167 | adding manifests |
|
167 | adding manifests | |
168 | adding file changes |
|
168 | adding file changes | |
169 | added 3 changesets with 2 changes to 1 files (+2 heads) |
|
169 | added 3 changesets with 2 changes to 1 files (+2 heads) | |
170 | not merging with 1 other new branch heads (use "hg heads ." and "hg merge" to merge them) |
|
170 | not merging with 1 other new branch heads (use "hg heads ." and "hg merge" to merge them) | |
171 | % parent should be 3 (fetch did not merge anything) |
|
171 | % parent should be 3 (fetch did not merge anything) | |
172 | 3 |
|
172 | 3 | |
|
173 | % pull in change on different branch than dirstate | |||
|
174 | adding a | |||
|
175 | updating working directory | |||
|
176 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
177 | marked working directory as branch topic | |||
|
178 | abort: working dir not at branch tip (use "hg update" to check out branch tip) | |||
|
179 | % parent should be 0 (fetch did not update or merge anything) | |||
|
180 | 0 |
General Comments 0
You need to be logged in to leave comments.
Login now