Mercurial > kallithea
annotate rhodecode/lib/unionrepo.py @ 3578:f3283898d431 beta
pep8 unionrepo
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 24 Mar 2013 19:53:09 +0100 |
parents | 6354556781ef |
children |
rev | line source |
---|---|
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
1 # unionrepo.py - repository class for viewing union of repository changesets |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
2 # |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
3 # Derived from bundlerepo.py |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
4 # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
5 # Copyright 2013 Unity Technologies, Mads Kiilerich <madski@unity3d.com> |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
6 # |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
9 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
10 """Repository class for "in-memory pull" of one local repository to another, |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
11 allowing operations like diff and log with revsets. |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
12 """ |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
13 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
14 import os |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
15 from mercurial.node import nullid |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
16 from mercurial.i18n import _ |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
17 from mercurial import util, mdiff, cmdutil, scmutil |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
18 from mercurial import localrepo, changelog, manifest, filelog, revlog |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
19 |
3578 | 20 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
21 class unionrevlog(revlog.revlog): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
22 def __init__(self, opener, indexfile, revlog2, linkmapper): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
23 # How it works: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
24 # To retrieve a revision, we just need to know the node id so we can |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
25 # look it up in revlog2. |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
26 # |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
27 # To differentiate a rev in the second revlog from a rev in the revlog, |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
28 # we check revision against repotiprev. |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
29 opener = scmutil.readonlyvfs(opener) |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
30 revlog.revlog.__init__(self, opener, indexfile) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
31 self.revlog2 = revlog2 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
32 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
33 n = len(self) |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
34 self.repotiprev = n - 1 |
3578 | 35 self.bundlerevs = set() # used by 'bundle()' revset expression |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
36 for rev2 in self.revlog2: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
37 rev = self.revlog2.index[rev2] |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
38 # rev numbers - in revlog2, very different from self.rev |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
39 _start, _csize, _rsize, _base, linkrev, p1rev, p2rev, node = rev |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
40 |
3578 | 41 if linkmapper is None: # link is to same revlog |
42 assert linkrev == rev2 # we never link back | |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
43 link = n |
3578 | 44 else: # rev must be mapped from repo2 cl to unified cl by linkmapper |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
45 link = linkmapper(linkrev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
46 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
47 if node in self.nodemap: |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
48 # this happens for the common revlog revisions |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
49 self.bundlerevs.add(self.nodemap[node]) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
50 continue |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
51 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
52 p1node = self.revlog2.node(p1rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
53 p2node = self.revlog2.node(p2rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
54 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
55 e = (None, None, None, None, |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
56 link, self.rev(p1node), self.rev(p2node), node) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
57 self.index.insert(-1, e) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
58 self.nodemap[node] = n |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
59 self.bundlerevs.add(n) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
60 n += 1 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
61 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
62 def _chunk(self, rev): |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
63 if rev <= self.repotiprev: |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
64 return revlog.revlog._chunk(self, rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
65 return self.revlog2._chunk(self.node(rev)) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
66 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
67 def revdiff(self, rev1, rev2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
68 """return or calculate a delta between two revisions""" |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
69 if rev1 > self.repotiprev and rev2 > self.repotiprev: |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
70 return self.revlog2.revdiff( |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
71 self.revlog2.rev(self.node(rev1)), |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
72 self.revlog2.rev(self.node(rev2))) |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
73 elif rev1 <= self.repotiprev and rev2 <= self.repotiprev: |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
74 return revlog.revlog.revdiff(self, rev1, rev2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
75 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
76 return mdiff.textdiff(self.revision(self.node(rev1)), |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
77 self.revision(self.node(rev2))) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
78 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
79 def revision(self, nodeorrev): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
80 """return an uncompressed revision of a given node or revision |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
81 number. |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
82 """ |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
83 if isinstance(nodeorrev, int): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
84 rev = nodeorrev |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
85 node = self.node(rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
86 else: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
87 node = nodeorrev |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
88 rev = self.rev(node) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
89 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
90 if node == nullid: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
91 return "" |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
92 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
93 if rev > self.repotiprev: |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
94 text = self.revlog2.revision(node) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
95 self._cache = (node, rev, text) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
96 else: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
97 text = revlog.revlog.revision(self, rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
98 # already cached |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
99 return text |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
100 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
101 def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
102 raise NotImplementedError |
3578 | 103 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
104 def addgroup(self, revs, linkmapper, transaction): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
105 raise NotImplementedError |
3578 | 106 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
107 def strip(self, rev, minlink): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
108 raise NotImplementedError |
3578 | 109 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
110 def checksize(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
111 raise NotImplementedError |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
112 |
3578 | 113 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
114 class unionchangelog(unionrevlog, changelog.changelog): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
115 def __init__(self, opener, opener2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
116 changelog.changelog.__init__(self, opener) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
117 linkmapper = None |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
118 changelog2 = changelog.changelog(opener2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
119 unionrevlog.__init__(self, opener, self.indexfile, changelog2, |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
120 linkmapper) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
121 |
3578 | 122 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
123 class unionmanifest(unionrevlog, manifest.manifest): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
124 def __init__(self, opener, opener2, linkmapper): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
125 manifest.manifest.__init__(self, opener) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
126 manifest2 = manifest.manifest(opener2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
127 unionrevlog.__init__(self, opener, self.indexfile, manifest2, |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
128 linkmapper) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
129 |
3578 | 130 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
131 class unionfilelog(unionrevlog, filelog.filelog): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
132 def __init__(self, opener, path, opener2, linkmapper, repo): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
133 filelog.filelog.__init__(self, opener, path) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
134 filelog2 = filelog.filelog(opener2, path) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
135 unionrevlog.__init__(self, opener, self.indexfile, filelog2, |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
136 linkmapper) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
137 self._repo = repo |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
138 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
139 def _file(self, f): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
140 self._repo.file(f) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
141 |
3578 | 142 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
143 class unionpeer(localrepo.localpeer): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
144 def canpush(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
145 return False |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
146 |
3578 | 147 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
148 class unionrepository(localrepo.localrepository): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
149 def __init__(self, ui, path, path2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
150 localrepo.localrepository.__init__(self, ui, path) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
151 self.ui.setconfig('phases', 'publish', False) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
152 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
153 self._url = 'union:%s+%s' % (util.expandpath(path), |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
154 util.expandpath(path2)) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
155 self.repo2 = localrepo.localrepository(ui, path2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
156 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
157 @localrepo.unfilteredpropertycache |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
158 def changelog(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
159 return unionchangelog(self.sopener, self.repo2.sopener) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
160 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
161 def _clrev(self, rev2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
162 """map from repo2 changelog rev to temporary rev in self.changelog""" |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
163 node = self.repo2.changelog.node(rev2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
164 return self.changelog.rev(node) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
165 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
166 @localrepo.unfilteredpropertycache |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
167 def manifest(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
168 return unionmanifest(self.sopener, self.repo2.sopener, |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
169 self._clrev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
170 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
171 def url(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
172 return self._url |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
173 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
174 def file(self, f): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
175 return unionfilelog(self.sopener, f, self.repo2.sopener, |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
176 self._clrev, self) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
177 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
178 def close(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
179 self.repo2.close() |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
180 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
181 def cancopy(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
182 return False |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
183 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
184 def peer(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
185 return unionpeer(self) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
186 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
187 def getcwd(self): |
3578 | 188 return os.getcwd() # always outside the repo |
189 | |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
190 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
191 def instance(ui, path, create): |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
192 if create: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
193 raise util.Abort(_('cannot create new union repository')) |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
194 parentpath = ui.config("bundle", "mainreporoot", "") |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
195 if not parentpath: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
196 # try to find the correct path to the working directory repo |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
197 parentpath = cmdutil.findrepo(os.getcwd()) |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
198 if parentpath is None: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
199 parentpath = '' |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
200 if parentpath: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
201 # Try to make the full path relative so we get a nice, short URL. |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
202 # In particular, we don't want temp dir names in test outputs. |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
203 cwd = os.getcwd() |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
204 if parentpath == cwd: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
205 parentpath = '' |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
206 else: |
3578 | 207 cwd = os.path.join(cwd, '') |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
208 if parentpath.startswith(cwd): |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
209 parentpath = parentpath[len(cwd):] |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
210 if path.startswith('union:'): |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
211 s = path.split(":", 1)[1].split("+", 1) |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
212 if len(s) == 1: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
213 repopath, repopath2 = parentpath, s[0] |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
214 else: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
215 repopath, repopath2 = s |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
216 else: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
217 repopath, repopath2 = parentpath, path |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
218 return unionrepository(ui, repopath, repopath2) |