Subversion Repositories DevTools

Rev

Rev 1308 | Rev 2615 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1308 Rev 2559
Line 205... Line 205...
205
    #
205
    #
206
    #   Check Module Name
206
    #   Check Module Name
207
    #
207
    #
208
    my @errors;
208
    my @errors;
209
    $self->{getDiffError} = undef;
209
    $self->{getDiffError} = undef;
210
    unless ( $module_name =~ m~/(tags|branches|trunk)(/|$)~ )
210
    unless ( $module_name =~ m~^(.*)/(tags|branches|trunk)(/|$)~ )
211
    {
211
    {
212
        push @errors,
212
        push @errors,
213
            "Module does not contain 'tags', 'trunk' or 'branches'",
213
            "Module does not contain 'tags', 'trunk' or 'branches'",
214
            "Module must specify a development branch or trunk";
214
            "Module must specify a development branch or trunk",
-
 
215
            "ModuleName: $module_name"
-
 
216
            ;
215
    }
217
    }
-
 
218
    my $moduleRoot = $1;
-
 
219
    my $moduleTail = $3;
-
 
220
    
216
 
221
 
217
    if ( $module_name =~ m~^/~ )
222
    if ( $module_name =~ m~^/~ )
218
    {
223
    {
219
        push @errors, "Module must not start with a '/'"
224
        push @errors, "Module must not start with a '/'"
220
    }
225
    }
Line 244... Line 249...
244
    #       4) Error - detected before here (no start or end)
249
    #       4) Error - detected before here (no start or end)
245
    #
250
    #
246
    my $start_url;
251
    my $start_url;
247
    my $end_url;
252
    my $end_url;
248
 
253
 
249
    my $moduleRoot = $module_name;
254
#    my $moduleRoot = $module_name;
250
    $moduleRoot =~ s~/trunk$~~;
255
#    $moduleRoot =~ s~/trunk$~~;
251
    $moduleRoot =~ s~/branches/.*~~;
256
#    $moduleRoot =~ s~/branches/.*~~;
252
    $moduleRoot =~ s~/tags/.*~~;
257
#    $moduleRoot =~ s~/tags/.*~~;
253
 
258
 
-
 
259
    my $diffOld = $module_name;
254
    if ( ! $start_tag )
260
    if ( ! $start_tag )
255
    {
261
    {
256
        #
262
        #
257
        #   Dummy start: Root of the empty repository
263
        #   Dummy start: Root of the empty repository
258
        #
264
        #
Line 271... Line 277...
271
    {
277
    {
272
        #
278
        #
273
        #   Tagged version
279
        #   Tagged version
274
        #
280
        #
275
        $start_url =  join ('/', $moduleRoot, 'tags', $start_tag);
281
        $start_url =  join ('/', $moduleRoot, 'tags', $start_tag);
-
 
282
        $diffOld = $start_url;
276
    }
283
    }
277
 
284
 
-
 
285
    my $diffNew = $module_name;
278
    if ( ! $end_tag )
286
    if ( ! $end_tag )
279
    {
287
    {
280
        #
288
        #
281
        #   Dummy end: Head of the branch
289
        #   Dummy end: Head of the branch
282
        #
290
        #
Line 293... Line 301...
293
    {
301
    {
294
        #
302
        #
295
        #   Tagged version
303
        #   Tagged version
296
        #
304
        #
297
        $end_url =  join ('/', $moduleRoot, 'tags', $end_tag);
305
        $end_url =  join ('/', $moduleRoot, 'tags', $end_tag);
-
 
306
        $diffNew = $end_url;
298
    }
307
    }
299
 
308
 
300
 
309
 
301
 
310
 
302
    # Execute the diff command.
311
    # Execute the diff command.
303
    my $read_stdout_data;
312
    my $read_stdout_data;
304
    my $read_stdout_fh = new FileHandle;
313
    my $read_stdout_fh = new FileHandle;
305
    open($read_stdout_fh, '>', \$read_stdout_data);
314
    open($read_stdout_fh, '>', \$read_stdout_data);
306
 
315
 
307
    #
316
    #
308
    #   Determine the commad to use
317
    #   Determine the command to use
309
    #   If user provides two numbers, then module is a full path
318
    #   If user provides two numbers, then module is a full path
310
    #   Otherwise assume that the user has provided named tags
319
    #   Otherwise assume that the user has provided named tags
311
    #
320
    #
312
    #
321
    #
313
    my @args = ();
322
    my @args = ();
Line 324... Line 333...
324
 
333
 
325
 
334
 
326
    Codestriker::execute_command($read_stdout_fh, $stderr_fh,
335
    Codestriker::execute_command($read_stdout_fh, $stderr_fh,
327
                                 $Codestriker::svn, @args);
336
                                 $Codestriker::svn, @args);
328
 
337
 
-
 
338
 
-
 
339
    #
-
 
340
    #   DPurdie: 29-Nov-12
-
 
341
    #   The diff output does not have the full file name
-
 
342
    #   The following code attempts to fix this (bit it didn't work too well
-
 
343
    #   with a mixture of tags, branches and pegs)
-
 
344
    #
-
 
345
    #   Unified Diff format :
-
 
346
    #       --- /path/to/original
-
 
347
    #       +++ /path/to/new
-
 
348
    #   Svn Extension
-
 
349
    #       Index: path/to/file
-
 
350
    #
-
 
351
    #
-
 
352
 
329
    my $rv = open($read_stdout_fh, '<', \$read_stdout_data);
353
    my $rv = open($read_stdout_fh, '<', \$read_stdout_data);
330
    if ( $rv ) {
354
    if ( $rv ) {
331
        while(<$read_stdout_fh>) {
355
        while(<$read_stdout_fh>) {
332
            my $line = $_;
356
            my $line = $_;
333
        
357
        
334
            # If the user specifies a path (a branch in Subversion), the
358
            ## If the user specifies a path (a branch in Subversion), the
335
            # diff file does not come back with a path rooted from the
359
            ## diff file does not come back with a path rooted from the
336
            # repository base making it impossible to pull the entire file
360
            ## repository base making it impossible to pull the entire file
337
            # back out. This code attempts to change the diff file on the
361
            ## back out. This code attempts to change the diff file on the
338
            # fly to ensure that the full path is present. This is a bug
362
            ## fly to ensure that the full path is present. This is a bug
339
            # against Subversion, so eventually it will be fixed, so this
363
            ## against Subversion, so eventually it will be fixed, so this
340
            # code can't break when the diff command starts returning the
364
            ## code can't break when the diff command starts returning the
341
            # full path.
365
            ## full path.
342
            if ($line =~ /^--- / || $line =~ /^\+\+\+ / ||
366
            #if ($line =~ /^--- / || $line =~ /^\+\+\+ / ||
343
                $line =~ /^Index: /) {
367
            #    $line =~ /^Index: /) {
344
                # Check if the bug has been fixed.
368
            #    # Check if the bug has been fixed.
345
                if ($line =~ /^\+\+\+ $module_name/ == 0 && 
369
            #    if ($line =~ /^\+\+\+ $module_name/ == 0 &&
346
                    $line =~ /^--- $module_name/ == 0 &&
370
            #        $line =~ /^--- $module_name/ == 0 &&
347
                    $line =~ /^Index: $module_name/ == 0) {
371
            #        $line =~ /^Index: $module_name/ == 0) {
348
                        $line =~ s/^--- /--- $directory\// or
372
            #            $line =~ s/^--- /--- $directory\// or
349
                        $line =~ s/^Index: /Index: $directory\// or
373
            #            $line =~ s/^Index: /Index: $directory\// or
350
                        $line =~ s/^\+\+\+ /\+\+\+ $directory\//;
374
            #            $line =~ s/^\+\+\+ /\+\+\+ $directory\//;
351
                }
375
            #    }
352
            }
376
            #}
-
 
377
 
-
 
378
            $line =~ s~^Index: ~Index: $diffNew/~;
-
 
379
            $line =~ s~^--- ~--- $diffOld/~;
-
 
380
            $line =~ s~^\+\+\+ ~\+\+\+ $diffNew/~;
353
 
381
 
354
            print $stdout_fh $line;
382
            print $stdout_fh $line;
355
        }
383
        }
356
    }
384
    }
357
 
-
 
358
    return $Codestriker::OK;
385
    return $Codestriker::OK;
359
}
386
}
360
 
387
 
361
1;
388
1;