Commit Graph

3 Commits

Author SHA1 Message Date
Jun Wu
833188e453 fastannotate: move exception classes to error.py
Summary: The newly added error.py will be used in other files.

Test Plan: A related test will be added later

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: ttung, stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3836304

Signature: t1:3836304:1473411906:ca110c8214d2b1a0f9ae29111d75baa54c072c19
2016-09-08 14:47:49 +01:00
Jun Wu
190eb53c0b fastannotate: implements the "contains" operations for the revmap
Summary:
The revmap stores 2 kinds of revisions:
- Real revisions in the main branch that can be annotated directly
- Revisions in a merge changeset's p2 branch. They are not in the linelog
  linear history but may appear in lines introduced by the merge changeset.
  We call those revisions in a "side branch", outside the "main branch".

This diff implements `__contains__` to test if a revision is in the main
branch or not, it will be frequently used in upcoming code like calculating
the annotate information for a side branch, or finding a joint point when
doing a hybrid annotate.

Test Plan: A revmap Python test will be added later and cover this feature

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3827995

Signature: t1:3827995:1473324222:4f0d94a2d21c033ab78b3a5dd31254692d36a852
2016-09-07 15:05:55 +01:00
Jun Wu
f1c3dc9f91 fastannotate: implement a simple revision map
Summary:
To use linelog, we need to be able to translate between hg commit hashes and
linelog revision numbers. This diff implements such a revmap using the most
direct way.

The revmap also contains an extra "flag" for each revision, which will be used
to mark if the revision is in the main branch or not, to handle merge commits.

Test Plan:
`import revmap` from IPython and test its interface manually. Also have a
simple script to get some idea about its perf with 10000 revisions:

```
import contextlib, time, os, random, revmap, sys

@contextlib.contextmanager
def benchmark(msg):
    sys.stderr.write('%s: ' % msg)
    t1 = time.time()
    yield
    t2 = time.time()
    sys.stderr.write('%f seconds\n' % (t2 - t1))

def randomid():
    return ''.join([chr(random.randint(0,255)) for _ in xrange(0, 20)])

rm = revmap.revmap('revmap1')

with benchmark('insert 10000 random revisions'): # ~0.3 seconds
    for i in xrange(0, 10000):
        rm.append(randomid(), flag=1, flush=False)

with benchmark('writing to disk'): # 0.02 seconds
    rm.flush()

os.rename('revmap1', 'revmap2')
with benchmark('loading'): # ~0.015 seconds
    rm = revmap.revmap('revmap2')
```

Reviewers: ttung, #sourcecontrol, ikostia

Reviewed By: ikostia

Subscribers: ikostia, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3709706

Signature: t1:3709706:1471936489:0bbe35ed39a2af3f06e1000c4f9674149ad43995
2016-08-23 16:24:13 +01:00