##// 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 19 return (os.path.isfile(path) and bundlerepo or localrepo)
20 20
21 21 def addbranchrevs(lrepo, repo, branches, revs):
22 if not branches:
22 hashbranch, branches = branches
23 if not hashbranch and not branches:
23 24 return revs or None, revs and revs[0] or None
24 25 revs = revs and list(revs) or []
25 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 30 return revs, revs[0]
28 31 branchmap = repo.branchmap()
29 for branch in branches:
30 if branch == '.':
32
33 def primary(butf8):
34 if butf8 == '.':
31 35 if not lrepo or not lrepo.local():
32 36 raise util.Abort(_("dirstate branch not accessible"))
33 37 butf8 = lrepo.dirstate.branch()
34 branch = encoding.tolocal(butf8)
35 else:
36 butf8 = encoding.fromlocal(branch)
37 38 if butf8 in branchmap:
38 39 revs.extend(node.hex(r) for r in reversed(branchmap[butf8]))
40 return True
39 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 52 return revs, revs[0]
42 53
43 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 57 if '#' not in url:
47 return url, branches or []
58 return url, (None, branches or [])
48 59 url, branch = url.split('#', 1)
49 return url, (branches or []) + [branch]
60 return url, (branch, branches or [])
50 61
51 62 schemes = {
52 63 'bundle': bundlerepo,
@@ -12,6 +12,7 b' hg up 0'
12 12 hg branch c
13 13 echo c > foo
14 14 hg ci -d '0 0' -mc
15 hg tag -l z
15 16 cd ..
16 17 hg clone -r 0 branch branch2
17 18 cd branch2
@@ -32,6 +33,10 b' hg branch -f b'
32 33 echo b2 > foo
33 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 40 echo in rev c branch a
36 41 hg in -qr c ../branch#a
37 42 hg in -qr c -b a
@@ -15,9 +15,14 b' 1 files updated, 0 files merged, 0 files'
15 15 marked working directory as branch æ
16 16 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
17 17 marked working directory as branch æ
18 created new head
18 19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
19 20 marked working directory as branch b
20 21 created new head
22 unknown branch and fallback
23 abort: unknown branch 'z'!
24 2:f25d57ab0566
25 abort: unknown branch 'z'!
21 26 in rev c branch a
22 27 1:dd6e60a716c6
23 28 2:f25d57ab0566
@@ -1,5 +1,5 b''
1 http://example.com/no/anchor, branches: []
2 http://example.com/an/anchor, branches: ['foo']
3 http://example.com/no/anchor/branches, branches: ['foo']
4 http://example.com/an/anchor/branches, branches: ['foo', 'bar']
5 http://example.com/an/anchor/branches-None, branches: ['foo']
1 http://example.com/no/anchor, branches: (None, [])
2 http://example.com/an/anchor, branches: ('foo', [])
3 http://example.com/no/anchor/branches, branches: (None, ['foo'])
4 http://example.com/an/anchor/branches, branches: ('bar', ['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