Skip to content

Commit

Permalink
Fix: MercurialHandler does read the version number properly
Browse files Browse the repository at this point in the history
MercurialHandler fails to retrieve the version number of a working copy if the last changeset did not affect the root folder "csb" (e.g. after adding a tag).
  • Loading branch information
ivan-kalev committed Aug 6, 2012
1 parent 4cb2f68 commit 74e8926
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions csb/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,23 +538,30 @@ def __init__(self, path, sc='hg'):
super(MercurialHandler, self).__init__(path, sc)

def read(self):

cmd = '{0.sc} log -r tip {0.path}'.format(self)

revision = None
changeset = ''

for line in self._run(cmd):
if line.startswith('changeset:'):
items = line[10:].split(':')
revision = int(items[0])
changeset = items[1].strip()
break

if revision is None:
raise RevisionError('No revision number found', code=0, cmd=cmd)
wd = os.getcwd()
os.chdir(self.path)

try:
cmd = '{0.sc} log -r tip'.format(self)

revision = None
changeset = ''

for line in self._run(cmd):
if line.startswith('changeset:'):
items = line[10:].split(':')
revision = int(items[0])
changeset = items[1].strip()
break

if revision is None:
raise RevisionError('No revision number found', code=0, cmd=cmd)

return RevisionInfo(self.path, revision, changeset)

return RevisionInfo(self.path, revision, changeset)
finally:
os.chdir(wd)

class RevisionInfo(object):

Expand Down

0 comments on commit 74e8926

Please sign in to comment.