Mercurial > kallithea
annotate rhodecode/lib/unionrepo.py @ 3574:000653f7cdf9 beta
avoid displaying repr of internal classes in user facing messages
The context of the message will tell where the problem was and there is no reason to show
... does not exist for this repository <MercurialRepository at /home/marcink/repos/rhodecode>
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 21 Mar 2013 11:17:01 +0100 |
parents | 6354556781ef |
children | f3283898d431 |
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 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
20 class unionrevlog(revlog.revlog): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
21 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
|
22 # How it works: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
23 # 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
|
24 # look it up in revlog2. |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
25 # |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
26 # 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
|
27 # we check revision against repotiprev. |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
28 opener = scmutil.readonlyvfs(opener) |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
29 revlog.revlog.__init__(self, opener, indexfile) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
30 self.revlog2 = revlog2 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
31 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
32 n = len(self) |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
33 self.repotiprev = n - 1 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
34 self.bundlerevs = set() # used by 'bundle()' revset expression |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
35 for rev2 in self.revlog2: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
36 rev = self.revlog2.index[rev2] |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
37 # 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
|
38 _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
|
39 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
40 if linkmapper is None: # link is to same revlog |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
41 assert linkrev == rev2 # we never link back |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
42 link = n |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
43 else: # rev must be mapped from repo2 cl to unified cl by linkmapper |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
44 link = linkmapper(linkrev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
45 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
46 if node in self.nodemap: |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
47 # 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
|
48 self.bundlerevs.add(self.nodemap[node]) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
49 continue |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
50 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
51 p1node = self.revlog2.node(p1rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
52 p2node = self.revlog2.node(p2rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
53 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
54 e = (None, None, None, None, |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
55 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
|
56 self.index.insert(-1, e) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
57 self.nodemap[node] = n |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
58 self.bundlerevs.add(n) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
59 n += 1 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
60 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
61 def _chunk(self, rev): |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
62 if rev <= self.repotiprev: |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
63 return revlog.revlog._chunk(self, rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
64 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
|
65 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
66 def revdiff(self, rev1, rev2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
67 """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
|
68 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
|
69 return self.revlog2.revdiff( |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
70 self.revlog2.rev(self.node(rev1)), |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
71 self.revlog2.rev(self.node(rev2))) |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
72 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
|
73 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
|
74 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
75 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
|
76 self.revision(self.node(rev2))) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
77 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
78 def revision(self, nodeorrev): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
79 """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
|
80 number. |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
81 """ |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
82 if isinstance(nodeorrev, int): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
83 rev = nodeorrev |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
84 node = self.node(rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
85 else: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
86 node = nodeorrev |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
87 rev = self.rev(node) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
88 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
89 if node == nullid: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
90 return "" |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
91 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
92 if rev > self.repotiprev: |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
93 text = self.revlog2.revision(node) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
94 self._cache = (node, rev, text) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
95 else: |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
96 text = revlog.revlog.revision(self, rev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
97 # already cached |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
98 return text |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
99 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
100 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
|
101 raise NotImplementedError |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
102 def addgroup(self, revs, linkmapper, transaction): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
103 raise NotImplementedError |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
104 def strip(self, rev, minlink): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
105 raise NotImplementedError |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
106 def checksize(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
107 raise NotImplementedError |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
108 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
109 class unionchangelog(unionrevlog, changelog.changelog): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
110 def __init__(self, opener, opener2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
111 changelog.changelog.__init__(self, opener) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
112 linkmapper = None |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
113 changelog2 = changelog.changelog(opener2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
114 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
|
115 linkmapper) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
116 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
117 class unionmanifest(unionrevlog, manifest.manifest): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
118 def __init__(self, opener, opener2, linkmapper): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
119 manifest.manifest.__init__(self, opener) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
120 manifest2 = manifest.manifest(opener2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
121 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
|
122 linkmapper) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
123 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
124 class unionfilelog(unionrevlog, filelog.filelog): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
125 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
|
126 filelog.filelog.__init__(self, opener, path) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
127 filelog2 = filelog.filelog(opener2, path) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
128 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
|
129 linkmapper) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
130 self._repo = repo |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
131 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
132 def _file(self, f): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
133 self._repo.file(f) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
134 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
135 class unionpeer(localrepo.localpeer): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
136 def canpush(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
137 return False |
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 class unionrepository(localrepo.localrepository): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
140 def __init__(self, ui, path, path2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
141 localrepo.localrepository.__init__(self, ui, path) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
142 self.ui.setconfig('phases', 'publish', False) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
143 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
144 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
|
145 util.expandpath(path2)) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
146 self.repo2 = localrepo.localrepository(ui, path2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
147 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
148 @localrepo.unfilteredpropertycache |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
149 def changelog(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
150 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
|
151 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
152 def _clrev(self, rev2): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
153 """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
|
154 node = self.repo2.changelog.node(rev2) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
155 return self.changelog.rev(node) |
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 manifest(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
159 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
|
160 self._clrev) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
161 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
162 def url(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
163 return self._url |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
164 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
165 def file(self, f): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
166 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
|
167 self._clrev, self) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
168 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
169 def close(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
170 self.repo2.close() |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
171 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
172 def cancopy(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
173 return False |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
174 |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
175 def peer(self): |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
176 return unionpeer(self) |
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
177 |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
178 def getcwd(self): |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
179 return os.getcwd() # always outside the repo |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
180 |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
181 def instance(ui, path, create): |
3407
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
182 if create: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
183 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
|
184 parentpath = ui.config("bundle", "mainreporoot", "") |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
185 if not parentpath: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
186 # 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
|
187 parentpath = cmdutil.findrepo(os.getcwd()) |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
188 if parentpath is None: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
189 parentpath = '' |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
190 if parentpath: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
191 # 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
|
192 # 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
|
193 cwd = os.getcwd() |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
194 if parentpath == cwd: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
195 parentpath = '' |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
196 else: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
197 cwd = os.path.join(cwd,'') |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
198 if parentpath.startswith(cwd): |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
199 parentpath = parentpath[len(cwd):] |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
200 if path.startswith('union:'): |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
201 s = path.split(":", 1)[1].split("+", 1) |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
202 if len(s) == 1: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
203 repopath, repopath2 = parentpath, s[0] |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
204 else: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
205 repopath, repopath2 = s |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
206 else: |
6354556781ef
update unionrepo for Mercurial 2.5.1
Mads Kiilerich <madski@unity3d.com>
parents:
3302
diff
changeset
|
207 repopath, repopath2 = parentpath, path |
3302
ead7a902998c
introduce unionrepo repository class for viewing union of repositories
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
208 return unionrepository(ui, repopath, repopath2) |