Mercurial > hg
annotate mercurial/unionrepo.py @ 24356:a38f384f2a57
record: consolidate ui.write wrapping in a function
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Mon, 16 Mar 2015 15:30:33 -0700 |
parents | 76f6ae06ddf5 |
children | e4f75c93f073 |
rev | line source |
---|---|
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
1 # unionrepo.py - repository class for viewing union of repository changesets |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
2 # |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
3 # Derived from bundlerepo.py |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
4 # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
5 # Copyright 2013 Unity Technologies, Mads Kiilerich <madski@unity3d.com> |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
6 # |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
9 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
10 """Repository class for "in-memory pull" of one local repository to another, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
11 allowing operations like diff and log with revsets. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
12 """ |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
13 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
14 from node import nullid |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
15 from i18n import _ |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
16 import os |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
17 import util, mdiff, cmdutil, scmutil |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
18 import localrepo, changelog, manifest, filelog, revlog |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
19 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
20 class unionrevlog(revlog.revlog): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
21 def __init__(self, opener, indexfile, revlog2, linkmapper): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
22 # How it works: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
23 # To retrieve a revision, we just need to know the node id so we can |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
24 # look it up in revlog2. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
25 # |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
26 # To differentiate a rev in the second revlog from a rev in the revlog, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
27 # we check revision against repotiprev. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
28 opener = scmutil.readonlyvfs(opener) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
29 revlog.revlog.__init__(self, opener, indexfile) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
30 self.revlog2 = revlog2 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
31 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
32 n = len(self) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
33 self.repotiprev = n - 1 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
34 self.bundlerevs = set() # used by 'bundle()' revset expression |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
35 for rev2 in self.revlog2: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
36 rev = self.revlog2.index[rev2] |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
37 # rev numbers - in revlog2, very different from self.rev |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
38 _start, _csize, _rsize, _base, linkrev, p1rev, p2rev, node = rev |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
39 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
40 if linkmapper is None: # link is to same revlog |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
41 assert linkrev == rev2 # we never link back |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
42 link = n |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
43 else: # rev must be mapped from repo2 cl to unified cl by linkmapper |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
44 link = linkmapper(linkrev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
45 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
46 if node in self.nodemap: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
47 # this happens for the common revlog revisions |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
48 self.bundlerevs.add(self.nodemap[node]) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
49 continue |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
50 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
51 p1node = self.revlog2.node(p1rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
52 p2node = self.revlog2.node(p2rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
53 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
54 e = (None, None, None, None, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
55 link, self.rev(p1node), self.rev(p2node), node) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
56 self.index.insert(-1, e) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
57 self.nodemap[node] = n |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
58 self.bundlerevs.add(n) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
59 n += 1 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
60 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
61 def _chunk(self, rev): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
62 if rev <= self.repotiprev: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
63 return revlog.revlog._chunk(self, rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
64 return self.revlog2._chunk(self.node(rev)) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
65 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
66 def revdiff(self, rev1, rev2): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
67 """return or calculate a delta between two revisions""" |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
68 if rev1 > self.repotiprev and rev2 > self.repotiprev: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
69 return self.revlog2.revdiff( |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
70 self.revlog2.rev(self.node(rev1)), |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
71 self.revlog2.rev(self.node(rev2))) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
72 elif rev1 <= self.repotiprev and rev2 <= self.repotiprev: |
19630
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
73 return self.baserevdiff(rev1, rev2) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
74 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
75 return mdiff.textdiff(self.revision(self.node(rev1)), |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
76 self.revision(self.node(rev2))) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
77 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
78 def revision(self, nodeorrev): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
79 """return an uncompressed revision of a given node or revision |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
80 number. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
81 """ |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
82 if isinstance(nodeorrev, int): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
83 rev = nodeorrev |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
84 node = self.node(rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
85 else: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
86 node = nodeorrev |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
87 rev = self.rev(node) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
88 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
89 if node == nullid: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
90 return "" |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
91 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
92 if rev > self.repotiprev: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
93 text = self.revlog2.revision(node) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
94 self._cache = (node, rev, text) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
95 else: |
19630
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
96 text = self.baserevision(rev) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
97 # already cached |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
98 return text |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
99 |
19630
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
100 def baserevision(self, nodeorrev): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
101 # Revlog subclasses may override 'revision' method to modify format of |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
102 # content retrieved from revlog. To use unionrevlog with such class one |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
103 # needs to override 'baserevision' and make more specific call here. |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
104 return revlog.revlog.revision(self, nodeorrev) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
105 |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
106 def baserevdiff(self, rev1, rev2): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
107 # Exists for the same purpose as baserevision. |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
108 return revlog.revlog.revdiff(self, rev1, rev2) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
109 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
110 def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
111 raise NotImplementedError |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
112 def addgroup(self, revs, linkmapper, transaction): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
113 raise NotImplementedError |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
114 def strip(self, rev, minlink): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
115 raise NotImplementedError |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
116 def checksize(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
117 raise NotImplementedError |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
118 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
119 class unionchangelog(unionrevlog, changelog.changelog): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
120 def __init__(self, opener, opener2): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
121 changelog.changelog.__init__(self, opener) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
122 linkmapper = None |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
123 changelog2 = changelog.changelog(opener2) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
124 unionrevlog.__init__(self, opener, self.indexfile, changelog2, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
125 linkmapper) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
126 |
19630
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
127 def baserevision(self, nodeorrev): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
128 # Although changelog doesn't override 'revision' method, some extensions |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
129 # may replace this class with another that does. Same story with |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
130 # manifest and filelog classes. |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
131 return changelog.changelog.revision(self, nodeorrev) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
132 |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
133 def baserevdiff(self, rev1, rev2): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
134 return changelog.changelog.revdiff(self, rev1, rev2) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
135 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
136 class unionmanifest(unionrevlog, manifest.manifest): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
137 def __init__(self, opener, opener2, linkmapper): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
138 manifest.manifest.__init__(self, opener) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
139 manifest2 = manifest.manifest(opener2) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
140 unionrevlog.__init__(self, opener, self.indexfile, manifest2, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
141 linkmapper) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
142 |
19630
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
143 def baserevision(self, nodeorrev): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
144 return manifest.manifest.revision(self, nodeorrev) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
145 |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
146 def baserevdiff(self, rev1, rev2): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
147 return manifest.manifest.revdiff(self, rev1, rev2) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
148 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
149 class unionfilelog(unionrevlog, filelog.filelog): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
150 def __init__(self, opener, path, opener2, linkmapper, repo): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
151 filelog.filelog.__init__(self, opener, path) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
152 filelog2 = filelog.filelog(opener2, path) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
153 unionrevlog.__init__(self, opener, self.indexfile, filelog2, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
154 linkmapper) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
155 self._repo = repo |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
156 |
19630
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
157 def baserevision(self, nodeorrev): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
158 return filelog.filelog.revision(self, nodeorrev) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
159 |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
160 def baserevdiff(self, rev1, rev2): |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
161 return filelog.filelog.revdiff(self, rev1, rev2) |
bb67f630b335
unionrevlog: extract 'baserevision' and 'baserevdiff' methods
Wojciech Lopata <lopek@fb.com>
parents:
18944
diff
changeset
|
162 |
24118
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
163 def iscensored(self, rev): |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
164 """Check if a revision is censored.""" |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
165 if rev <= self.repotiprev: |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
166 return filelog.filelog.iscensored(self, rev) |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
167 return self.revlog2.iscensored(rev) |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
168 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
169 class unionpeer(localrepo.localpeer): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
170 def canpush(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
171 return False |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
172 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
173 class unionrepository(localrepo.localrepository): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
174 def __init__(self, ui, path, path2): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
175 localrepo.localrepository.__init__(self, ui, path) |
20790
49f2d5644f04
config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents:
19630
diff
changeset
|
176 self.ui.setconfig('phases', 'publish', False, 'unionrepo') |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
177 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
178 self._url = 'union:%s+%s' % (util.expandpath(path), |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
179 util.expandpath(path2)) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
180 self.repo2 = localrepo.localrepository(ui, path2) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
181 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
182 @localrepo.unfilteredpropertycache |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
183 def changelog(self): |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20790
diff
changeset
|
184 return unionchangelog(self.svfs, self.repo2.svfs) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
185 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
186 def _clrev(self, rev2): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
187 """map from repo2 changelog rev to temporary rev in self.changelog""" |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
188 node = self.repo2.changelog.node(rev2) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
189 return self.changelog.rev(node) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
190 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
191 @localrepo.unfilteredpropertycache |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
192 def manifest(self): |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20790
diff
changeset
|
193 return unionmanifest(self.svfs, self.repo2.svfs, |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
194 self._clrev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
195 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
196 def url(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
197 return self._url |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
198 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
199 def file(self, f): |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20790
diff
changeset
|
200 return unionfilelog(self.svfs, f, self.repo2.svfs, |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
201 self._clrev, self) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
202 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
203 def close(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
204 self.repo2.close() |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
205 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
206 def cancopy(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
207 return False |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
208 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
209 def peer(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
210 return unionpeer(self) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
211 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
212 def getcwd(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
213 return os.getcwd() # always outside the repo |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
214 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
215 def instance(ui, path, create): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
216 if create: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
217 raise util.Abort(_('cannot create new union repository')) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
218 parentpath = ui.config("bundle", "mainreporoot", "") |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
219 if not parentpath: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
220 # try to find the correct path to the working directory repo |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
221 parentpath = cmdutil.findrepo(os.getcwd()) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
222 if parentpath is None: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
223 parentpath = '' |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
224 if parentpath: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
225 # Try to make the full path relative so we get a nice, short URL. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
226 # In particular, we don't want temp dir names in test outputs. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
227 cwd = os.getcwd() |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
228 if parentpath == cwd: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
229 parentpath = '' |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
230 else: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
231 cwd = os.path.join(cwd,'') |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
232 if parentpath.startswith(cwd): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
233 parentpath = parentpath[len(cwd):] |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
234 if path.startswith('union:'): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
235 s = path.split(":", 1)[1].split("+", 1) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
236 if len(s) == 1: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
237 repopath, repopath2 = parentpath, s[0] |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
238 else: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
239 repopath, repopath2 = s |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
240 else: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
241 repopath, repopath2 = parentpath, path |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
242 return unionrepository(ui, repopath, repopath2) |