Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:15:53+00:00 2026-05-23T23:15:53+00:00

Is there any CVS command that can give me previous revision of a file,

  • 0

Is there any CVS command that can give me previous revision of a file, given the filename and its revision?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:15:53+00:00Added an answer on May 23, 2026 at 11:15 pm

    There is no direct way to do this from CVS commands. But since I am using the output (of CVS log) IN java, following code snippet worked for me

    if (currentRevision == null || currentRevision.trim().length() == 0) {
        return null;
    }
    
    String[] revComponents = currentRevision.trim().split("\\.");
    
    if (revComponents == null || revComponents.length == 0) {
        log.warn("Failed to parse revision number: " + currentRevision
                + " for identification of previous revision");
        return null;
    }
    
    if (revComponents.length % 2 == 1) {
        log.warn("Odd number of components in revision: " + currentRevision);
        log.warn("Possibly a tag revision.");
        return null;
    }
    
    int lastComp;
    try {
        lastComp = Integer.parseInt(revComponents[revComponents.length - 1]);
    } catch (NumberFormatException nmfe) {
        log.warn("Failed to parse the last component of revision from " + currentRevision);
        log.warn("Identified presence of alphanumric values in the last component. Cannot predict previous revision for this");
        return null;
    }
    
    if (revComponents.length == 2 && lastComp == 1) {
        log.debug("Revision: " + currentRevision + " is the first revision for the current file. Cannot go further back");
        return null;
    }
    
    StringBuilder result = new StringBuilder();
    if (lastComp == 1) {
        for (int i = 0; i < revComponents.length - 2; i++) {
            if (result.length() > 0)
                result.append('.');
            result.append(revComponents[i]);
        }
    } else if (lastComp > 1) {
        for (int i = 0; i < revComponents.length - 1; i++) {
            result.append(revComponents[i]);
            result.append('.');
        }
        result.append((lastComp - 1));
    } else {
        log.warn("Found invalid value for last revision number component in " + currentRevision);
            return null;
        }
    
        return result.toString();
    }
    

    Above code also handles branch revisions, for example, if the current revision (in picture) is the first one on branch that it will return the revision from which branch for that file was created.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that Subversion has basically been written to replace CVS, are there any compelling
Is there any way I can set a formatter on models that will convert
We have a cvs archive, and I can get any version of any file
Are there any tools available that will index a CVS repository? Basically what I
Is there any way we can fetch X509 Public Cetrificates using c# from AD
At work, we are using SVN, CVS, and GIT because there any many projects
Are there any decent plugin's for Eclipse that allow integration with StarTeam? I miss
Is there any simple way to show only the files in my repository that
I want to know that is there any nice tool which you would like
BRIEF: How do you ensure that there is no unsaved work in any DVCS's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.