Patch: Enable support for paths with spaces in Mercurial (hg) diff parser
Submitted
Updated 3 months, 1 week ago
| Derek Slager | Reviewers | ||
| reviewboard | |||
| 541 | |||
| None | Review Board SVN | ||
Enables the Mercurial diff parser to handle file paths with spaces. I don't know Python, and was therefore "coding by Google", so please expect to find some issues. Update: diff #2 comes with proposed changes generously applied by bboissin (via http://code.google.com/p/reviewboard/issues/detail?id=541)
Tested locally on Debian with various changesets that do and do not include paths with spaces.
Posted 3 months, 4 weeks ago (July 23rd, 2008, 5:32 p.m.)
-
trunk/reviewboard/scmtools/hg.py (Diff revision 1) 48 info['newFile'] = info['origFile'] = diffLine[-1]
48 isCommitted = len(diffLine) > 4 and diffLine[3] == '-r'
-
Are we guaranteed that diffLine[3] will be "-r" when it's uncommitted?
-
trunk/reviewboard/scmtools/hg.py (Diff revision 1) 49 nameStartIndex = 5 if isCommitted else 3
-
We usually prefer these to be more verbose. What you could so is: isCommitted = ... if isCommitted: nameStartIndex = 5 info[...] else: nameStartIndex = 3 info[...]
-
trunk/reviewboard/scmtools/hg.py (Diff revision 1) 93 f = opener.open('%s/raw-file/%s/%s' % (self.url, rev, path))
96 f = opener.open('%s/raw-file/%s/%s' % (self.url, rev, path.replace(' ', '%20')))
-
You should probably use urllib.quote() for escaping contents.
Committed as r1442. Thanks!!