Review Board

beta

Add CVS support to post-review

Updated 8 months ago

Christian Hammond Reviewers
trunk reviewboard
None Review Board SVN
This change adds CVS support to post-review. It's fairly basic but does all we need for now.
Posted a change against a CVS server to the GSoC server successfully.

Diff revision 1 (Latest)

  1. /trunk/reviewboard/contrib/tools/post-review: 3 changes [ 1 2 3 ]
/trunk/reviewboard/contrib/tools/post-review
Revision 1332 New Change
460
                return trees[repository_info.path]['REVIEWBOARD_URL']
460
                return trees[repository_info.path]['REVIEWBOARD_URL']
461
461
462
        return None
462
        return None
463
463
464
464
465
class CVSClient(SCMClient):
466
    """
467
    A wrapper around the cvs tool that fetches repository
468
    information and generates compatible diffs.
469
    """
470
    def get_repository_info(self):
471
        if not check_install("cvs"):
472
            return None
473
474
        cvsroot_path = os.path.join("CVS", "Root")
475
476
        if not os.path.exists(cvsroot_path):
477
            return None
478
479
        fp = open(cvsroot_path, "r")
480
        repository_path = fp.read().strip()
481
        fp.close()
482
483
        i = repository_path.find("@")
484
        if i != -1:
485
            repository_path = repository_path[i + 1:]
486
487
        return RepositoryInfo(path=repository_path)
488
489
    def diff(self, files):
490
        """
491
        Performs a diff across all modified files in a CVS repository.
492
        """
493
        return self.do_diff(' '.join(files))
494
495
    def diff_between_revisions(self, revision_range):
496
        """
497
        Performs a diff between 2 revisions of a CVS repository.
498
        """
499
        rev_str = ''
500
501
        for rev in revision_range.split(":"):
502
            rev_str += "-r %s" % rev
503
504
        return self.do_diff(rev_str)
505
506
    def do_diff(self, params):
507
        # Diff returns "1" if differences were found.
508
        return execute('cvs -q diff -u %s' % params,
509
                       extra_ignore_errors=(1,))
510
511
465
class SVNClient(SCMClient):
512
class SVNClient(SCMClient):
466
    """
513
    """
467
    A wrapper around the svn Subversion tool that fetches repository
514
    A wrapper around the svn Subversion tool that fetches repository
468
    information and generates compatible diffs.
515
    information and generates compatible diffs.
469
    """
516
    """
1358
1405
1359
    # Try to find the SCM Client we're going to be working with
1406
    # Try to find the SCM Client we're going to be working with
1360
    repository_info = None
1407
    repository_info = None
1361
    tool = None
1408
    tool = None
1362
1409
1363
    for tool in (SVNClient(), MercurialClient(), GitClient(), PerforceClient()):
1410
    for tool in (SVNClient(), CVSClient(), MercurialClient(),
1411
                 GitClient(), PerforceClient()):
1364
        repository_info = tool.get_repository_info()
1412
        repository_info = tool.get_repository_info()
1365
1413
1366
        if repository_info:
1414
        if repository_info:
1367
            break
1415
            break
1368
1416
  1. /trunk/reviewboard/contrib/tools/post-review: 3 changes [ 1 2 3 ]