##// END OF EJS Templates
fetch: switch the default parent used for a merge...
Bryan O'Sullivan -
r6206:0b6f1249 default
parent child Browse files
Show More
@@ -17,7 +17,12 b" def fetch(ui, repo, source='default', **"
17 17
18 18 If the pulled changes add a new head, the head is automatically
19 19 merged, and the result of the merge is committed. Otherwise, the
20 working directory is updated.
20 working directory is updated to include the new changes.
21
22 When a merge occurs, the newly pulled changes are assumed to be
23 "authoritative". The head of the new changes is used as the first
24 parent, with local changes as the second. To switch the merge
25 order, use --switch-parent.
21 26
22 27 See 'hg help dates' for a list of formats valid for -d/--date.
23 28 '''
@@ -34,15 +39,27 b" def fetch(ui, repo, source='default', **"
34 39 newparent = newchildren[0]
35 40 hg.clean(repo, newparent)
36 41 newheads = [n for n in repo.heads() if n != newparent]
37 err = False
38 if newheads:
39 ui.status(_('merging with new head %d:%s\n') %
40 (repo.changelog.rev(newheads[0]), short(newheads[0])))
41 err = hg.merge(repo, newheads[0], remind=False)
42 if not err and len(newheads) > 1:
42 if len(newheads) > 1:
43 43 ui.status(_('not merging with %d other new heads '
44 44 '(use "hg heads" and "hg merge" to merge them)') %
45 45 (len(newheads) - 1))
46 return
47 err = False
48 if newheads:
49 # By default, we consider the repository we're pulling
50 # *from* as authoritative, so we merge our changes into
51 # theirs.
52 if opts['switch_parent']:
53 firstparent, secondparent = newparent, newheads[0]
54 else:
55 firstparent, secondparent = newheads[0], newparent
56 ui.status(_('updating to %d:%s\n') %
57 (repo.changelog.rev(firstparent),
58 short(firstparent)))
59 hg.clean(repo, firstparent)
60 ui.status(_('merging with %d:%s\n') %
61 (repo.changelog.rev(secondparent), short(secondparent)))
62 err = hg.merge(repo, secondparent, remind=False)
46 63 if not err:
47 64 mod, add, rem = repo.status()[:3]
48 65 message = (cmdutil.logmessage(opts) or
@@ -54,6 +71,7 b" def fetch(ui, repo, source='default', **"
54 71 ui.status(_('new changeset %d:%s merges remote changes '
55 72 'with local\n') % (repo.changelog.rev(n),
56 73 short(n)))
74
57 75 def pull():
58 76 cmdutil.setremoteconfig(ui, opts)
59 77
@@ -97,6 +115,7 b' cmdtable = {'
97 115 (fetch,
98 116 [('r', 'rev', [], _('a specific revision you would like to pull')),
99 117 ('f', 'force-editor', None, _('edit commit message')),
118 ('', 'switch-parent', None, _('switch parents when merging')),
100 119 ] + commands.commitopts + commands.commitopts2 + commands.remoteopts,
101 120 _('hg fetch [SOURCE]')),
102 121 }
@@ -24,6 +24,7 b" hg --cwd c commit -d '3 0' -Amc"
24 24 hg clone c d
25 25 hg clone c e
26 26
27 echo % should merge c into a
27 28 hg --cwd c fetch -d '4 0' -m 'automated merge' ../a
28 29 ls c
29 30
@@ -37,3 +38,15 b" hg --cwd d tip --template '{desc}\\n'"
37 38 echo '% fetch over http with auth (should be hidden in desc)'
38 39 hg --cwd e fetch -d '5 0' http://user:password@localhost:$HGPORT/
39 40 hg --cwd e tip --template '{desc}\n'
41
42 hg clone a f
43 hg clone a g
44
45 echo f > f/f
46 hg --cwd f ci -d '6 0' -Amf
47
48 echo g > g/g
49 hg --cwd g ci -d '6 0' -Amg
50
51 echo % should merge f into g
52 hg --cwd g fetch --switch ../f
@@ -15,13 +15,16 b' 1:97d72e5f12c7'
15 15 adding c
16 16 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
17 17 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
18 % should merge c into a
18 19 pulling from ../a
19 20 searching for changes
20 21 adding changesets
21 22 adding manifests
22 23 adding file changes
23 24 added 1 changesets with 1 changes to 1 files (+1 heads)
24 merging with new head 2:97d72e5f12c7
25 updating to 2:97d72e5f12c7
26 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
27 merging with 1:5e056962225c
25 28 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
26 29 new changeset 3:cd3a41621cf0 merges remote changes with local
27 30 a
@@ -34,7 +37,9 b' adding changesets'
34 37 adding manifests
35 38 adding file changes
36 39 added 1 changesets with 1 changes to 1 files (+1 heads)
37 merging with new head 2:97d72e5f12c7
40 updating to 2:97d72e5f12c7
41 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
42 merging with 1:5e056962225c
38 43 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 44 new changeset 3:0b6439e938f9 merges remote changes with local
40 45 Automated merge with http://localhost:20059/
@@ -45,7 +50,24 b' adding changesets'
45 50 adding manifests
46 51 adding file changes
47 52 added 1 changesets with 1 changes to 1 files (+1 heads)
48 merging with new head 2:97d72e5f12c7
53 updating to 2:97d72e5f12c7
54 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
55 merging with 1:5e056962225c
49 56 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
50 57 new changeset 3:0b6439e938f9 merges remote changes with local
51 58 Automated merge with http://localhost:20059/
59 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 adding f
62 adding g
63 % should merge f into g
64 pulling from ../f
65 searching for changes
66 adding changesets
67 adding manifests
68 adding file changes
69 added 1 changesets with 1 changes to 1 files (+1 heads)
70 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
71 merging with 3:cc6a3744834d
72 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
73 new changeset 4:96d2275e70b4 merges remote changes with local
General Comments 0
You need to be logged in to leave comments. Login now