예제 #1
0
파일: cvs.py 프로젝트: ustuehler/git-cvs
    def blob(self, change, changeset):
        """Return the raw binary content of a file at the specified
        revision.
        """
        filename = change.filename + ',v'
        rcsfile = os.path.join(self.prefix, filename)
        if not os.path.isfile(rcsfile):
            rcsfile = os.path.join(self.prefix,
                os.path.dirname(filename), 'Attic',
                os.path.basename(filename))
        if not os.path.isfile(rcsfile):
            raise RuntimeError, _('no RCS file found for %s') % filename

        # cvs has the odd behavior that it favors revision 1.1 over
        # 1.1.1.1 if it searches for a revision by date and the date
        # is after that of the initial revision even by one second.
        #if change.revision == '1.1.1.1' and \
        #        change.timestamp < changeset.timestamp:
        #    revision = '1.1'
        #else:
        #    revision = change.revision
        revision = change.revision

        rcsfile = RCSFile(rcsfile)
        blob = rcsfile.blob(revision)
        return self.expand_keywords(blob, change, rcsfile, revision)
예제 #2
0
 def testNoRevisionsOnTrunk(self):
     # This RCS file contains no revisions on the "trunk", i.e. the
     # first trunk revision 1.1 is explicitly marked 'dead' but it
     # is still a branchpoint for OpenBSD release branches in which
     # the path exists.
     f = RCSFile(join(dirname(__file__), 'data', 'patch-copyin_c,v'))
     for c in f.changes(): self.assertTrue(False)
예제 #3
0
 def checkout(self, filename, revision):
     # FIXME: RCS should do keyword substitution, not CVS!
     cvs = CVS(join(dirname(__file__), 'data', 'greek'), None)
     cvs.localid = 'OpenBSD'
     f = RCSFile(join(dirname(__file__), 'data', filename))
     c = f.change(revision)
     blob = f.blob(revision)
     return cvs.expand_keywords(blob, c, f, revision)
예제 #4
0
    def testIncompleteRevisionTrail(self):
        """HEAD branch missing 1.3 and earlier ancestors

        The file sbin/isakmpd/Attic/pkcs.c,v in OpenBSD's src repostiory
        only contains revisions back to 1.4, but no earlier revisions.
        """
        f = RCSFile(join(dirname(__file__), 'data', 'pkcs.c,v'))
        for c in f.changes(): pass
        self.assertEqual('1.4', c.revision)
예제 #5
0
    def test_multiple_vendor_imports_and_no_revisions_on_trunk(self):
        """Respect the 'branch' field in the RCS header.

        This file was imported twice into the vendor branch but never
        modified in the HEAD branch.

        The RCS file is from OpenBSD CVS (src/usr.sbin/nsd/LICENSE).
        """
        f = RCSFile(join(dirname(__file__), 'data', 'nsd', 'LICENSE,v'))
        self.assertEqual(['1.1.1.1', '1.1.1.2'], list(f.revisions()))
예제 #6
0
파일: rcsdump.py 프로젝트: agernler/git-cvs
    def run(self):
        rcsfile = RCSFile(self.rcsfile)

        if self.options.checkout:
            return self.checkout(rcsfile, self.options.checkout)

        print 'Head: %s' % rcsfile.head
        print 'Branch: %s' % rcsfile.branch
        print 'Revision trail:',
        for revision in rcsfile.revisions():
            print revision,
        print ''
        for change in rcsfile.changes():
            rcsfile._print_revision(change.revision)
예제 #7
0
    def test_keyword_substitution_edge_cases(self):
        """Test edge cases where RCS keyword expansion might fail.
        """
        blob = self.checkout('dot.commonutils,v', '1.1')
        s = '$Id: dot.commonutils,v 1.1 1995/10/18 08:37:54 deraadt Exp $'
        self.assertEqual(1651, blob.find(s))

        blob = self.checkout('res_query.c,v', '1.1')
        s = '$Id: res_query.c,v 1.1 1993/06/01 09:42:14 vixie Exp vixie "'
        self.assertEqual(3091, blob.find(s))

        blob = self.checkout('setjmp.h,v', '1.2')
        s = '$OpenBSD: setjmp.h,v 1.2 2001/03/29 18:52:19 drahn Exp $'
        self.assertEqual(3, blob.find(s))

        blob = self.checkout('test_cvs_import_01_seed1.txt,v,v', '1.1')
        s = '$Id: seed1.txt,v 1.1 2007/06/05 05:49:41 niallo Exp $'
        self.assertEqual(347, blob.find(s))

        f = RCSFile(join(dirname(__file__), 'data', 'pathnames.h,v'))
        self.assertEqual(list(f.revisions())[-1], '1.1.1.1')