Mercurial > hgstorage
changeset 9:9dd870ae1601
some docstrings
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sat, 14 May 2011 00:21:37 +0200 |
| parents | 1254345daa19 |
| children | 2f5f4963d09e |
| files | hgstorage.py |
| diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgstorage.py Sat May 14 00:11:19 2011 +0200 +++ b/hgstorage.py Sat May 14 00:21:37 2011 +0200 @@ -19,6 +19,12 @@ class Storage(object): + """ + A storage object holds all the configuration and path to your repository. + From this object you need to create sessions that can in turn be used to + manipulate entries in your repository. + """ + def __init__(self, path, prefix=None): self.path = path self.prefix = prefix or '' @@ -27,6 +33,10 @@ self.sessions = weakref.WeakKeyDictionary() def create(self): + """Create a repository at the configured path.""" + + if not os.path.exists(self.path): + os.makedirs(self.path) repo = mercurial.hg.repository(self.ui, self.path, create=True) @classmethod @@ -70,16 +80,26 @@ return key def session(self): + """Create a new session.""" + session = Session(self) self.sessions[session] = None return session def update_sessions(self): + """Update the tip on all active sessions.""" + for session in self.sessions: session._update() class Session(object): + """ + A session object lets you manipulate entries in the storage. It caches some + information for fast access, so you should discard it and use a new one for + from time to time. + """ + def __init__(self, storage): self.storage = storage self._update() @@ -121,8 +141,6 @@ return (parent_rev, last_rev) def _merge(self, filename, parent, other, data): - """Merge conflicting changes.""" - filetip = self.tip[filename] parent_data = filetip.filectx(parent).data() other_data = filetip.filectx(other).data()
