Ejemplo n.º 1
0
def cdm_restore(ui, repo, backup, **opts):
    '''restore workspace from backup

    Restores a workspace from the specified backup directory and generation
    (which defaults to the latest).'''

    if not os.getcwd().startswith(repo.root):
        raise util.Abort('restore is not safe to run with -R')

    abort_if_dirty(wslist[repo])

    if opts['generation']:
        gen = int(opts['generation'])
    else:
        gen = None

    if os.path.exists(backup):
        backup = os.path.abspath(backup)

    wlock = repo.wlock()
    lock = repo.lock()

    try:
        bk = CdmBackup(ui, wslist[repo], backup)
        bk.restore(gen)
    finally:
        lock.release()
        wlock.release()
Ejemplo n.º 2
0
def cdm_restore(ui, repo, backup, **opts):
    '''restore workspace from backup

    Restores a workspace from the specified backup directory and generation
    (which defaults to the latest).'''

    if not os.getcwd().startswith(repo.root):
        raise util.Abort('restore is not safe to run with -R')
    if wslist[repo].modified():
        raise util.Abort('Workspace has uncommitted changes')
    if wslist[repo].merged():
        raise util.Abort('Workspace has an uncommitted merge')
    if wslist[repo].branched():
        raise util.Abort('Workspace has an uncommitted branch')

    if opts['generation']:
        gen = int(opts['generation'])
    else:
        gen = None

    if os.path.exists(backup):
        backup = os.path.abspath(backup)

    bk = CdmBackup(ui, wslist[repo], backup)
    bk.restore(gen)
Ejemplo n.º 3
0
def cdm_restore(ui, repo, backup, **opts):
    '''restore workspace from backup

    Restore this workspace from a backup (taken by 'hg backup').

    If the specified backup directory does not exist, it is assumed to
    be relative to the cadmium backup directory (~/cdm.backup/ by
    default).

    For example::

      % hg restore on-rfe - Restore the latest backup of ~/cdm.backup/on-rfe
      % hg restore -g3 on-rfe - Restore the 3rd backup of ~/cdm.backup/on-rfe
      % hg restore /net/foo/backup/on-rfe - Restore from an explicit path
    '''

    if not os.getcwd().startswith(repo.root):
        raise util.Abort('restore is not safe to run with -R')

    abort_if_dirty(wslist[repo])

    if opts['generation']:
        gen = int(opts['generation'])
    else:
        gen = None

    if os.path.exists(backup):
        backup = os.path.abspath(backup)

    wlock = repo.wlock()
    lock = repo.lock()

    try:
        bk = CdmBackup(ui, wslist[repo], backup)
        bk.restore(gen)
    finally:
        lock.release()
        wlock.release()