Show More
@@ -13,43 +13,25 b" demandload(globals(), 'os sys')" | |||||
13 |
|
13 | |||
14 | revrangesep = ':' |
|
14 | revrangesep = ':' | |
15 |
|
15 | |||
16 | def revfix(repo, val, defval): |
|
|||
17 | '''turn user-level id of changeset into rev number. |
|
|||
18 | user-level id can be tag, changeset, rev number, or negative rev |
|
|||
19 | number relative to number of revs (-1 is tip, etc).''' |
|
|||
20 | if not val: |
|
|||
21 | return defval |
|
|||
22 | try: |
|
|||
23 | num = int(val) |
|
|||
24 | if str(num) != val: |
|
|||
25 | raise ValueError |
|
|||
26 | if num < 0: |
|
|||
27 | num += repo.changelog.count() |
|
|||
28 | if num < 0: |
|
|||
29 | num = 0 |
|
|||
30 | elif num >= repo.changelog.count(): |
|
|||
31 | raise ValueError |
|
|||
32 | except ValueError: |
|
|||
33 | try: |
|
|||
34 | num = repo.changelog.rev(repo.lookup(val)) |
|
|||
35 | except KeyError: |
|
|||
36 | raise util.Abort(_('invalid revision identifier %s') % val) |
|
|||
37 | return num |
|
|||
38 |
|
||||
39 | def revpair(ui, repo, revs): |
|
16 | def revpair(ui, repo, revs): | |
40 | '''return pair of nodes, given list of revisions. second item can |
|
17 | '''return pair of nodes, given list of revisions. second item can | |
41 | be None, meaning use working dir.''' |
|
18 | be None, meaning use working dir.''' | |
|
19 | ||||
|
20 | def revfix(repo, val, defval): | |||
|
21 | if not val and val != 0: | |||
|
22 | val = defval | |||
|
23 | return repo.lookup(val) | |||
|
24 | ||||
42 | if not revs: |
|
25 | if not revs: | |
43 | return repo.dirstate.parents()[0], None |
|
26 | return repo.dirstate.parents()[0], None | |
44 | end = None |
|
27 | end = None | |
45 | if len(revs) == 1: |
|
28 | if len(revs) == 1: | |
46 |
|
|
29 | if revrangesep in revs[0]: | |
47 | if revrangesep in start: |
|
30 | start, end = revs[0].split(revrangesep, 1) | |
48 | start, end = start.split(revrangesep, 1) |
|
|||
49 | start = revfix(repo, start, 0) |
|
31 | start = revfix(repo, start, 0) | |
50 | end = revfix(repo, end, repo.changelog.count() - 1) |
|
32 | end = revfix(repo, end, repo.changelog.count() - 1) | |
51 | else: |
|
33 | else: | |
52 |
start = revfix(repo, |
|
34 | start = revfix(repo, revs[0], None) | |
53 | elif len(revs) == 2: |
|
35 | elif len(revs) == 2: | |
54 | if revrangesep in revs[0] or revrangesep in revs[1]: |
|
36 | if revrangesep in revs[0] or revrangesep in revs[1]: | |
55 | raise util.Abort(_('too many revisions specified')) |
|
37 | raise util.Abort(_('too many revisions specified')) | |
@@ -57,11 +39,16 b' def revpair(ui, repo, revs):' | |||||
57 | end = revfix(repo, revs[1], None) |
|
39 | end = revfix(repo, revs[1], None) | |
58 | else: |
|
40 | else: | |
59 | raise util.Abort(_('too many revisions specified')) |
|
41 | raise util.Abort(_('too many revisions specified')) | |
60 | if end is not None: end = repo.lookup(end) |
|
42 | return start, end | |
61 | return repo.lookup(start), end |
|
|||
62 |
|
43 | |||
63 | def revrange(ui, repo, revs): |
|
44 | def revrange(ui, repo, revs): | |
64 | """Yield revision as strings from a list of revision specifications.""" |
|
45 | """Yield revision as strings from a list of revision specifications.""" | |
|
46 | ||||
|
47 | def revfix(repo, val, defval): | |||
|
48 | if not val and val != 0: | |||
|
49 | return defval | |||
|
50 | return repo.changelog.rev(repo.lookup(val)) | |||
|
51 | ||||
65 | seen = {} |
|
52 | seen = {} | |
66 | for spec in revs: |
|
53 | for spec in revs: | |
67 | if revrangesep in spec: |
|
54 | if revrangesep in spec: | |
@@ -73,13 +60,13 b' def revrange(ui, repo, revs):' | |||||
73 | if rev in seen: |
|
60 | if rev in seen: | |
74 | continue |
|
61 | continue | |
75 | seen[rev] = 1 |
|
62 | seen[rev] = 1 | |
76 |
yield |
|
63 | yield rev | |
77 | else: |
|
64 | else: | |
78 | rev = revfix(repo, spec, None) |
|
65 | rev = revfix(repo, spec, None) | |
79 | if rev in seen: |
|
66 | if rev in seen: | |
80 | continue |
|
67 | continue | |
81 | seen[rev] = 1 |
|
68 | seen[rev] = 1 | |
82 |
yield |
|
69 | yield rev | |
83 |
|
70 | |||
84 | def make_filename(repo, pat, node, |
|
71 | def make_filename(repo, pat, node, | |
85 | total=None, seqno=None, revwidth=None, pathname=None): |
|
72 | total=None, seqno=None, revwidth=None, pathname=None): |
General Comments 0
You need to be logged in to leave comments.
Login now