Ticket #256: libscm_fix_1_of_1_rev_6839f138ff17_Issue_256__fix_parsing_branch_name_from_changelog.patch

File libscm_fix_1_of_1_rev_6839f138ff17_Issue_256__fix_parsing_branch_name_from_changelog.patch, 2.9 KB (added by jan vrany, 5 years ago)
  • mercurial/HGCommandParser.st

    # HG changeset patch
    # User Jan Vrany <jan.vrany@fit.cvut.cz>
    # Date 1546940111 0
    #      Tue Jan 08 09:35:11 2019 +0000
    # Node ID 6839f138ff173a601b4d7c79d9e88ca2ce9f4f0b
    # Parent  f376c52fbc5b617c035db4e84854b1895fdb0183
    Issue 256: fix parsing branch name from changelog
    
    To retrieve a branch of an changeset, `stx:libscm` uses `{branch}`
    branch keyword and then parses it as "name list". However, according
    to documentation it is a single string:
    
      branch        String. The name of the branch on which the changeset was
                      committed.
    
    This obviously caused problems when branch name had spaces in it.
    This commit fixes the problem.
    
    One remaining thing is that `stx:libscm` technically allows a changeset
    to be in more than one branch which seems to be impossible in
    Mercurial itself. This should be investigated and fixed, eventually.
    
    diff -r f376c52fbc5b -r 6839f138ff17 mercurial/HGCommandParser.st
    a b  
    392392
    393393    rev := HGChangeset new.
    394394    rev setId: self parseNodeId. self expectLineEnd.
    395     branches := self parseNameList. self expectLineEnd.
     395    branches := Array with: stream nextLine.
    396396    rev setBranches: branches.
    397397    rev setParent1Id: self parseNodeId. self expectSpace.
    398398    rev setParent2Id: self parseNodeId. self expectSpace. self expectLineEnd.
     
    430430    ^rev
    431431
    432432    "Created: / 13-11-2012 / 09:45:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    433     "Modified: / 19-03-2014 / 23:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     433    "Modified: / 07-01-2019 / 22:51:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    434434!
    435435
    436436parseMergeLocalChanged: info
  • mercurial/HGTests.st

    diff -r f376c52fbc5b -r 6839f138ff17 mercurial/HGTests.st
    a b  
    453453    self assert: branches anElement name = 'default'
    454454
    455455    "Created: / 14-01-2013 / 14:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     456!
     457
     458test_branches_issue256a
     459    "
     460    Change branch with spaces & commit. Check whether commited changeset
     461    has the branch set.
     462    "
     463
     464    | repo wc |
     465
     466    repo := self repositoryNamed:'test_repo_01'.
     467    wc := repo workingCopy.
     468    self assert: repo branches size == 1.
     469    wc branch: 'test branches issue256a'.
     470
     471    "Modify some file"
     472    (wc / 'f1.txt') writingFileDo:[:s | s nextPutAll:'modified...' ].
     473    wc commit: testSelector , ' - commit 01'.
     474
     475    self assert: wc changeset branches size == 1.
     476    self assert: wc changeset branches anElement name = 'test branches issue256a'.
     477    self assert: repo branches size == 2.
     478    self assert:(repo branches contains: [:b|b name = 'default']).
     479    self assert:(repo branches contains: [:b|b name = 'test branches issue256a']).
     480
     481    "Created: / 07-01-2019 / 22:42:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    456482! !
    457483
    458484!HGTests methodsFor:'tests - changesets'!