Show More
@@ -29,6 +29,39 b' def recode(s):' | |||||
29 | else: |
|
29 | else: | |
30 | return s.decode('utf-8').encode(orig_encoding, 'replace') |
|
30 | return s.decode('utf-8').encode(orig_encoding, 'replace') | |
31 |
|
31 | |||
|
32 | def mapbranch(branch, branchmap): | |||
|
33 | ''' | |||
|
34 | >>> bmap = {'default': 'branch1'} | |||
|
35 | >>> for i in ['', None]: | |||
|
36 | ... mapbranch(i, bmap) | |||
|
37 | 'branch1' | |||
|
38 | 'branch1' | |||
|
39 | >>> bmap = {'None': 'branch2'} | |||
|
40 | >>> for i in ['', None]: | |||
|
41 | ... mapbranch(i, bmap) | |||
|
42 | 'branch2' | |||
|
43 | 'branch2' | |||
|
44 | >>> bmap = {'None': 'branch3', 'default': 'branch4'} | |||
|
45 | >>> for i in ['None', '', None, 'default', 'branch5']: | |||
|
46 | ... mapbranch(i, bmap) | |||
|
47 | 'branch3' | |||
|
48 | 'branch4' | |||
|
49 | 'branch4' | |||
|
50 | 'branch4' | |||
|
51 | 'branch5' | |||
|
52 | ''' | |||
|
53 | # If branch is None or empty, this commit is coming from the source | |||
|
54 | # repository's default branch and destined for the default branch in the | |||
|
55 | # destination repository. For such commits, using a literal "default" | |||
|
56 | # in branchmap below allows the user to map "default" to an alternate | |||
|
57 | # default branch in the destination repository. | |||
|
58 | branch = branchmap.get(branch or 'default', branch) | |||
|
59 | # At some point we used "None" literal to denote the default branch, | |||
|
60 | # attempt to use that for backward compatibility. | |||
|
61 | if (not branch): | |||
|
62 | branch = branchmap.get(str(None), branch) | |||
|
63 | return branch | |||
|
64 | ||||
32 | source_converters = [ |
|
65 | source_converters = [ | |
33 | ('cvs', convert_cvs, 'branchsort'), |
|
66 | ('cvs', convert_cvs, 'branchsort'), | |
34 | ('git', convert_git, 'branchsort'), |
|
67 | ('git', convert_git, 'branchsort'), | |
@@ -377,12 +410,7 b' class converter(object):' | |||||
377 | def cachecommit(self, rev): |
|
410 | def cachecommit(self, rev): | |
378 | commit = self.source.getcommit(rev) |
|
411 | commit = self.source.getcommit(rev) | |
379 | commit.author = self.authors.get(commit.author, commit.author) |
|
412 | commit.author = self.authors.get(commit.author, commit.author) | |
380 | # If commit.branch is None, this commit is coming from the source |
|
413 | commit.branch = mapbranch(commit.branch, self.branchmap) | |
381 | # repository's default branch and destined for the default branch in the |
|
|||
382 | # destination repository. For such commits, passing a literal "None" |
|
|||
383 | # string to branchmap.get() below allows the user to map "None" to an |
|
|||
384 | # alternate default branch in the destination repository. |
|
|||
385 | commit.branch = self.branchmap.get(str(commit.branch), commit.branch) |
|
|||
386 | self.commitcache[rev] = commit |
|
414 | self.commitcache[rev] = commit | |
387 | return commit |
|
415 | return commit | |
388 |
|
416 |
@@ -140,7 +140,7 b' class p4_source(converter_source):' | |||||
140 | date = (int(d["time"]), 0) # timezone not set |
|
140 | date = (int(d["time"]), 0) # timezone not set | |
141 | c = commit(author=self.recode(d["user"]), |
|
141 | c = commit(author=self.recode(d["user"]), | |
142 | date=util.datestr(date, '%Y-%m-%d %H:%M:%S %1%2'), |
|
142 | date=util.datestr(date, '%Y-%m-%d %H:%M:%S %1%2'), | |
143 |
parents=parents, desc=desc, branch= |
|
143 | parents=parents, desc=desc, branch=None, | |
144 | extra={"p4": change}) |
|
144 | extra={"p4": change}) | |
145 |
|
145 | |||
146 | files = [] |
|
146 | files = [] |
@@ -99,7 +99,7 b' Test hg failing to call itself' | |||||
99 | Convert 'trunk' to branch other than 'default' |
|
99 | Convert 'trunk' to branch other than 'default' | |
100 |
|
100 | |||
101 | $ cat > branchmap <<EOF |
|
101 | $ cat > branchmap <<EOF | |
102 |
> |
|
102 | > default hgtrunk | |
103 | > |
|
103 | > | |
104 | > |
|
104 | > | |
105 | > EOF |
|
105 | > EOF | |
@@ -121,9 +121,8 b" Convert 'trunk' to branch other than 'de" | |||||
121 | 0 last change to a |
|
121 | 0 last change to a | |
122 |
|
122 | |||
123 | $ cd C-hg |
|
123 | $ cd C-hg | |
124 | $ hg branches |
|
124 | $ hg branches --template '{branch}\n' | |
125 | hgtrunk 10:745f063703b4 |
|
125 | hgtrunk | |
126 | old 9:aa50d7b8d922 |
|
126 | old | |
127 | old2 8:c85a22267b6e (inactive) |
|
127 | old2 | |
128 | $ cd .. |
|
128 | $ cd .. | |
129 |
|
@@ -31,6 +31,7 b" testmod('mercurial.ui')" | |||||
31 | testmod('mercurial.url') |
|
31 | testmod('mercurial.url') | |
32 | testmod('mercurial.util') |
|
32 | testmod('mercurial.util') | |
33 | testmod('mercurial.util', testtarget='platform') |
|
33 | testmod('mercurial.util', testtarget='platform') | |
|
34 | testmod('hgext.convert.convcmd') | |||
34 | testmod('hgext.convert.cvsps') |
|
35 | testmod('hgext.convert.cvsps') | |
35 | testmod('hgext.convert.filemap') |
|
36 | testmod('hgext.convert.filemap') | |
36 | testmod('hgext.convert.p4') |
|
37 | testmod('hgext.convert.p4') |
General Comments 0
You need to be logged in to leave comments.
Login now