2009-03-26 9 views

उत्तर

36

एक भंडार से मुख्य संशोधन पुनर्प्राप्त करने का सबसे महंगा तरीका जानकारी कमांड है।

using(SvnClient client = new SvnClient()) 
{ 
    SvnInfoEventArgs info; 
    Uri repos = new Uri("http://my.server/svn/repos"); 

    client.GetInfo(repos, out info); 

    Console.WriteLine(string.Format("The last revision of {0} is {1}", repos, info.Revision)); 
} 
+0

इस कोड के रूप में मेरे लिए काम नहीं कर रहा है से नीचे (SvnClient क्लाइंट = नया SvnClient()) {SvnInfoEventArgs जानकारी; उरी रिपोस = नया उरी ("svn: // india01/भंडार/शाखाएं/mybranch1"); क्लाइंट। गेटइन्फो (रिपोज़, आउट जानकारी); lblMsg.Visible = सत्य; lblMsg.Text = (string.Format ("{0} का अंतिम संशोधन {1}" है, repos, info.Revision)); } ' जब भी मैं अपना वेबपेज चला रहा हूं तो यह केवल खोज पर रहता है .. इसके लिए कोई समाधान। – picnic4u

+2

यदि आप किसी दिए गए पथ (संपूर्ण रेपो नहीं) के लिए नवीनतम संशोधन चाहते हैं तो आप इसके बजाय 'info.LastChangeRevision' वापस कर सकते हैं। – styfle

9

ठीक है, मैं इसे अपने आप से लगा:

SvnInfoEventArgs statuses; 
client.GetInfo("svn://repo.address", out statuses); 
int LastRevision = statuses.LastChangeRevision; 
1

मैं भी एक बहुत googled लेकिन केवल एक बात जो मुझे वास्तव में पिछले संशोधन प्राप्त करने के लिए काम कर रहा था था:

public static long GetRevision(String target) 
    { 
     SvnClient client = new SvnClient(); 

     //SvnInfoEventArgs info; 
     //client.GetInfo(SvnTarget.FromString(target), out info); //Specify the repository root as Uri 
     //return info.Revision 
     //return info.LastChangeRevision 

     Collection<SvnLogEventArgs> info = new Collection<SvnLogEventArgs>(); 
     client.GetLog(target, out info); 
     return info[0].Revision; 
    } 

अन्य समाधान पर टिप्पणी कर रहे हैं। अपने आप से प्रयास करें और अंतर देखें। । ।

+0

यह आदेश एक संशोधन संख्या प्राप्त करने के लिए सभी संशोधनों को पुनर्प्राप्त करता है ... यह थोड़ी अधिक मात्रा में है और निश्चित रूप से जानकारी प्राप्त करने का सबसे तेज़ तरीका नहीं है। –

15

मैं SvnWorkingCopyClient का उपयोग कर काम कर प्रतिलिपि के नवीनतम संस्करण को जाँच कर रहा हूँ:

var workingCopyClient = new SvnWorkingCopyClient(); 

SvnWorkingCopyVersion version; 

workingCopyClient.GetVersion(workingFolder, out version); 

स्थानीय काम कर रहे भंडार के नवीनतम संस्करण को तो उपलब्ध है के माध्यम से

long localRev = version.End; 

एक दूरस्थ भंडार के लिए,

का उपयोग
var client = new SvnClient(); 

SvnInfoEventArgs info; 

client.GetInfo(targetUri, out info); 

long remoteRev = info.Revision; 

इसके बजाए।

यह कमांड लाइन से svnversion टूल का उपयोग करने के समान है। उम्मीद है की यह मदद करेगा।

0

यह एक बहुत पुराना सवाल है, और शीर्ष दो उत्तरों में इसका उत्तर दिया गया है। फिर भी, उम्मीद है कि यह किसी के लिए कुछ मदद की जा सकती है, मैं निम्नलिखित सी # विधि पोस्ट कर रहा हूं यह बताता हूं कि न केवल भंडार और कार्यशील प्रति दोनों से संशोधन संख्या कैसे प्राप्त करें, बल्कि सामान्य परिस्थितियों के परीक्षण के लिए कैसे करें समस्याओं के रूप में माना जाना चाहिए, उदाहरण के लिए एक स्वचालित निर्माण प्रक्रिया में।

/// <summary> 
    /// Method to get the Subversion revision number for the top folder of the build collection, 
    /// assuming these files were checked-out from Merlinia's Subversion repository. This also 
    /// checks that the working copy is up-to-date. (This does require that a connection to the 
    /// Subversion repository is possible, and that it is running.) 
    /// 
    /// One minor problem is that SharpSvn is available in 32-bit or 64-bit DLLs, so the program 
    /// needs to target one or the other platform, not "Any CPU". 
    /// 
    /// On error an exception is thrown; caller must be prepared to catch it. 
    /// </summary> 
    /// <returns>Subversion repository revision number</returns> 
    private int GetSvnRevisionNumber() 
    { 
    try 
    { 
     // Get the latest revision number from the Subversion repository 
     SvnInfoEventArgs svnInfoEventArgs; 
     using (SvnClient svnClient = new SvnClient()) 
     { 
      svnClient.GetInfo(new Uri("svn://99.99.99.99/Merlinia/Trunk"), out svnInfoEventArgs); 
     } 

     // Get the current revision numbers from the working copy that is the "build collection" 
     SvnWorkingCopyVersion svnWorkingCopyVersion; 
     using (SvnWorkingCopyClient svnWorkingCopyClient = new SvnWorkingCopyClient()) 
     { 
      svnWorkingCopyClient.GetVersion(_collectionFolder, out svnWorkingCopyVersion); 
     } 

     // Check the build collection has not been modified since last commit or update 
     if (svnWorkingCopyVersion.Modified) 
     { 
      throw new MerliniaException(0x3af34e1u, 
        "Build collection has been modified since last repository commit or update."); 
     } 

     // Check the build collection is up-to-date relative to the repository 
     if (svnInfoEventArgs.Revision != svnWorkingCopyVersion.Start) 
     { 
      throw new MerliniaException(0x3af502eu, 
      "Build collection not up-to-date, its revisions = {0}-{1}, repository = {2}.", 
      svnWorkingCopyVersion.Start, svnWorkingCopyVersion.End, svnInfoEventArgs.Revision); 
     } 

     return (int)svnInfoEventArgs.Revision; 
    } 
    catch (Exception e) 
    { 
     _fLog.Error(0x3af242au, e); 
     throw; 
    } 
    } 

(इस कोड बातें कार्यक्रम से कॉपी किया गया था के लिए विशेष के एक जोड़े शामिल नहीं है, लेकिन यह है कि SharpSvn भागों को समझने में मुश्किल नहीं होना चाहिए।)

संबंधित मुद्दे