##// END OF EJS Templates
improve --branch processing (and differentiate from # syntax)...
Sune Foldager -
r11322:3d6915f5 default
parent child Browse files
Show More
@@ -19,34 +19,45 b' def _local(path):'
19 return (os.path.isfile(path) and bundlerepo or localrepo)
19 return (os.path.isfile(path) and bundlerepo or localrepo)
20
20
21 def addbranchrevs(lrepo, repo, branches, revs):
21 def addbranchrevs(lrepo, repo, branches, revs):
22 if not branches:
22 hashbranch, branches = branches
23 if not hashbranch and not branches:
23 return revs or None, revs and revs[0] or None
24 return revs or None, revs and revs[0] or None
24 revs = revs and list(revs) or []
25 revs = revs and list(revs) or []
25 if not repo.capable('branchmap'):
26 if not repo.capable('branchmap'):
26 revs.extend(branches)
27 if branches:
28 raise util.Abort(_("remote branch lookup not supported"))
29 revs.append(hashbranch)
27 return revs, revs[0]
30 return revs, revs[0]
28 branchmap = repo.branchmap()
31 branchmap = repo.branchmap()
29 for branch in branches:
32
30 if branch == '.':
33 def primary(butf8):
34 if butf8 == '.':
31 if not lrepo or not lrepo.local():
35 if not lrepo or not lrepo.local():
32 raise util.Abort(_("dirstate branch not accessible"))
36 raise util.Abort(_("dirstate branch not accessible"))
33 butf8 = lrepo.dirstate.branch()
37 butf8 = lrepo.dirstate.branch()
34 branch = encoding.tolocal(butf8)
35 else:
36 butf8 = encoding.fromlocal(branch)
37 if butf8 in branchmap:
38 if butf8 in branchmap:
38 revs.extend(node.hex(r) for r in reversed(branchmap[butf8]))
39 revs.extend(node.hex(r) for r in reversed(branchmap[butf8]))
40 return True
39 else:
41 else:
40 revs.append(branch)
42 return False
43
44 for branch in branches:
45 butf8 = encoding.fromlocal(branch)
46 if not primary(butf8):
47 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
48 if hashbranch:
49 butf8 = encoding.fromlocal(hashbranch)
50 if not primary(butf8):
51 revs.append(hashbranch)
41 return revs, revs[0]
52 return revs, revs[0]
42
53
43 def parseurl(url, branches=None):
54 def parseurl(url, branches=None):
44 '''parse url#branch, returning url, branches+[branch]'''
55 '''parse url#branch, returning (url, (branch, branches))'''
45
56
46 if '#' not in url:
57 if '#' not in url:
47 return url, branches or []
58 return url, (None, branches or [])
48 url, branch = url.split('#', 1)
59 url, branch = url.split('#', 1)
49 return url, (branches or []) + [branch]
60 return url, (branch, branches or [])
50
61
51 schemes = {
62 schemes = {
52 'bundle': bundlerepo,
63 'bundle': bundlerepo,
@@ -12,6 +12,7 b' hg up 0'
12 hg branch c
12 hg branch c
13 echo c > foo
13 echo c > foo
14 hg ci -d '0 0' -mc
14 hg ci -d '0 0' -mc
15 hg tag -l z
15 cd ..
16 cd ..
16 hg clone -r 0 branch branch2
17 hg clone -r 0 branch branch2
17 cd branch2
18 cd branch2
@@ -32,6 +33,10 b' hg branch -f b'
32 echo b2 > foo
33 echo b2 > foo
33 hg ci -d '0 0' -mb2
34 hg ci -d '0 0' -mb2
34
35
36 echo unknown branch and fallback
37 hg in -qbz
38 hg in -q ../branch#z
39 hg out -qbz
35 echo in rev c branch a
40 echo in rev c branch a
36 hg in -qr c ../branch#a
41 hg in -qr c ../branch#a
37 hg in -qr c -b a
42 hg in -qr c -b a
@@ -15,9 +15,14 b' 1 files updated, 0 files merged, 0 files'
15 marked working directory as branch æ
15 marked working directory as branch æ
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 marked working directory as branch æ
17 marked working directory as branch æ
18 created new head
18 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
19 marked working directory as branch b
20 marked working directory as branch b
20 created new head
21 created new head
22 unknown branch and fallback
23 abort: unknown branch 'z'!
24 2:f25d57ab0566
25 abort: unknown branch 'z'!
21 in rev c branch a
26 in rev c branch a
22 1:dd6e60a716c6
27 1:dd6e60a716c6
23 2:f25d57ab0566
28 2:f25d57ab0566
@@ -1,5 +1,5 b''
1 http://example.com/no/anchor, branches: []
1 http://example.com/no/anchor, branches: (None, [])
2 http://example.com/an/anchor, branches: ['foo']
2 http://example.com/an/anchor, branches: ('foo', [])
3 http://example.com/no/anchor/branches, branches: ['foo']
3 http://example.com/no/anchor/branches, branches: (None, ['foo'])
4 http://example.com/an/anchor/branches, branches: ['foo', 'bar']
4 http://example.com/an/anchor/branches, branches: ('bar', ['foo'])
5 http://example.com/an/anchor/branches-None, branches: ['foo']
5 http://example.com/an/anchor/branches-None, branches: ('foo', [])
General Comments 0
You need to be logged in to leave comments. Login now