From 81019a790ee74cd3bd6bd6ea076da47ddc871ae8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 6 Mar 2012 20:14:25 -0800 Subject: [PATCH] Improve ArcanistMercurialParser's handling of unusual branch names Summary: See . Mercurial branch names may contain any characters, but we currently reject branch names with spaces. NOTE: Mercurial allows you to name branches things like ` ` (five spaces). We do not parse this correctly. Die in a well fire. Test Plan: - Added some horrible-but-possible test cases for crazy branch names. - Unit tests now pass. Reviewers: btrahan, Makinde, killermonk Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1795 --- .../parser/mercurial/ArcanistMercurialParser.php | 4 ++-- .../ArcanistMercurialParserTestCase.php | 16 +++++++++++++++- .../__tests__/data/branches-with-spaces.txt | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 src/repository/parser/mercurial/__tests__/data/branches-with-spaces.txt diff --git a/src/repository/parser/mercurial/ArcanistMercurialParser.php b/src/repository/parser/mercurial/ArcanistMercurialParser.php index 7820768a..7ce13097 100644 --- a/src/repository/parser/mercurial/ArcanistMercurialParser.php +++ b/src/repository/parser/mercurial/ArcanistMercurialParser.php @@ -1,7 +1,7 @@ assertEqual( + array( + 'm m m m m 2:ffffffffffff (inactive)', + 'xxx yyy zzz', + 'default', + "'", + ), + array_keys($output)); + $this->assertEqual( + array('0b9d8290c4e0', '78963faacfc7', '5db03c5500c6', 'ffffffffffff'), + array_values(ipull($output, 'rev'))); + break; case 'log-basic.txt': $output = ArcanistMercurialParser::parseMercurialLog($data); $this->assertEqual( diff --git a/src/repository/parser/mercurial/__tests__/data/branches-with-spaces.txt b/src/repository/parser/mercurial/__tests__/data/branches-with-spaces.txt new file mode 100644 index 00000000..30c999b5 --- /dev/null +++ b/src/repository/parser/mercurial/__tests__/data/branches-with-spaces.txt @@ -0,0 +1,4 @@ +m m m m m 2:ffffffffffff (inactive) 8:0b9d8290c4e0 +xxx yyy zzz 7:78963faacfc7 (inactive) +default 6:5db03c5500c6 (inactive) +' 9:ffffffffffff (inactive) \ No newline at end of file -- 2.43.0