Mercurial > public > mercurial-scm > hg-stable
annotate hgext/git/gitlog.py @ 52643:143063a94085
git: implement baselogindex.{rev,get_rev}
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Thu, 02 Jan 2025 11:24:09 -0500 |
parents | a26c5da900ff |
children | cdbfe5e7592e |
rev | line source |
---|---|
51901
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51321
diff
changeset
|
1 from __future__ import annotations |
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51321
diff
changeset
|
2 |
52516
3daaa5195a30
typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents:
52473
diff
changeset
|
3 from typing import ( |
52642
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
4 Iterable, |
52516
3daaa5195a30
typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents:
52473
diff
changeset
|
5 Iterator, |
3daaa5195a30
typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents:
52473
diff
changeset
|
6 ) |
3daaa5195a30
typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents:
52473
diff
changeset
|
7 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 from mercurial.i18n import _ |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
10 from mercurial.node import ( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
11 bin, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
12 hex, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
13 nullrev, |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46114
diff
changeset
|
14 sha1nodeconstants, |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
15 ) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 from mercurial import ( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 ancestor, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 changelog as hgchangelog, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 dagop, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 encoding, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 error, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 manifest, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 pycompat, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 ) |
52518
ba8f03ad8906
filelog: subclass the new `repository.ifilestorage` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
52516
diff
changeset
|
25 from mercurial.interfaces import ( |
ba8f03ad8906
filelog: subclass the new `repository.ifilestorage` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
52516
diff
changeset
|
26 repository, |
ba8f03ad8906
filelog: subclass the new `repository.ifilestorage` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
52516
diff
changeset
|
27 ) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 from mercurial.utils import stringutil |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 from . import ( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 gitutil, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 index, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 manifest as gitmanifest, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 |
44496
ec54b3d2af0b
git: don't fail import when pygit2 is not install
Martin von Zweigbergk <martinvonz@google.com>
parents:
44493
diff
changeset
|
35 pygit2 = gitutil.get_pygit2() |
ec54b3d2af0b
git: don't fail import when pygit2 is not install
Martin von Zweigbergk <martinvonz@google.com>
parents:
44493
diff
changeset
|
36 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
38 class baselog: # revlog.revlog): |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 """Common implementations between changelog and manifestlog.""" |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 def __init__(self, gr, db): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 self.gitrepo = gr |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 self._db = db |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
44 |
52516
3daaa5195a30
typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents:
52473
diff
changeset
|
45 def __len__(self) -> int: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 return int( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 self._db.execute('SELECT COUNT(*) FROM changelog').fetchone()[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
52642
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
50 def files(self): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
51 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
52 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
53 def storageinfo( |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
54 self, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
55 exclusivefiles=False, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
56 sharedfiles=False, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
57 revisionscount=False, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
58 trackedsize=False, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
59 storedsize=False, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
60 ): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
61 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
62 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
63 def verifyintegrity(self, state) -> Iterable[repository.iverifyproblem]: |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
64 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
65 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
66 def revs(self, start=0, stop=None): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
67 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
68 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
69 def addgroup( |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
70 self, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
71 deltas, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
72 linkmapper, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
73 transaction, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
74 addrevisioncb=None, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
75 duplicaterevisioncb=None, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
76 ): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
77 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
78 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
79 def commonancestorsheads(self, node1, node2): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
80 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
81 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
82 def descendants(self, revs): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
83 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
84 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
85 def heads(self, start=None, stop=None): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
86 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
87 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
88 def children(self, node): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
89 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
90 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
91 def emitrevisions( |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
92 self, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
93 nodes, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
94 nodesorder=None, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
95 revisiondata=False, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
96 assumehaveparentrevisions=False, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
97 ): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
98 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
99 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
100 def getstrippoint(self, minlink): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
101 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
102 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
103 def iscensored(self, rev): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
104 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
105 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
106 def parentrevs(self, rev): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
107 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
108 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
109 def rawdata(self, node): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
110 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
111 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
112 def revision(self, node): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
113 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
114 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
115 def size(self, rev): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
116 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
117 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
118 def strip(self, minlink, transaction): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
119 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
120 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
121 def addrevision( |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
122 self, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
123 revisiondata, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
124 transaction, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
125 linkrev, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
126 p1, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
127 p2, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
128 node=None, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
129 flags=0, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
130 cachedelta=None, |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
131 ): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
132 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
133 |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
134 def censorrevision(self, tr, node, tombstone=b''): |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
135 raise NotImplementedError |
a26c5da900ff
git: add stubs for filelog methods
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52518
diff
changeset
|
136 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 def rev(self, n): |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
138 if n == sha1nodeconstants.nullid: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
139 return -1 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 t = self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
141 'SELECT rev FROM changelog WHERE node = ?', (gitutil.togitnode(n),) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 ).fetchone() |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 if t is None: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 raise error.LookupError(n, b'00changelog.i', _(b'no node %d')) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
145 return t[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
146 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 def node(self, r): |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
148 if r == nullrev: |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
149 return sha1nodeconstants.nullid |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 t = self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 'SELECT node FROM changelog WHERE rev = ?', (r,) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 ).fetchone() |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
153 if t is None: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
154 raise error.LookupError(r, b'00changelog.i', _(b'no node')) |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
155 return bin(t[0]) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
156 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 def hasnode(self, n): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
158 t = self._db.execute( |
47021
ce24a00fe7f0
git: pass the correct type to the sqlite3 query for baselog.hasnode()
Matt Harbison <matt_harbison@yahoo.com>
parents:
47020
diff
changeset
|
159 'SELECT node FROM changelog WHERE node = ?', |
ce24a00fe7f0
git: pass the correct type to the sqlite3 query for baselog.hasnode()
Matt Harbison <matt_harbison@yahoo.com>
parents:
47020
diff
changeset
|
160 (pycompat.sysstr(n),), |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
161 ).fetchone() |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
162 return t is not None |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
164 |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
165 class baselogindex: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 def __init__(self, log): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 self._log = log |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
168 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 def has_node(self, n): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 return self._log.rev(n) != -1 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
171 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 def __len__(self): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
173 return len(self._log) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
174 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 def __getitem__(self, idx): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
176 p1rev, p2rev = self._log.parentrevs(idx) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
177 # TODO: it's messy that the index leaks so far out of the |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
178 # storage layer that we have to implement things like reading |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 # this raw tuple, which exposes revlog internals. |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
180 return ( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 # Pretend offset is just the index, since we don't really care. |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
182 idx, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
183 # Same with lengths |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
184 idx, # length |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
185 idx, # rawsize |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
186 -1, # delta base |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
187 idx, # linkrev TODO is this right? |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
188 p1rev, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
189 p2rev, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
190 self._log.node(idx), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
192 |
52643
143063a94085
git: implement baselogindex.{rev,get_rev}
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52642
diff
changeset
|
193 def rev(self, node): |
143063a94085
git: implement baselogindex.{rev,get_rev}
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52642
diff
changeset
|
194 return self._log.rev(node) |
143063a94085
git: implement baselogindex.{rev,get_rev}
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52642
diff
changeset
|
195 |
143063a94085
git: implement baselogindex.{rev,get_rev}
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52642
diff
changeset
|
196 def get_rev(self, node): |
143063a94085
git: implement baselogindex.{rev,get_rev}
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52642
diff
changeset
|
197 return self._log.get_rev(node) |
143063a94085
git: implement baselogindex.{rev,get_rev}
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
parents:
52642
diff
changeset
|
198 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
199 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
200 # TODO: an interface for the changelog type? |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
201 class changelog(baselog): |
45427
66a10bd1b8db
git: restore basic functionality after b3040b6739ce
Augie Fackler <raf@durin42.com>
parents:
45426
diff
changeset
|
202 # TODO: this appears to be an enumerated type, and should probably |
66a10bd1b8db
git: restore basic functionality after b3040b6739ce
Augie Fackler <raf@durin42.com>
parents:
45426
diff
changeset
|
203 # be part of the public changelog interface |
66a10bd1b8db
git: restore basic functionality after b3040b6739ce
Augie Fackler <raf@durin42.com>
parents:
45426
diff
changeset
|
204 _copiesstorage = b'extra' |
66a10bd1b8db
git: restore basic functionality after b3040b6739ce
Augie Fackler <raf@durin42.com>
parents:
45426
diff
changeset
|
205 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 def __contains__(self, rev): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 try: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
208 self.node(rev) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
209 return True |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
210 except error.LookupError: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
211 return False |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
212 |
44493
8b5f5d8ad783
gitlog: implement __iter__ on changelog
Augie Fackler <raf@durin42.com>
parents:
44492
diff
changeset
|
213 def __iter__(self): |
49292
d44e3c45f0e4
py3: replace `pycompat.xrange` by `range`
Manuel Jacob <me@manueljacob.de>
parents:
49037
diff
changeset
|
214 return iter(range(len(self))) |
44493
8b5f5d8ad783
gitlog: implement __iter__ on changelog
Augie Fackler <raf@durin42.com>
parents:
44492
diff
changeset
|
215 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
216 @property |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
217 def filteredrevs(self): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
218 # TODO: we should probably add a refs/hg/ namespace for hidden |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
219 # heads etc, but that's an idea for later. |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 return set() |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
221 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
222 @property |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
223 def index(self): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
224 return baselogindex(self) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
225 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
226 @property |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
227 def nodemap(self): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
228 r = { |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
229 bin(v[0]): v[1] |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
230 for v in self._db.execute('SELECT node, rev FROM changelog') |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 } |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
232 r[sha1nodeconstants.nullid] = nullrev |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
233 return r |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
234 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 def tip(self): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
236 t = self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
237 'SELECT node FROM changelog ORDER BY rev DESC LIMIT 1' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 ).fetchone() |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
239 if t: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
240 return bin(t[0]) |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
241 return sha1nodeconstants.nullid |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
243 def revs(self, start=0, stop=None): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
244 if stop is None: |
47020
2a77c817d451
git: use the correct type for stopping changelog.revs()
Matt Harbison <matt_harbison@yahoo.com>
parents:
47019
diff
changeset
|
245 stop = self.tiprev() |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
246 t = self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
247 'SELECT rev FROM changelog ' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
248 'WHERE rev >= ? AND rev <= ? ' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
249 'ORDER BY REV ASC', |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
250 (start, stop), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
251 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
252 return (int(r[0]) for r in t) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
253 |
45940
6aacc39501f7
gitlog: add tiprev() function
Augie Fackler <raf@durin42.com>
parents:
45529
diff
changeset
|
254 def tiprev(self): |
6aacc39501f7
gitlog: add tiprev() function
Augie Fackler <raf@durin42.com>
parents:
45529
diff
changeset
|
255 t = self._db.execute( |
45954
66f6ca2b7aee
cleanup: fix a few recent black formatting violations
Matt Harbison <matt_harbison@yahoo.com>
parents:
45940
diff
changeset
|
256 'SELECT rev FROM changelog ' 'ORDER BY REV DESC ' 'LIMIT 1' |
47017
497cedcb6504
git: make changelog.tiprev() return int instead of tuple (issue6510)
Matt Harbison <matt_harbison@yahoo.com>
parents:
47016
diff
changeset
|
257 ).fetchone() |
497cedcb6504
git: make changelog.tiprev() return int instead of tuple (issue6510)
Matt Harbison <matt_harbison@yahoo.com>
parents:
47016
diff
changeset
|
258 |
497cedcb6504
git: make changelog.tiprev() return int instead of tuple (issue6510)
Matt Harbison <matt_harbison@yahoo.com>
parents:
47016
diff
changeset
|
259 if t is not None: |
497cedcb6504
git: make changelog.tiprev() return int instead of tuple (issue6510)
Matt Harbison <matt_harbison@yahoo.com>
parents:
47016
diff
changeset
|
260 return t[0] |
497cedcb6504
git: make changelog.tiprev() return int instead of tuple (issue6510)
Matt Harbison <matt_harbison@yahoo.com>
parents:
47016
diff
changeset
|
261 return -1 |
45940
6aacc39501f7
gitlog: add tiprev() function
Augie Fackler <raf@durin42.com>
parents:
45529
diff
changeset
|
262 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
263 def _partialmatch(self, id): |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
264 if sha1nodeconstants.wdirhex.startswith(id): |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
265 raise error.WdirUnsupported |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
266 candidates = [ |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
267 bin(x[0]) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
268 for x in self._db.execute( |
47016
846920d89476
git: fix partial node matching
Matt Harbison <matt_harbison@yahoo.com>
parents:
46797
diff
changeset
|
269 'SELECT node FROM changelog WHERE node LIKE ?', |
846920d89476
git: fix partial node matching
Matt Harbison <matt_harbison@yahoo.com>
parents:
46797
diff
changeset
|
270 (pycompat.sysstr(id + b'%'),), |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
271 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
272 ] |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
273 if sha1nodeconstants.nullhex.startswith(id): |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
274 candidates.append(sha1nodeconstants.nullid) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
275 if len(candidates) > 1: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
276 raise error.AmbiguousPrefixLookupError( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
277 id, b'00changelog.i', _(b'ambiguous identifier') |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
278 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
279 if candidates: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
280 return candidates[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
281 return None |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
282 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
283 def flags(self, rev): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
284 return 0 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
285 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
286 def shortest(self, node, minlength=1): |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
287 nodehex = hex(node) |
49292
d44e3c45f0e4
py3: replace `pycompat.xrange` by `range`
Manuel Jacob <me@manueljacob.de>
parents:
49037
diff
changeset
|
288 for attempt in range(minlength, len(nodehex) + 1): |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
289 candidate = nodehex[:attempt] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
290 matches = int( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
291 self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
292 'SELECT COUNT(*) FROM changelog WHERE node LIKE ?', |
44490
6d953b3fc2bd
git: make {shortest()} return shortest *unique* prefix
Martin von Zweigbergk <martinvonz@google.com>
parents:
44489
diff
changeset
|
293 (pycompat.sysstr(candidate + b'%'),), |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
294 ).fetchone()[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
295 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
296 if matches == 1: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
297 return candidate |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
298 return nodehex |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
299 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
300 def headrevs(self, revs=None): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
301 realheads = [ |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
302 int(x[0]) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
303 for x in self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
304 'SELECT rev FROM changelog ' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
305 'INNER JOIN heads ON changelog.node = heads.node' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
306 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
307 ] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
308 if revs: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
309 return sorted([r for r in revs if r in realheads]) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
310 return sorted(realheads) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
311 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
312 def changelogrevision(self, nodeorrev): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
313 # Ensure we have a node id |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
314 if isinstance(nodeorrev, int): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
315 n = self.node(nodeorrev) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
316 else: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
317 n = nodeorrev |
47023
f8fa7ec53517
git: initialize `extra` to have at least the branch name for nullid
Matt Harbison <matt_harbison@yahoo.com>
parents:
47021
diff
changeset
|
318 extra = {b'branch': b'default'} |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
319 # handle looking up nullid |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
320 if n == sha1nodeconstants.nullid: |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
321 return hgchangelog._changelogrevision( |
47084 | 322 extra=extra, manifest=sha1nodeconstants.nullid |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
323 ) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
324 hn = gitutil.togitnode(n) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
325 # We've got a real commit! |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
326 files = [ |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
327 r[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
328 for r in self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
329 'SELECT filename FROM changedfiles ' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
330 'WHERE node = ? and filenode != ?', |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
331 (hn, gitutil.nullgit), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
332 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
333 ] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
334 filesremoved = [ |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
335 r[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
336 for r in self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
337 'SELECT filename FROM changedfiles ' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
338 'WHERE node = ? and filenode = ?', |
47019
03c73fc6f89a
git: use the proper filenode for deleted files in changelog.changelogrevision
Matt Harbison <matt_harbison@yahoo.com>
parents:
47017
diff
changeset
|
339 (hn, gitutil.nullgit), |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
340 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
341 ] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
342 c = self.gitrepo[hn] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
343 return hgchangelog._changelogrevision( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
344 manifest=n, # pretend manifest the same as the commit node |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
345 user=b'%s <%s>' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
346 % (c.author.name.encode('utf8'), c.author.email.encode('utf8')), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
347 date=(c.author.time, -c.author.offset * 60), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
348 files=files, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
349 # TODO filesadded in the index |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
350 filesremoved=filesremoved, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
351 description=c.message.encode('utf8'), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
352 # TODO do we want to handle extra? how? |
47023
f8fa7ec53517
git: initialize `extra` to have at least the branch name for nullid
Matt Harbison <matt_harbison@yahoo.com>
parents:
47021
diff
changeset
|
353 extra=extra, |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
354 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
355 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
356 def ancestors(self, revs, stoprev=0, inclusive=False): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
357 revs = list(revs) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
358 tip = self.rev(self.tip()) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
359 for r in revs: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
360 if r > tip: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
361 raise IndexError(b'Invalid rev %r' % r) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
362 return ancestor.lazyancestors( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
363 self.parentrevs, revs, stoprev=stoprev, inclusive=inclusive |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
364 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
365 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
366 # Cleanup opportunity: this is *identical* to the revlog.py version |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
367 def descendants(self, revs): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
368 return dagop.descendantrevs(revs, self.revs, self.parentrevs) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
369 |
44904
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
370 def incrementalmissingrevs(self, common=None): |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
371 """Return an object that can be used to incrementally compute the |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
372 revision numbers of the ancestors of arbitrary sets that are not |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
373 ancestors of common. This is an ancestor.incrementalmissingancestors |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
374 object. |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
375 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
376 'common' is a list of revision numbers. If common is not supplied, uses |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
377 nullrev. |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
378 """ |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
379 if common is None: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
380 common = [nullrev] |
44904
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
381 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
382 return ancestor.incrementalmissingancestors(self.parentrevs, common) |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
383 |
49382
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
384 def findmissingrevs(self, common=None, heads=None): |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
385 """Return the revision numbers of the ancestors of heads that |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
386 are not ancestors of common. |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
387 |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
388 More specifically, return a list of revision numbers corresponding to |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
389 nodes N such that every N satisfies the following constraints: |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
390 |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
391 1. N is an ancestor of some node in 'heads' |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
392 2. N is not an ancestor of any node in 'common' |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
393 |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
394 The list is sorted by revision number, meaning it is |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
395 topologically sorted. |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
396 |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
397 'heads' and 'common' are both lists of revision numbers. If heads is |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
398 not supplied, uses all of the revlog's heads. If common is not |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
399 supplied, uses nullid.""" |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
400 if common is None: |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
401 common = [nullrev] |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
402 if heads is None: |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
403 heads = self.headrevs() |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
404 |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
405 inc = self.incrementalmissingrevs(common=common) |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
406 return inc.missingancestors(heads) |
1e12ea7d8435
git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
Anton Shestakov <av6@dwimlabs.net>
parents:
49296
diff
changeset
|
407 |
44904
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
408 def findmissing(self, common=None, heads=None): |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
409 """Return the ancestors of heads that are not ancestors of common. |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
410 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
411 More specifically, return a list of nodes N such that every N |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
412 satisfies the following constraints: |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
413 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
414 1. N is an ancestor of some node in 'heads' |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
415 2. N is not an ancestor of any node in 'common' |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
416 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
417 The list is sorted by revision number, meaning it is |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
418 topologically sorted. |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
419 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
420 'heads' and 'common' are both lists of node IDs. If heads is |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
421 not supplied, uses all of the revlog's heads. If common is not |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
422 supplied, uses nullid.""" |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
423 if common is None: |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
424 common = [sha1nodeconstants.nullid] |
44904
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
425 if heads is None: |
51321
d91b55371d6f
git-hgext: adjust to the lack of `changelog.heads` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49382
diff
changeset
|
426 heads = [self.node(r) for r in self.headrevs()] |
44904
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
427 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
428 common = [self.rev(n) for n in common] |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
429 heads = [self.rev(n) for n in heads] |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
430 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
431 inc = self.incrementalmissingrevs(common=common) |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
432 return [self.node(r) for r in inc.missingancestors(heads)] |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
433 |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
434 def children(self, node): |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
435 """find the children of a given node""" |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
436 c = [] |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
437 p = self.rev(node) |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
438 for r in self.revs(start=p + 1): |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
439 prevs = [pr for pr in self.parentrevs(r) if pr != nullrev] |
44904
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
440 if prevs: |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
441 for pr in prevs: |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
442 if pr == p: |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
443 c.append(self.node(r)) |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
444 elif p == nullrev: |
44904
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
445 c.append(self.node(r)) |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
446 return c |
3e09d22a0bf5
git: implement some changelog methods
Romain DEP. <rom1dep@gmail.com>
parents:
44903
diff
changeset
|
447 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
448 def reachableroots(self, minroot, heads, roots, includepath=False): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
449 return dagop._reachablerootspure( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
450 self.parentrevs, minroot, roots, heads, includepath |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
451 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
452 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
453 # Cleanup opportunity: this is *identical* to the revlog.py version |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
454 def isancestor(self, a, b): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
455 a, b = self.rev(a), self.rev(b) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
456 return self.isancestorrev(a, b) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
457 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
458 # Cleanup opportunity: this is *identical* to the revlog.py version |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
459 def isancestorrev(self, a, b): |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
460 if a == nullrev: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
461 return True |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
462 elif a == b: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
463 return True |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
464 elif a > b: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
465 return False |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
466 return bool(self.reachableroots(a, [b], [a], includepath=False)) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
467 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
468 def parentrevs(self, rev): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
469 n = self.node(rev) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
470 hn = gitutil.togitnode(n) |
44903
8bfc6cc8e480
git: avoid looking-up parents for the null commit
Romain DEP. <rom1dep@gmail.com>
parents:
44496
diff
changeset
|
471 if hn != gitutil.nullgit: |
8bfc6cc8e480
git: avoid looking-up parents for the null commit
Romain DEP. <rom1dep@gmail.com>
parents:
44496
diff
changeset
|
472 c = self.gitrepo[hn] |
8bfc6cc8e480
git: avoid looking-up parents for the null commit
Romain DEP. <rom1dep@gmail.com>
parents:
44496
diff
changeset
|
473 else: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
474 return nullrev, nullrev |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
475 p1 = p2 = nullrev |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
476 if c.parents: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
477 p1 = self.rev(c.parents[0].id.raw) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
478 if len(c.parents) > 2: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
479 raise error.Abort(b'TODO octopus merge handling') |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
480 if len(c.parents) == 2: |
44492
f19491aae641
gitlog: fix embarassing bug that prevented log from showing correct parents
Augie Fackler <raf@durin42.com>
parents:
44490
diff
changeset
|
481 p2 = self.rev(c.parents[1].id.raw) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
482 return p1, p2 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
483 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
484 # Private method is used at least by the tags code. |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
485 _uncheckedparentrevs = parentrevs |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
486 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
487 def commonancestorsheads(self, a, b): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
488 # TODO the revlog verson of this has a C path, so we probably |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
489 # need to optimize this... |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
490 a, b = self.rev(a), self.rev(b) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
491 return [ |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
492 self.node(n) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
493 for n in ancestor.commonancestorsheads(self.parentrevs, a, b) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
494 ] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
495 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
496 def branchinfo(self, rev): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
497 """Git doesn't do named branches, so just put everything on default.""" |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
498 return b'default', False |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
499 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
500 def delayupdate(self, tr): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
501 # TODO: I think we can elide this because we're just dropping |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
502 # an object in the git repo? |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
503 pass |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
504 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
505 def add( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
506 self, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
507 manifest, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
508 files, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
509 desc, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
510 transaction, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
511 p1, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
512 p2, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
513 user, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
514 date=None, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
515 extra=None, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
516 p1copies=None, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
517 p2copies=None, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
518 filesadded=None, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
519 filesremoved=None, |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
520 ): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
521 parents = [] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
522 hp1, hp2 = gitutil.togitnode(p1), gitutil.togitnode(p2) |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
523 if p1 != sha1nodeconstants.nullid: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
524 parents.append(hp1) |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
525 if p2 and p2 != sha1nodeconstants.nullid: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
526 parents.append(hp2) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
527 assert date is not None |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
528 timestamp, tz = date |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
529 sig = pygit2.Signature( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
530 encoding.unifromlocal(stringutil.person(user)), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
531 encoding.unifromlocal(stringutil.email(user)), |
45529
e7587430ca23
git: also convert timezone to int (issue6359)
Augie Fackler <augie@google.com>
parents:
45427
diff
changeset
|
532 int(timestamp), |
45426
8ddbb75bad09
git: convert tz offset to int (issue6359)
Augie Fackler <raf@durin42.com>
parents:
44992
diff
changeset
|
533 -int(tz // 60), |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
534 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
535 oid = self.gitrepo.create_commit( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
536 None, sig, sig, desc, gitutil.togitnode(manifest), parents |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
537 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
538 # Set up an internal reference to force the commit into the |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
539 # changelog. Hypothetically, we could even use this refs/hg/ |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
540 # namespace to allow for anonymous heads on git repos, which |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
541 # would be neat. |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
542 self.gitrepo.references.create( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
543 'refs/hg/internal/latest-commit', oid, force=True |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
544 ) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
545 # Reindex now to pick up changes. We omit the progress |
44992
83e41b73d115
git: add debug logging when there's a mismatch in the cached heads list
Augie Fackler <augie@google.com>
parents:
44904
diff
changeset
|
546 # and log callbacks because this will be very quick. |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
547 index._index_repo(self.gitrepo, self._db) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
548 return oid.raw |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
549 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
550 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
551 class manifestlog(baselog): |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46114
diff
changeset
|
552 nodeconstants = sha1nodeconstants |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46114
diff
changeset
|
553 |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
554 def __getitem__(self, node): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
555 return self.get(b'', node) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
556 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
557 def get(self, relpath, node): |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
558 if node == sha1nodeconstants.nullid: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
559 # TODO: this should almost certainly be a memgittreemanifestctx |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
560 return manifest.memtreemanifestctx(self, relpath) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
561 commit = self.gitrepo[gitutil.togitnode(node)] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
562 t = commit.tree |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
563 if relpath: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
564 parts = relpath.split(b'/') |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
565 for p in parts: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
566 te = t[p] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
567 t = self.gitrepo[te.id] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
568 return gitmanifest.gittreemanifestctx(self.gitrepo, t) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
569 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
570 |
52518
ba8f03ad8906
filelog: subclass the new `repository.ifilestorage` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
52516
diff
changeset
|
571 class filelog(baselog, repository.ifilestorage): |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
572 def __init__(self, gr, db, path): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
573 super(filelog, self).__init__(gr, db) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
574 assert isinstance(path, bytes) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
575 self.path = path |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
576 self.nullid = sha1nodeconstants.nullid |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
577 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
578 def read(self, node): |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46797
diff
changeset
|
579 if node == sha1nodeconstants.nullid: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
580 return b'' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
581 return self.gitrepo[gitutil.togitnode(node)].data |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
582 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
583 def lookup(self, node): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
584 if len(node) not in (20, 40): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
585 node = int(node) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
586 if isinstance(node, int): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
587 assert False, b'todo revnums for nodes' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
588 if len(node) == 40: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
589 node = bin(node) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
590 hnode = gitutil.togitnode(node) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
591 if hnode in self.gitrepo: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
592 return node |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
593 raise error.LookupError(self.path, node, _(b'no match found')) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
594 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
595 def cmp(self, node, text): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
596 """Returns True if text is different than content at `node`.""" |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
597 return self.read(node) != text |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
598 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
599 def add(self, text, meta, transaction, link, p1=None, p2=None): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
600 assert not meta # Should we even try to handle this? |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
601 return self.gitrepo.create_blob(text).raw |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
602 |
52516
3daaa5195a30
typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents:
52473
diff
changeset
|
603 def __iter__(self) -> Iterator[int]: |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
604 for clrev in self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
605 ''' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
606 SELECT rev FROM changelog |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
607 INNER JOIN changedfiles ON changelog.node = changedfiles.node |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
608 WHERE changedfiles.filename = ? AND changedfiles.filenode != ? |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
609 ''', |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
610 (pycompat.fsdecode(self.path), gitutil.nullgit), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
611 ): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
612 yield clrev[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
613 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
614 def linkrev(self, fr): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
615 return fr |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
616 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
617 def rev(self, node): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
618 row = self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
619 ''' |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
620 SELECT rev FROM changelog |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
621 INNER JOIN changedfiles ON changelog.node = changedfiles.node |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
622 WHERE changedfiles.filename = ? AND changedfiles.filenode = ?''', |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
623 (pycompat.fsdecode(self.path), gitutil.togitnode(node)), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
624 ).fetchone() |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
625 if row is None: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
626 raise error.LookupError(self.path, node, _(b'no such node')) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
627 return int(row[0]) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
628 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
629 def node(self, rev): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
630 maybe = self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
631 '''SELECT filenode FROM changedfiles |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
632 INNER JOIN changelog ON changelog.node = changedfiles.node |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
633 WHERE changelog.rev = ? AND filename = ? |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
634 ''', |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
635 (rev, pycompat.fsdecode(self.path)), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
636 ).fetchone() |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
637 if maybe is None: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
638 raise IndexError('gitlog %r out of range %d' % (self.path, rev)) |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
639 return bin(maybe[0]) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
640 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
641 def parents(self, node): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
642 gn = gitutil.togitnode(node) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
643 gp = pycompat.fsdecode(self.path) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
644 ps = [] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
645 for p in self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
646 '''SELECT p1filenode, p2filenode FROM changedfiles |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
647 WHERE filenode = ? AND filename = ? |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
648 ''', |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
649 (gn, gp), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
650 ).fetchone(): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
651 if p is None: |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
652 commit = self._db.execute( |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
653 "SELECT node FROM changedfiles " |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
654 "WHERE filenode = ? AND filename = ?", |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
655 (gn, gp), |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
656 ).fetchone()[0] |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
657 # This filelog is missing some data. Build the |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
658 # filelog, then recurse (which will always find data). |
49296
ef5f5f1cbd90
py3: constant-fold some `pycompat.ispy3`
Manuel Jacob <me@manueljacob.de>
parents:
49292
diff
changeset
|
659 commit = commit.decode('ascii') |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
660 index.fill_in_filelog(self.gitrepo, self._db, commit, gp, gn) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
661 return self.parents(node) |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
662 else: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45954
diff
changeset
|
663 ps.append(bin(p)) |
44489
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
664 return ps |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
665 |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
666 def renamed(self, node): |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
667 # TODO: renames/copies |
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
668 return False |