Changeset - 18f6bdd1e3fc
[Not reviewed]
default
0 1 0
Mads Kiilerich - 11 years ago 2014-10-03 00:20:36
madski@unity3d.com
hg: make get_ref_revision('rev', '00000000000000') give the null revision

It gave tip revision and caused weird pull request diffs and lots of grief when
(accidentally) creating a pull request from the null revision.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -443,24 +443,26 @@ class MercurialRepository(BaseRepository
 
            raise ChangesetDoesNotExistError(msg)
 
        except (IndexError, ValueError, RepoLookupError, TypeError):
 
            msg = ("Revision %s does not exist for %s" % (revision, self))
 
            raise ChangesetDoesNotExistError(msg)
 

	
 
        return revision
 

	
 
    def get_ref_revision(self, ref_type, ref_name):
 
        """
 
        Returns revision number for the given reference.
 
        """
 
        ref_name = safe_str(ref_name)
 
        if ref_type == 'rev' and not ref_name.strip('0'):
 
            return self.EMPTY_CHANGESET
 
        # lookup up the exact node id
 
        _revset_predicates = {
 
                'branch': 'branch',
 
                'book': 'bookmark',
 
                'tag': 'tag',
 
                'rev': 'id',
 
            }
 
        # avoid expensive branch(x) iteration over whole repo
 
        rev_spec = "%%s & %s(%%s)" % _revset_predicates[ref_type]
 
        try:
 
            revs = self._repo.revs(rev_spec, ref_name, ref_name)
 
        except LookupError:
0 comments (0 inline, 0 general)