alex / pyvcs

A pure python abstraction layer of multiple VCS, very lightweight.
BSD 3-Clause "New" or "Revised" License
128 stars 10 forks source link

Mercurial backend file_contents gets file contents from working directory, not tip #3

Closed stucchio closed 15 years ago

stucchio commented 15 years ago

Continuation of Issue 2:

The real problem is that repo.changectx(None) returns a workingctx rather than a changectx. This is a context representing the "working directory", and it behaves oddly in several cases.

However, I think that pyvcs really wants to return the 'tip' (much like the svn 'head') rather than the working directory. This appears to be what the svn backend does, though I don't fully understand that code.

A simple fix to get the tip:

def file_contents(self, path, revision=None):
    """
    Returns the contents of a file as a string at a given revision, or
    HEAD if revision is None.
    """
    if revision is None:
        revision = 'tip'
    chgctx = self.repo.changectx(revision)
    try:
        fctx = chgctx.filectx(path)
    except KeyError:
        raise FileDoesNotExist
alex commented 15 years ago

Closed by 77cdc14d53ba9560169ba65822385be858359456, #4. Fixes a bunch of wonkiness with filebrowsing and mercurial, thanks to Chris Stucchio for his help