Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: msdos batch file to build projects using subversion svn tool  (Read 10415 times)

0 Members and 1 Guest are viewing this topic.

helpcindy

    Topic Starter


    Rookie

    hi!
    im a begginner in writting batch files.I would really gratefull if someone could guide me as to how to go about creating a batch file that could be used to merge files present in different directories using the svn subversion tool.
    thanks!

    gpl



      Apprentice
    • Thanked: 27
      Re: msdos batch file to build projects using subversion svn tool
      « Reply #1 on: July 22, 2009, 12:38:24 AM »
      Hi
      The first step is to define clearly what you want to achieve.
      How do you define which versions are to overwrite the master and in which order ?
      Which different directories do you mean ? Are your updates in a tree ? are the directories named in a special way ?

      With all this information, Im sure we could come up with a pretty good tool
      Graham


      helpcindy

        Topic Starter


        Rookie

        Re: msdos batch file to build projects using subversion svn tool
        « Reply #2 on: July 22, 2009, 12:48:49 AM »
        hi !
        thank u so much for the reply!
        il try my best to explain to you what exactly im trying to achieve.
        iv basically got two folders.one belonging to me and the other to the server.so i have to check if there are any new additions to the folder in the server using the subversion tool and update my folder with the new files and folders.so my goal is basically to build a project using an automated script.

        gpl



          Apprentice
        • Thanked: 27
          Re: msdos batch file to build projects using subversion svn tool
          « Reply #3 on: July 22, 2009, 02:04:23 AM »
          Here is a link to the command line operation of subversion http://www.sunsource.net/scdocs/ddUsingSVN_command-line this would be the first thing that you need to understand how to do.

          Do you know how you will cope with changes to files that you have changed ?

          helpcindy

            Topic Starter


            Rookie

            Re: msdos batch file to build projects using subversion svn tool
            « Reply #4 on: July 22, 2009, 03:18:03 AM »
            thank you for the link.
            it seems to have everything that i will need.i am still learning how to write batch files so im guessing it will take some time for me to understand how exactly to go about writing the script.

            in response to your question:by changes what changes are u refering to? i will have to consider the changes made by everyone else and incorporate it into my folder right..

            helpcindy

              Topic Starter


              Rookie

              Re: msdos batch file to build projects using subversion svn tool
              « Reply #5 on: July 22, 2009, 03:19:26 AM »
              oh so in case i make changes in a file i will have to update it in the server right?...is that what u mean?

              gpl



                Apprentice
              • Thanked: 27
                Re: msdos batch file to build projects using subversion svn tool
                « Reply #6 on: July 22, 2009, 03:21:26 AM »
                Im thinking of a situation where you and someone else have made a change to the same file(s), this is quite tricky to manage

                helpcindy

                  Topic Starter


                  Rookie

                  Re: msdos batch file to build projects using subversion svn tool
                  « Reply #7 on: July 22, 2009, 03:27:46 AM »
                  ah..!
                  im guessing that in case of a situation like that a conflict will arise.There are a few options by which you can solve such conflicts.It will have to be done interactively wherein you select whether you consider "mine-full",or "theirs-full",or merge them.This is what the guide said about conflicts.

                  helpcindy

                    Topic Starter


                    Rookie

                    Re: msdos batch file to build projects using subversion svn tool
                    « Reply #8 on: July 22, 2009, 03:30:28 AM »
                    would you by any chance know where i could find a model batch script around which i could work,so that it could help me frame my required script.?

                    gpl



                      Apprentice
                    • Thanked: 27
                      Re: msdos batch file to build projects using subversion svn tool
                      « Reply #9 on: July 22, 2009, 05:00:49 AM »
                      I dont have any sample code Im afraid, to be honest I use tortoise svn to manage most of the time. I understand that there are other free subversion tools that manage to combine several different versions of files quite well

                      If I have a branch of changes, I usually follow the steps below

                      extract the trunk (master copy) to a directory on the file system
                      extract the branch of changes to a different directory on the file system
                      copy the changed files to the trunk (master) directory
                      commit the changes

                      As long as there are no other changes committed to the trunk (master) for updated files, this should all work well. If there have been changes, and you are trying to copy an older version over an updated one, there will be problems.

                      If someone else has committed a change to a file that you are trying to commit, then you have a bit of a headache !!

                      The logic for your process goes something like this :
                      1 - extract the trunk
                      2 - identify the changes in your development branch and extract those to a different folder
                      3 - MOVE all files in the branch that are newer than the same file in the trunk to the trunk directory
                      4 - any files that are left are the problem ones and will need manual intervention to merge the changes -- I suggest your process stops at this point - re-running will pick up your fixes
                      5 - commit the trunk back to the repository

                      I havent looked at the command-line functionality - can you start to sketch out a script from this (and correcting any errors in my logic above) ?

                      helpcindy

                        Topic Starter


                        Rookie

                        Re: msdos batch file to build projects using subversion svn tool
                        « Reply #10 on: July 27, 2009, 04:18:17 AM »
                        yes i think i will be able to frame a code using the steps you have provided.
                        thank you so much for your help.! i will let you know if im successful !
                         :)

                        helpcindy

                          Topic Starter


                          Rookie

                          Re: msdos batch file to build projects using subversion svn tool
                          « Reply #11 on: July 27, 2009, 04:34:46 AM »
                          another query:
                          during the development of the file,i will need a sample repository to carry out my tests and check various functions.how do i go about it?

                          helpcindy

                            Topic Starter


                            Rookie

                            Re: msdos batch file to build projects using subversion svn tool
                            « Reply #12 on: July 27, 2009, 04:52:58 AM »
                            so according to your logic i extract the trunk,which would basically mean downloading my working copy by selecting svn checkout right? then i svn update it to get the changes made by different people on my team.When i update it,i replace the older files with its newer versions in the working copy right?
                            i didn quite follow what you meant by saying i must move all the files into a seperate folder and the ones left after replacing are problem ones.
                            i apologize for the never ending doubts!
                             ;)

                            gpl



                              Apprentice
                            • Thanked: 27
                              Re: msdos batch file to build projects using subversion svn tool
                              « Reply #13 on: July 27, 2009, 07:35:00 AM »
                              I envisage the setup to be as follows

                              There is a master copy of all of the files, the trunk. Then you have your branch, where you do your work, this is isolated from the trunk.

                              When you extract the trunk to a directory, it has all the new changes from other developers (Im assuming you are working in a multi developer environment).

                              You need to identify all of the files in your working copy of the branch that you have changed, ones that havent changed can be ignored.

                              The logic in my earlier post was slightly wrong, you may have changed a file that was changed in the trunk earlier by someone else, so simply overwriting it would lose those changes.

                              So, you need to check out your working copy, merge it in with the trunk (I use the file system to do this instead of repository itself, then commit the changes in the trunk back to the repository).

                              The merge process is the problem, where you are the only person making changes, this is simple. Im not sure how you manage the conflicted updates, as I said before there are subversion clients that handle this better than tortoise. Here, if the changes are to different parts of the code, it is fairly simple to merge together but when the change has been made to the same lines, I can see no simple way to merge them without doing it by hand.

                              Depending on what powers you have, you should be able to create a test repository where you can check out the different scenarios.

                              helpcindy

                                Topic Starter


                                Rookie

                                Re: msdos batch file to build projects using subversion svn tool
                                « Reply #14 on: July 27, 2009, 11:22:14 PM »
                                i actually sat down with my advisor and found out what exactly i am expected to do,i discussed the merging problem.Since i am new to this and i am just taking it up as a small project he suggested for now that i overwrite the files that have been changed.He asked me to carry out the following steps:
                                         1.Manually checkout the working copy and the particular server folder
                                       using a batch file:
                                        2.Update working copy
                                        3.Update server folder
                                        4.Copy and overwrite any files that are different in server folder and working copy by copying them from server copy and replacing them in working copy
                                        5.Start the build
                                        6.Determine whether there is an error or not and display it on the screen

                                helpcindy

                                  Topic Starter


                                  Rookie

                                  Re: msdos batch file to build projects using subversion svn tool
                                  « Reply #15 on: July 28, 2009, 12:31:53 AM »
                                  this is a sample that i have come up with..!

                                  [attachment deleted by admin]

                                  helpcindy

                                    Topic Starter


                                    Rookie

                                    Re: msdos batch file to build projects using subversion svn tool
                                    « Reply #16 on: July 28, 2009, 05:42:37 PM »
                                    another doubt:
                                    how do you transcend through different subfolders and compare them to see whats different between the two,and to overwrite it if any difference appears?

                                    helpcindy

                                      Topic Starter


                                      Rookie

                                      Re: msdos batch file to build projects using subversion svn tool
                                      « Reply #17 on: July 28, 2009, 05:53:02 PM »
                                      it says this but i don understand how its supposed to be checked out,its says its a file so i cant check it out


                                      ...



                                      SVN command line executable is not available in C:\SVN\bin. To get it,
                                      checkout and unzip as C:\SVN the following file

                                      http://mo.syst.internal/svn/main/Tools/SVN/svn-win32.zip

                                      You may have to manually upgrade this zip if it is not up-to-date
                                      with your checkout tool, eg: recent Tortoise SVN

                                      Add C:\SVN\bin to your system PATH environment variable if you want
                                      to use SVN command line outside of ECHO project environment.




                                      gpl



                                        Apprentice
                                      • Thanked: 27
                                        Re: msdos batch file to build projects using subversion svn tool
                                        « Reply #18 on: July 28, 2009, 07:42:48 PM »
                                        another doubt:
                                        how do you transcend through different subfolders and compare them to see whats different between the two,and to overwrite it if any difference appears?
                                        Hi
                                        I dont know! I would expect the subversion tool to be able to identify changed files; in tortoise, you can compare 2 branches (or branch and trunk) - is this possible in the command-line version ?

                                        With respect to you next post, Im not sure what this means; in your batch, try adding the line

                                        Path %Path%;C:\SVN\bin

                                        near the top to make the tool available anywhere while in your session

                                        You dont need to check out this file, locate it using Tortoise and copy (or is it export ?) it to the file system, then unzip it to c:\svn\bin

                                        Your batch file looks like a great start, where you have expressions like [PATH_ServerCopy], do you mean that this is a literal folder, or is it supposed to be a variable ? if a variable, it should be enclosed by % symbols, thus
                                        %PATH_ServerCopy%

                                        Graham

                                        helpcindy

                                          Topic Starter


                                          Rookie

                                          Re: msdos batch file to build projects using subversion svn tool
                                          « Reply #19 on: July 28, 2009, 08:09:01 PM »
                                          Thank u so much for your continuous help and response! I Deeply appreciate it!

                                          with respect to the subfolders comparison,i still havent figured out how to go about it,as you might have seen i have just included a xcopy command for the directory names without specifying any subfolders

                                          with respect to the svn command line executable error that popped up,i cleard it.I did not have svn bin installed on my system so i downloaded that from my server.

                                          by [PATH_ServerCopy], i give the path of the respective folder.

                                          i do have a doubt though,im not exactly sure about the build command.Is it alright to just type build.When i use command line i just need to enter build,but im not too sure if i can just include it by itself in the batch file.

                                          Thank you once again!

                                          helpcindy

                                            Topic Starter


                                            Rookie

                                            Re: msdos batch file to build projects using subversion svn tool
                                            « Reply #20 on: July 28, 2009, 08:56:33 PM »
                                            According to an online guide:

                                            Viewing the differences between files: svn diff

                                            You can use svn diff to display local modifications in a specified file in your working copy against the one in the repository. In the command prompt, type:

                                            svn diff (PATH of the file) (URL of the project's repository)
                                            For example, to compare a locally modified file "index.html" against the one in the project's repository, type:

                                            svn diff $SRC/...../index.html https://(projectname).(domain)/svn/(projectname)/trunk (projectname) --username [type-user-name-here]
                                            Alternatively, you can go to the directory where the file belongs and type:

                                            svn diff (FILENAME)

                                            but im not sure if this is what i require.i just need the control to transcend through the same folders and if a folder is missing in the working copy to copy it there from the server copy.

                                            gpl



                                              Apprentice
                                            • Thanked: 27
                                              Re: msdos batch file to build projects using subversion svn tool
                                              « Reply #21 on: July 29, 2009, 06:21:37 AM »
                                              I dont know about your build command, I suspect it is a procedure on your system to call all the commands to build your system ... if its a batch file, you will need to do
                                              call build
                                              to ensure that your batch file gets returned to afterwards (if you just did build, it would go away and do the build but never come back)

                                              Xcopy has useful parameters, do xcopy /? to see them

                                              or search this site for 'only copy newer files' - or similar - for an example of how to update a directory tree, sorry I didnt think about that earlier (it was 07:30 in the morning here, my brain doesnt work so well at that time)

                                              helpcindy

                                                Topic Starter


                                                Rookie

                                                Re: msdos batch file to build projects using subversion svn tool
                                                « Reply #22 on: July 29, 2009, 10:43:39 PM »
                                                OH MY GOD!
                                                i think its working! yay!!!!

                                                thank you so much!

                                                i used the call function as you asked me to and i was successful! :)
                                                so now my batch file is running,just got to tweak it.Got to figure out the comparing of folders(i will look into the parameters of xcopy),and a few pieces here and there.
                                                One thing,whenever i try to update a particular folder it always asks me to cleanup before it can update.I have not placed any locks as such on any of the folders.Any way to go around it?

                                                helpcindy

                                                  Topic Starter


                                                  Rookie

                                                  Re: msdos batch file to build projects using subversion svn tool
                                                  « Reply #23 on: July 29, 2009, 10:45:13 PM »
                                                  and i apologize for making you think so early in the morning!
                                                   ;D

                                                  helpcindy

                                                    Topic Starter


                                                    Rookie

                                                    Re: msdos batch file to build projects using subversion svn tool
                                                    « Reply #24 on: July 29, 2009, 11:22:38 PM »
                                                    I found this command

                                                    REPLACE %1\*.* %2 /A
                                                    REPLACE %1\*.* %2 /U

                                                    where /A : add files from source that do not exist at the destination
                                                              /U : overwrites file in destination directory with those from source directory only if source files are newer

                                                    helpcindy

                                                      Topic Starter


                                                      Rookie

                                                      Re: msdos batch file to build projects using subversion svn tool
                                                      « Reply #25 on: July 29, 2009, 11:52:20 PM »
                                                      Im assuming REPLACE command can only be used for files.Im not sure if it can move through the directories.

                                                      I found this other line online,but i dont quite understand it


                                                      svn status | grep '^?' | awk '{ print $2; }' | xargs svn add

                                                      it apparently syncs the repository and the working copy.But im not sure where i am supposed to mention the paths etc.

                                                      helpcindy

                                                        Topic Starter


                                                        Rookie

                                                        Re: msdos batch file to build projects using subversion svn tool
                                                        « Reply #26 on: July 30, 2009, 12:45:52 AM »
                                                        i tried using the svn merge tool,but the following statement is displayed
                                                        svn: A working copy merge source needs an explicit revision

                                                        helpcindy

                                                          Topic Starter


                                                          Rookie

                                                          Re: msdos batch file to build projects using subversion svn tool
                                                          « Reply #27 on: July 30, 2009, 03:04:03 AM »
                                                          I found this worked:

                                                          XCOPY %1 %2  /e /c /i /h /k

                                                          it copied files and subdirectories.