Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

Expanded parse_timezone to accept double-negatives to be consistent with cgit implementation. Fixes #697828.

Changeset a6b19fe4efc1

Parent b575ecd59861

by Jason R. Coombs

Changes to 2 files · Browse files at a6b19fe4efc1 Showing diff from parent b575ecd59861 Diff from another changeset...

 
865
866
867
868
 
869
870
871
 
989
990
991
992
993
 
 
 
 
 
 
 
 
 
 
994
995
996
 
865
866
867
 
868
869
870
871
 
989
990
991
 
 
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
@@ -865,7 +865,7 @@
  def add(self, name, mode, hexsha):   """Add an entry to the tree.   - :param mode: The mode of the entry as an integral type. Not all + :param mode: The mode of the entry as an integral type. Not all   possible modes are supported by git; see check() for details.   :param name: The name of the entry, as a string.   :param hexsha: The hex SHA of the entry as a string. @@ -989,8 +989,16 @@
  and a boolean indicating whether this was a UTC timezone   prefixed with a negative sign (-0000).   """ - offset = int(text) - negative_utc = (offset == 0 and text[0] == '-') + # cgit parses the first character as the sign, and the rest + # as an integer (using strtol), which could also be negative. + # We do the same for compatibility. See #697828. + if not text[0] in '+-': + raise ValueError("Timezone must start with + or - (%(text)s)" % vars()) + sign = text[0] + offset = int(text[1:]) + if sign == '-': + offset = -offset + negative_utc = (offset == 0 and sign == '-')   signum = (offset < 0) and -1 or 1   offset = abs(offset)   hours = int(offset / 100)
 
752
753
754
 
 
 
 
752
753
754
755
756
757
@@ -752,3 +752,6 @@
  def test_parse_timezone_pdt_half(self):   self.assertEquals((((-4 * 60) - 40) * 60, False),   parse_timezone("-0440")) + + def test_parse_timezone_double_negative(self): + self.assertEquals(parse_timezone("+0700"), parse_timezone("--700"))