##// END OF EJS Templates
merge with other head by default, not tip....
Vadim Gelfer -
r2915:013921c7 default
parent child Browse files
Show More
@@ -0,0 +1,40 b''
1 #!/bin/sh
2
3 hg init
4 echo a > a
5 hg commit -A -ma
6
7 echo a >> a
8 hg commit -mb
9
10 echo a >> a
11 hg commit -mc
12
13 hg up 1
14 echo a >> a
15 hg commit -md
16
17 hg up 1
18 echo a >> a
19 hg commit -me
20
21 hg up 1
22 echo % should fail because not at a head
23 hg merge
24
25 hg up
26 echo % should fail because \> 2 heads
27 hg merge
28
29 echo % should succeed
30 hg merge 2
31 hg commit -mm1
32
33 echo % should succeed - 2 heads
34 hg merge
35 hg commit -mm2
36
37 echo % should fail because 1 head
38 hg merge
39
40 true
@@ -0,0 +1,17 b''
1 adding a
2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
3 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 % should fail because not at a head
6 abort: repo has 3 heads - please merge with an explicit rev
7 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
8 % should fail because > 2 heads
9 abort: repo has 3 heads - please merge with an explicit rev
10 % should succeed
11 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
12 (branch merge, don't forget to commit)
13 % should succeed - 2 heads
14 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
15 (branch merge, don't forget to commit)
16 % should fail because 1 head
17 abort: there is nothing to merge - use "hg update" instead
@@ -1969,9 +1969,29 b' def merge(ui, repo, node=None, force=Non'
1969 requested revision. Files that changed between either parent are
1969 requested revision. Files that changed between either parent are
1970 marked as changed for the next commit and a commit must be
1970 marked as changed for the next commit and a commit must be
1971 performed before any further updates are allowed.
1971 performed before any further updates are allowed.
1972
1973 If no revision is specified, the working directory's parent is a
1974 head revision, and the repository contains exactly one other head,
1975 the other head is merged with by default. Otherwise, an explicit
1976 revision to merge with must be provided.
1972 """
1977 """
1973
1978
1974 node = _lookup(repo, node, branch)
1979 if node:
1980 node = _lookup(repo, node, branch)
1981 else:
1982 heads = repo.heads()
1983 if len(heads) > 2:
1984 raise util.Abort(_('repo has %d heads - '
1985 'please merge with an explicit rev') %
1986 len(heads))
1987 if len(heads) == 1:
1988 raise util.Abort(_('there is nothing to merge - '
1989 'use "hg update" instead'))
1990 parent = repo.dirstate.parents()[0]
1991 if parent not in heads:
1992 raise util.Abort(_('working dir not at a head rev - '
1993 'use "hg update" or merge with an explicit rev'))
1994 node = parent == heads[0] and heads[-1] or heads[0]
1975 return hg.merge(repo, node, force=force)
1995 return hg.merge(repo, node, force=force)
1976
1996
1977 def outgoing(ui, repo, dest=None, **opts):
1997 def outgoing(ui, repo, dest=None, **opts):
@@ -43,7 +43,7 b' user: test'
43 date: Mon Jan 12 13:46:40 1970 +0000
43 date: Mon Jan 12 13:46:40 1970 +0000
44 summary: 1
44 summary: 1
45
45
46 abort: there is nothing to merge, just use 'hg update' or look at 'hg heads'
46 abort: there is nothing to merge - use "hg update" instead
47 failed
47 failed
48 changeset: 0:33aaa84a386b
48 changeset: 0:33aaa84a386b
49 user: test
49 user: test
General Comments 0
You need to be logged in to leave comments. Login now