Changeset - 2b5f94fc3b7a
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 13 years ago 2013-04-27 11:45:27
marcin@python-works.com
current revision will show workdir state, not the latest revision
3 files changed with 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/__init__.py
Show inline comments
 
@@ -12,14 +12,15 @@ def get_current_revision(quiet=False):
 
    try:
 
        from rhodecode.lib.vcs import get_repo
 
        from rhodecode.lib.vcs.utils.helpers import get_scm
 
        repopath = os.path.join(os.path.dirname(__file__), '..', '..')
 
        scm = get_scm(repopath)[0]
 
        repo = get_repo(path=repopath, alias=scm)
 
        tip = repo.get_changeset()
 
        return (tip.revision, tip.short_id)
 
        wk_dir = repo.workdir
 
        cur_rev = wk_dir.get_changeset()
 
        return (cur_rev.revision, cur_rev.short_id)
 
    except Exception, err:
 
        if not quiet:
 
            print ("WARNING: Cannot retrieve rhodecode's revision. "
 
                   "disregard this if you don't know what that means. "
 
                   "Original error was: %s" % err)
 
        return None
rhodecode/lib/vcs/backends/git/workdir.py
Show inline comments
 
@@ -17,14 +17,14 @@ class GitWorkdir(BaseWorkdir):
 
                raise RepositoryError("Couldn't compute workdir's branch")
 
        except IOError:
 
            # Try naive way...
 
            raise RepositoryError("Couldn't compute workdir's branch")
 

	
 
    def get_changeset(self):
 
        return self.repository.get_changeset(
 
            self.repository._repo.refs.as_dict().get('HEAD'))
 
        wk_dir_id = self.repository._repo.refs.as_dict().get('HEAD')
 
        return self.repository.get_changeset(wk_dir_id)
 

	
 
    def checkout_branch(self, branch=None):
 
        if branch is None:
 
            branch = self.repository.DEFAULT_BRANCH_NAME
 
        if branch not in self.repository.branches:
 
            raise BranchDoesNotExistError
rhodecode/lib/vcs/backends/hg/workdir.py
Show inline comments
 
@@ -7,13 +7,14 @@ from rhodecode.lib.vcs.utils.hgcompat im
 
class MercurialWorkdir(BaseWorkdir):
 

	
 
    def get_branch(self):
 
        return self.repository._repo.dirstate.branch()
 

	
 
    def get_changeset(self):
 
        return self.repository.get_changeset()
 
        wk_dir_id = self.repository._repo[None].parents()[0].hex()
 
        return self.repository.get_changeset(wk_dir_id)
 

	
 
    def checkout_branch(self, branch=None):
 
        if branch is None:
 
            branch = self.repository.DEFAULT_BRANCH_NAME
 
        if branch not in self.repository.branches:
 
            raise BranchDoesNotExistError
0 comments (0 inline, 0 general)