Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

It appears I was unable to save the scripts I used for converting some Subversion repos to Mercurial ones, more specifically the filemaps.

How can I get diffs between two directories (added/removed directories, files, etc.) with the results provided in a text file?

share|improve this question
1  
DIR /b /s [subversion_directory] > svndir.txt & DIR /b /s [mercurial_directory] > hgdir.txt & [your_diff_tool] svndir.txt hgdir.txt –  zb226 Aug 31 '12 at 2:16
    
How does that print the differences? Lets say there is a difference, everything after that will be wrong (even if it should be marked as same) –  soandos Aug 31 '12 at 2:51
    
@zb226 -- I'm thinking both must be sorted the same –  Daniel R Hicks Aug 31 '12 at 3:41
    
@DanH: You're correct, /o:n for sorting should be added to both dir commands. –  zb226 Aug 31 '12 at 8:33
    
@zb226 - Would you mind converting these comments to an actual answer? I did that with KDiff3 and it partly did the trick (I still had to format it the way it should), so I can accept it. Thanks! –  Isxek Aug 31 '12 at 14:09
add comment

1 Answer

up vote 3 down vote accepted

Using a full-fledged diff tool like diffmerge or kdiff3 (both free) you can easily check the differences by comparing the output files of the following batch file. As it is, you need to provide the two directories as arguments, but you may as well set those directly in the SET dir... lines - e.g. SET dir1=c:\svn and SET dir2=c:\hg. The script removes the path prefix from the filenames which would otherwise differ on all lines.

@ECHO OFF
SetLocal EnableDelayedExpansion
SET dir1=%1
SET dir2=%2
ECHO. 2>dir1.txt
ECHO. 2>dir2.txt
FOR /f "tokens=*" %%F IN ('DIR /s /b /o:n %dir1%') DO ( 
    SET tmp=%%F
    ECHO !tmp:%dir1%\=! >> dir1.txt
)
FOR /f "tokens=*" %%F IN ('DIR /s /b /o:n %dir2%') DO ( 
    SET tmp=%%F
    ECHO !tmp:%dir2%\=! >> dir2.txt
)
EndLocal

Then just diff the two output files dir1.txt and dir2.txt:

kdiff3 dir1.txt dir2.txt
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.