본문 바로가기

Major Field

Tortoise SVN을 Command로 활용하기

반응형

여럿이서 공동으로 개발하거나 히스토리를 정리하기 위해 버전관리 시스템을 사용하곤 한다. 윈도우 환경에서는 TortoiseSVN 을 이용하는데 Repository가 하나일 때는 편하고 직관적인 인터페이스가 좋았는데 동시에 여러 일을 하다보니 Repository 관리가 힘들게 되어 배치파일을 만들어 보았다.

TortoiseSVN 을 Command 에서 사용하려면 아래와 같이 입력하면 된다.

 > (TortoiseSVN path)\TortoiseProc.exe /command:update /path:(Repository path) /closeonend:1


/closeonend:1 부분은 옵션으로 command를 실행하고 난 뒤에 Dialog 창을 자동으로 닫아주는 기능을 한다. 뒤에 붙는 숫자에 따라 수행동작이 달라지는데 그 내용은 아래와 같다.

 To close the progress dialog at the end of a command automatically without using the permanent setting you can pass the /closeonend parameter.
  • /closeonend:0 don't close the dialog automatically

  • /closeonend:1 auto close if no errors

  • /closeonend:2 auto close if no errors and conflicts

  • /closeonend:3 auto close if no errors, conflicts and merges

  • /closeonend:4 auto close if no errors, conflicts and merges for local operations



/path:(Repository path) 부분은 현재 command를 적용하려는 Repository의 path를 (Repository path) 부분에 써주면 된다. 예를 들어, C:\project 라는 Repository 를 만들었다면 /path:"C:\project" 라고 입력하면 된다.

/command:update 는 수행할 명령을 입력하는 곳으로 아래와 같은 명령들이 있다.

Table D.1. List of available commands and options

Command Description
:about Shows the about dialog. This is also shown if no command is given.
:log Opens the log dialog. The /path specifies the file or folder for which the log should be shown. Three additional options can be set: /startrev:xxx, /endrev:xxx and /strict
:checkout Opens the checkout dialog. The /path specifies the target directory and the /url specifies the URL to checkout from.
:import Opens the import dialog. The /path specifies the directory with the data to import.
:update Updates the working copy in /path to HEAD. If the option /rev is given then a dialog is shown to ask the user to which revision the update should go. To avoid the dialog specify a revision number /rev:1234. Other options are /nonrecursive and /ignoreexternals.
:commit Opens the commit dialog. The /path specifies the target directory or the list of files to commit. You can also specify the /logmsg switch to pass a predefined log message to the commit dialog. Or, if you don't want to pass the log message on the command line, use /logmsgfile:path, where path points to a file containing the log message. To pre-fill the bug ID box (in case you've set up integration with bug trackers properly), you can use the /bugid:"the bug id here" to do that.
:add Adds the files in /path to version control.
:revert Reverts local modifications of a working copy. The /path tells which items to revert.
:cleanup Cleans up interrupted or aborted operations and unlocks the working copy in /path.
:resolve Marks a conflicted file specified in /path as resolved. If /noquestion is given, then resolving is done without asking the user first if it really should be done.
:repocreate Creates a repository in /path
:switch Opens the switch dialog. The /path specifies the target directory.
:export Exports the working copy in /path to another directory. If the /path points to an unversioned directory, a dialog will ask for an URL to export to the directory in /path.
:merge Opens the merge dialog. The /path specifies the target directory. For merging a revision range, the following options are available: /fromurl:URL, /revrange:string. For merging two repository trees, the following options are available: /fromurl:URL, /tourl:URL, /fromrev:xxx and /torev:xxx. These pre-fill the relevant fields in the merge dialog.
:mergeall Opens the merge all dialog. The /path specifies the target directory.
:copy Brings up the branch/tag dialog. The /path is the working copy to branch/tag from. And the /url is the target URL. You can also specify the /logmsg switch to pass a predefined log message to the branch/tag dialog. Or, if you don't want to pass the log message on the command line, use /logmsgfile:path, where path points to a file containing the log message.
:settings Opens the settings dialog.
:remove Removes the file(s) in /path from version control.
:rename Renames the file in /path. The new name for the file is asked with a dialog. To avoid the question about renaming similar files in one step, pass /noquestion.
:diff Starts the external diff program specified in the TortoiseSVN settings. The /path specifies the first file. If the option /path2 is set, then the diff program is started with those two files. If /path2 is omitted, then the diff is done between the file in /path and its BASE. To explicitly set the revision numbers use /startrev:xxx and /endrev:xxx. If /blame is set and /path2 is not set, then the diff is done by first blaming the files with the given revisions.
:showcompare

Depending on the URLs and revisions to compare, this either shows a unified diff (if the option unified is set), a dialog with a list of files that have changed or if the URLs point to files starts the diff viewer for those two files.

The options url1, url2, revision1 and revision2 must be specified. The options pegrevision, ignoreancestry, blame and unified are optional.

:conflicteditor Starts the conflict editor specified in the TortoiseSVN settings with the correct files for the conflicted file in /path.
:relocate Opens the relocate dialog. The /path specifies the working copy path to relocate.
:help Opens the help file.
:repostatus Opens the check-for-modifications dialog. The /path specifies the working copy directory.
:repobrowser Starts the repository browser dialog, pointing to the URL of the working copy given in /path or /path points directly to an URL. An additional option /rev:xxx can be used to specify the revision which the repository browser should show. If the /rev:xxx is omitted, it defaults to HEAD. If /path points to an URL, the /projectpropertiespath:path/to/wc specifies the path from where to read and use the project properties.
:ignore Adds all targets in /path to the ignore list, i.e. adds the svn:ignore property to those files.
:blame

Opens the blame dialog for the file specified in /path.

If the options /startrev and /endrev are set, then the dialog asking for the blame range is not shown but the revision values of those options are used instead.

If the option /line:nnn is set, TortoiseBlame will open with the specified line number showing.

The options /ignoreeol, /ignorespaces and /ignoreallspaces are also supported.

:cat Saves a file from an URL or working copy path given in /path to the location given in /savepath:path. The revision is given in /revision:xxx. This can be used to get a file with a specific revision.
:createpatch Creates a patch file for the path given in /path.
:revisiongraph Shows the revision graph for the path given in /path.
:lock Locks a file or all files in a directory given in /path. The 'lock' dialog is shown so the user can enter a comment for the lock.
:unlock Unlocks a file or all files in a directory given in /path.
:rebuildiconcache Rebuilds the windows icon cache. Only use this in case the windows icons are corrupted. A side effect of this (which can't be avoided) is that the icons on the desktop get rearranged. To suppress the message box, pass /noquestion.
:properties Shows the properties dialog for the path given in /path.


위의 내용들을 이용하여 여러 Repository 를 한꺼번에 update 시킨다거나, 특정 Repository 를 업데이트 한 후에 make 혹은 merge 과정을 통한 개발환경을 만들 수 있다.
(본인같은 경우에는 Repository 를 업데이트 하여 자동 Build될 수 있도록 배치파일을 만들어 쓰고 있다.)

 Examples (which should be entered on one line):
TortoiseProc.exe /command:commit
                 /path:"c:\svn_wc\file1.txt*c:\svn_wc\file2.txt"
                 /logmsg:"test log message" /closeonend:0

TortoiseProc.exe /command:update /path:"c:\svn_wc\" /closeonend:0

TortoiseProc.exe /command:log /path:"c:\svn_wc\file1.txt"
                 /startrev:50 /endrev:60 /closeonend:0


위의 내용들은 아래의 링크를 참조하였다.
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html#tsvn-automation-basics


반응형