Show More
@@ -78,8 +78,8 b' def catcommit(repo, n, prefix, changes=N' | |||||
78 | if not changes: |
|
78 | if not changes: | |
79 | changes = repo.changelog.read(n) |
|
79 | changes = repo.changelog.read(n) | |
80 | print "tree %s" % (hg.short(changes[0])) |
|
80 | print "tree %s" % (hg.short(changes[0])) | |
81 |
if i1 != |
|
81 | if i1 != hg.nullrev: print "parent %s" % (h1) | |
82 |
if i2 != |
|
82 | if i2 != hg.nullrev: print "parent %s" % (h2) | |
83 | date_ar = changes[2] |
|
83 | date_ar = changes[2] | |
84 | date = int(float(date_ar[0])) |
|
84 | date = int(float(date_ar[0])) | |
85 | lines = changes[4].splitlines() |
|
85 | lines = changes[4].splitlines() | |
@@ -241,10 +241,10 b' def revtree(args, repo, full="tree", max' | |||||
241 | date = changes[2][0] |
|
241 | date = changes[2][0] | |
242 | print "%s %s:%s" % (date, h, mask), |
|
242 | print "%s %s:%s" % (date, h, mask), | |
243 | mask = is_reachable(want_sha1, reachable, p1) |
|
243 | mask = is_reachable(want_sha1, reachable, p1) | |
244 |
if i1 != |
|
244 | if i1 != hg.nullrev and mask > 0: | |
245 | print "%s:%s " % (h1, mask), |
|
245 | print "%s:%s " % (h1, mask), | |
246 | mask = is_reachable(want_sha1, reachable, p2) |
|
246 | mask = is_reachable(want_sha1, reachable, p2) | |
247 |
if i2 != |
|
247 | if i2 != hg.nullrev and mask > 0: | |
248 | print "%s:%s " % (h2, mask), |
|
248 | print "%s:%s " % (h2, mask), | |
249 | print "" |
|
249 | print "" | |
250 | if maxnr and count >= maxnr: |
|
250 | if maxnr and count >= maxnr: |
@@ -1310,7 +1310,7 b' class queue:' | |||||
1310 | for r in rev: |
|
1310 | for r in rev: | |
1311 | p1, p2 = repo.changelog.parentrevs(r) |
|
1311 | p1, p2 = repo.changelog.parentrevs(r) | |
1312 | n = repo.changelog.node(r) |
|
1312 | n = repo.changelog.node(r) | |
1313 |
if p2 != |
|
1313 | if p2 != revlog.nullrev: | |
1314 | raise util.Abort(_('cannot import merge revision %d') % r) |
|
1314 | raise util.Abort(_('cannot import merge revision %d') % r) | |
1315 | if lastparent and lastparent != r: |
|
1315 | if lastparent and lastparent != r: | |
1316 | raise util.Abort(_('revision %d is not the parent of %d') |
|
1316 | raise util.Abort(_('revision %d is not the parent of %d') |
@@ -116,7 +116,7 b' def walkchangerevs(ui, repo, pats, chang' | |||||
116 | last = filelog.count() - 1 |
|
116 | last = filelog.count() - 1 | |
117 | else: |
|
117 | else: | |
118 | last = filelog.rev(node) |
|
118 | last = filelog.rev(node) | |
119 |
for i, window in increasing_windows(last, |
|
119 | for i, window in increasing_windows(last, nullrev): | |
120 | revs = [] |
|
120 | revs = [] | |
121 | for j in xrange(i - window, i + 1): |
|
121 | for j in xrange(i - window, i + 1): | |
122 | n = filelog.node(j) |
|
122 | n = filelog.node(j) | |
@@ -157,7 +157,8 b' def walkchangerevs(ui, repo, pats, chang' | |||||
157 |
|
157 | |||
158 | # The slow path checks files modified in every changeset. |
|
158 | # The slow path checks files modified in every changeset. | |
159 | def changerevgen(): |
|
159 | def changerevgen(): | |
160 |
for i, window in increasing_windows(repo.changelog.count()-1, |
|
160 | for i, window in increasing_windows(repo.changelog.count()-1, | |
|
161 | nullrev): | |||
161 | for j in xrange(i - window, i + 1): |
|
162 | for j in xrange(i - window, i + 1): | |
162 | yield j, change(j)[3] |
|
163 | yield j, change(j)[3] | |
163 |
|
164 | |||
@@ -169,7 +170,7 b' def walkchangerevs(ui, repo, pats, chang' | |||||
169 |
|
170 | |||
170 | class followfilter: |
|
171 | class followfilter: | |
171 | def __init__(self, onlyfirst=False): |
|
172 | def __init__(self, onlyfirst=False): | |
172 |
self.startrev = |
|
173 | self.startrev = nullrev | |
173 | self.roots = [] |
|
174 | self.roots = [] | |
174 | self.onlyfirst = onlyfirst |
|
175 | self.onlyfirst = onlyfirst | |
175 |
|
176 | |||
@@ -178,9 +179,10 b' def walkchangerevs(ui, repo, pats, chang' | |||||
178 | if self.onlyfirst: |
|
179 | if self.onlyfirst: | |
179 | return repo.changelog.parentrevs(rev)[0:1] |
|
180 | return repo.changelog.parentrevs(rev)[0:1] | |
180 | else: |
|
181 | else: | |
181 |
return filter(lambda x: x != |
|
182 | return filter(lambda x: x != nullrev, | |
182 |
|
183 | repo.changelog.parentrevs(rev)) | ||
183 | if self.startrev == -1: |
|
184 | ||
|
185 | if self.startrev == nullrev: | |||
184 | self.startrev = rev |
|
186 | self.startrev = rev | |
185 | return True |
|
187 | return True | |
186 |
|
188 | |||
@@ -322,7 +324,7 b' class changeset_printer(object):' | |||||
322 |
|
324 | |||
323 | parents = log.parentrevs(rev) |
|
325 | parents = log.parentrevs(rev) | |
324 | if not self.ui.debugflag: |
|
326 | if not self.ui.debugflag: | |
325 |
parents = [p for p in parents if p != |
|
327 | parents = [p for p in parents if p != nullrev] | |
326 | if len(parents) == 1 and parents[0] == rev-1: |
|
328 | if len(parents) == 1 and parents[0] == rev-1: | |
327 | parents = [] |
|
329 | parents = [] | |
328 | parents = [(p, hexfunc(log.node(p))) for p in parents] |
|
330 | parents = [(p, hexfunc(log.node(p))) for p in parents] | |
@@ -1872,7 +1874,7 b' def log(ui, repo, *pats, **opts):' | |||||
1872 | if rev in rcache[fn]: |
|
1874 | if rev in rcache[fn]: | |
1873 | return rcache[fn][rev] |
|
1875 | return rcache[fn][rev] | |
1874 | mr = repo.manifest.rev(man) |
|
1876 | mr = repo.manifest.rev(man) | |
1875 |
if repo.manifest.parentrevs(mr) != (mr - 1, |
|
1877 | if repo.manifest.parentrevs(mr) != (mr - 1, nullrev): | |
1876 | return ncache[fn].get(repo.manifest.find(man, fn)[0]) |
|
1878 | return ncache[fn].get(repo.manifest.find(man, fn)[0]) | |
1877 | if not dcache or dcache[0] != man: |
|
1879 | if not dcache or dcache[0] != man: | |
1878 | dcache[:] = [man, repo.manifest.readdelta(man)] |
|
1880 | dcache[:] = [man, repo.manifest.readdelta(man)] | |
@@ -1888,7 +1890,8 b' def log(ui, repo, *pats, **opts):' | |||||
1888 | elif st == 'add': |
|
1890 | elif st == 'add': | |
1889 | du.bump(rev) |
|
1891 | du.bump(rev) | |
1890 | changenode = repo.changelog.node(rev) |
|
1892 | changenode = repo.changelog.node(rev) | |
1891 |
parents = [p for p in repo.changelog.parentrevs(rev) |
|
1893 | parents = [p for p in repo.changelog.parentrevs(rev) | |
|
1894 | if p != nullrev] | |||
1892 | if opts['no_merges'] and len(parents) == 2: |
|
1895 | if opts['no_merges'] and len(parents) == 2: | |
1893 | continue |
|
1896 | continue | |
1894 | if opts['only_merges'] and len(parents) != 2: |
|
1897 | if opts['only_merges'] and len(parents) != 2: | |
@@ -1922,7 +1925,7 b' def log(ui, repo, *pats, **opts):' | |||||
1922 | if parents: |
|
1925 | if parents: | |
1923 | prev = parents[0] |
|
1926 | prev = parents[0] | |
1924 | else: |
|
1927 | else: | |
1925 |
prev = |
|
1928 | prev = nullrev | |
1926 | prev = repo.changelog.node(prev) |
|
1929 | prev = repo.changelog.node(prev) | |
1927 | patch.diff(repo, prev, changenode, match=matchfn, fp=du) |
|
1930 | patch.diff(repo, prev, changenode, match=matchfn, fp=du) | |
1928 | du.write("\n\n") |
|
1931 | du.write("\n\n") |
@@ -39,7 +39,7 b' class changectx(object):' | |||||
39 | return self._rev == other._rev |
|
39 | return self._rev == other._rev | |
40 |
|
40 | |||
41 | def __nonzero__(self): |
|
41 | def __nonzero__(self): | |
42 |
return self._rev != |
|
42 | return self._rev != nullrev | |
43 |
|
43 | |||
44 | def __getattr__(self, name): |
|
44 | def __getattr__(self, name): | |
45 | if name == '_changeset': |
|
45 | if name == '_changeset': | |
@@ -257,7 +257,7 b' class filectx(object):' | |||||
257 | if r: |
|
257 | if r: | |
258 | pl[0] = (r[0], getlog(r[0]).rev(r[1])) |
|
258 | pl[0] = (r[0], getlog(r[0]).rev(r[1])) | |
259 |
|
259 | |||
260 |
return [ |
|
260 | return [getctx(p, n) for p, n in pl if n != nullrev] | |
261 |
|
261 | |||
262 | # use linkrev to find the first changeset where self appeared |
|
262 | # use linkrev to find the first changeset where self appeared | |
263 | if self.rev() != self._filelog.linkrev(self._filenode): |
|
263 | if self.rev() != self._filelog.linkrev(self._filenode): |
@@ -332,10 +332,10 b' class localrepository(repo.repository):' | |||||
332 | node, label = l.rstrip().split(" ", 1) |
|
332 | node, label = l.rstrip().split(" ", 1) | |
333 | partial[label] = bin(node) |
|
333 | partial[label] = bin(node) | |
334 | else: # invalidate the cache |
|
334 | else: # invalidate the cache | |
335 |
last, lrev = nullid, |
|
335 | last, lrev = nullid, nullrev | |
336 | f.close() |
|
336 | f.close() | |
337 | except IOError: |
|
337 | except IOError: | |
338 |
last, lrev = nullid, |
|
338 | last, lrev = nullid, nullrev | |
339 | return partial, last, lrev |
|
339 | return partial, last, lrev | |
340 |
|
340 | |||
341 | def _writebranchcache(self, branches, tip, tiprev): |
|
341 | def _writebranchcache(self, branches, tip, tiprev): |
@@ -34,7 +34,7 b' def filemerge(repo, fw, fo, wctx, mctx):' | |||||
34 |
|
34 | |||
35 | fca = fcm.ancestor(fco) |
|
35 | fca = fcm.ancestor(fco) | |
36 | if not fca: |
|
36 | if not fca: | |
37 |
fca = repo.filectx(fw, fileid= |
|
37 | fca = repo.filectx(fw, fileid=nullrev) | |
38 | a = repo.wjoin(fw) |
|
38 | a = repo.wjoin(fw) | |
39 | b = temp("base", fca) |
|
39 | b = temp("base", fca) | |
40 | c = temp("other", fco) |
|
40 | c = temp("other", fco) |
@@ -10,6 +10,7 b' of the GNU General Public License, incor' | |||||
10 | from demandload import demandload |
|
10 | from demandload import demandload | |
11 | demandload(globals(), "binascii") |
|
11 | demandload(globals(), "binascii") | |
12 |
|
12 | |||
|
13 | nullrev = -1 | |||
13 | nullid = "\0" * 20 |
|
14 | nullid = "\0" * 20 | |
14 |
|
15 | |||
15 | def hex(node): |
|
16 | def hex(node): |
@@ -102,7 +102,7 b' class lazyparser(object):' | |||||
102 | self.datasize = size |
|
102 | self.datasize = size | |
103 | self.l = size/self.s |
|
103 | self.l = size/self.s | |
104 | self.index = [None] * self.l |
|
104 | self.index = [None] * self.l | |
105 |
self.map = {nullid: |
|
105 | self.map = {nullid: nullrev} | |
106 | self.allmap = 0 |
|
106 | self.allmap = 0 | |
107 | self.all = 0 |
|
107 | self.all = 0 | |
108 | self.mapfind_count = 0 |
|
108 | self.mapfind_count = 0 | |
@@ -387,14 +387,14 b' class revlog(object):' | |||||
387 | e[0] = self.offset_type(0, type) |
|
387 | e[0] = self.offset_type(0, type) | |
388 | self.index[0] = e |
|
388 | self.index[0] = e | |
389 | else: |
|
389 | else: | |
390 |
self.nodemap = { |
|
390 | self.nodemap = {nullid: nullrev} | |
391 | self.index = [] |
|
391 | self.index = [] | |
392 |
|
392 | |||
393 |
|
393 | |||
394 | def parseindex(self, fp, st): |
|
394 | def parseindex(self, fp, st): | |
395 | s = struct.calcsize(self.indexformat) |
|
395 | s = struct.calcsize(self.indexformat) | |
396 | self.index = [] |
|
396 | self.index = [] | |
397 |
self.nodemap = {nullid: |
|
397 | self.nodemap = {nullid: nullrev} | |
398 | inline = self.inlinedata() |
|
398 | inline = self.inlinedata() | |
399 | n = 0 |
|
399 | n = 0 | |
400 | leftover = None |
|
400 | leftover = None | |
@@ -474,7 +474,7 b' class revlog(object):' | |||||
474 | except KeyError: |
|
474 | except KeyError: | |
475 | raise RevlogError(_('%s: no node %s') % (self.indexfile, hex(node))) |
|
475 | raise RevlogError(_('%s: no node %s') % (self.indexfile, hex(node))) | |
476 | def linkrev(self, node): |
|
476 | def linkrev(self, node): | |
477 |
return (node == nullid) and |
|
477 | return (node == nullid) and nullrev or self.index[self.rev(node)][-4] | |
478 | def parents(self, node): |
|
478 | def parents(self, node): | |
479 | if node == nullid: return (nullid, nullid) |
|
479 | if node == nullid: return (nullid, nullid) | |
480 | r = self.rev(node) |
|
480 | r = self.rev(node) | |
@@ -483,15 +483,15 b' class revlog(object):' | |||||
483 | return d |
|
483 | return d | |
484 | return (self.node(d[0]), self.node(d[1])) |
|
484 | return (self.node(d[0]), self.node(d[1])) | |
485 | def parentrevs(self, rev): |
|
485 | def parentrevs(self, rev): | |
486 |
if rev == |
|
486 | if rev == nullrev: | |
487 |
return ( |
|
487 | return (nullrev, nullrev) | |
488 | d = self.index[rev][-3:-1] |
|
488 | d = self.index[rev][-3:-1] | |
489 | if self.version == REVLOGV0: |
|
489 | if self.version == REVLOGV0: | |
490 | return (self.rev(d[0]), self.rev(d[1])) |
|
490 | return (self.rev(d[0]), self.rev(d[1])) | |
491 | return d |
|
491 | return d | |
492 | def start(self, rev): |
|
492 | def start(self, rev): | |
493 | if rev < 0: |
|
493 | if rev < 0: | |
494 |
return |
|
494 | return nullrev | |
495 | if self.version != REVLOGV0: |
|
495 | if self.version != REVLOGV0: | |
496 | return self.ngoffset(self.index[rev][0]) |
|
496 | return self.ngoffset(self.index[rev][0]) | |
497 | return self.index[rev][0] |
|
497 | return self.index[rev][0] | |
@@ -581,8 +581,8 b' class revlog(object):' | |||||
581 | lowestrev = min([self.rev(n) for n in roots]) |
|
581 | lowestrev = min([self.rev(n) for n in roots]) | |
582 | else: |
|
582 | else: | |
583 | roots = [nullid] # Everybody's a descendent of nullid |
|
583 | roots = [nullid] # Everybody's a descendent of nullid | |
584 |
lowestrev = |
|
584 | lowestrev = nullrev | |
585 |
if (lowestrev == |
|
585 | if (lowestrev == nullrev) and (heads is None): | |
586 | # We want _all_ the nodes! |
|
586 | # We want _all_ the nodes! | |
587 | return ([self.node(r) for r in xrange(0, self.count())], |
|
587 | return ([self.node(r) for r in xrange(0, self.count())], | |
588 | [nullid], list(self.heads())) |
|
588 | [nullid], list(self.heads())) | |
@@ -634,7 +634,7 b' class revlog(object):' | |||||
634 | # roots that are not ancestors. |
|
634 | # roots that are not ancestors. | |
635 |
|
635 | |||
636 | # If one of the roots was nullid, everything is included anyway. |
|
636 | # If one of the roots was nullid, everything is included anyway. | |
637 |
if lowestrev > |
|
637 | if lowestrev > nullrev: | |
638 | # But, since we weren't, let's recompute the lowest rev to not |
|
638 | # But, since we weren't, let's recompute the lowest rev to not | |
639 | # include roots that aren't ancestors. |
|
639 | # include roots that aren't ancestors. | |
640 |
|
640 | |||
@@ -649,7 +649,7 b' class revlog(object):' | |||||
649 | else: |
|
649 | else: | |
650 | # We are descending from nullid, and don't need to care about |
|
650 | # We are descending from nullid, and don't need to care about | |
651 | # any other roots. |
|
651 | # any other roots. | |
652 |
lowestrev = |
|
652 | lowestrev = nullrev | |
653 | roots = [nullid] |
|
653 | roots = [nullid] | |
654 | # Transform our roots list into a 'set' (i.e. a dictionary where the |
|
654 | # Transform our roots list into a 'set' (i.e. a dictionary where the | |
655 | # values don't matter. |
|
655 | # values don't matter. | |
@@ -665,7 +665,7 b' class revlog(object):' | |||||
665 | for r in xrange(max(lowestrev, 0), highestrev + 1): |
|
665 | for r in xrange(max(lowestrev, 0), highestrev + 1): | |
666 | n = self.node(r) |
|
666 | n = self.node(r) | |
667 | isdescendent = False |
|
667 | isdescendent = False | |
668 |
if lowestrev == |
|
668 | if lowestrev == nullrev: # Everybody is a descendent of nullid | |
669 | isdescendent = True |
|
669 | isdescendent = True | |
670 | elif n in descendents: |
|
670 | elif n in descendents: | |
671 | # n is already a descendent |
|
671 | # n is already a descendent | |
@@ -1056,7 +1056,7 b' class revlog(object):' | |||||
1056 | """calculate the least common ancestor of nodes a and b""" |
|
1056 | """calculate the least common ancestor of nodes a and b""" | |
1057 |
|
1057 | |||
1058 | def parents(rev): |
|
1058 | def parents(rev): | |
1059 |
return [p for p in self.parentrevs(rev) if p != |
|
1059 | return [p for p in self.parentrevs(rev) if p != nullrev] | |
1060 |
|
1060 | |||
1061 | c = ancestor.ancestor(self.rev(a), self.rev(b), parents) |
|
1061 | c = ancestor.ancestor(self.rev(a), self.rev(b), parents) | |
1062 | if c is None: |
|
1062 | if c is None: | |
@@ -1113,7 +1113,7 b' class revlog(object):' | |||||
1113 | t = r - 1 |
|
1113 | t = r - 1 | |
1114 | node = None |
|
1114 | node = None | |
1115 |
|
1115 | |||
1116 |
base = prev = |
|
1116 | base = prev = nullrev | |
1117 | start = end = textlen = 0 |
|
1117 | start = end = textlen = 0 | |
1118 | if r: |
|
1118 | if r: | |
1119 | end = self.end(t) |
|
1119 | end = self.end(t) |
General Comments 0
You need to be logged in to leave comments.
Login now