本文整理汇总了Python中mercurial.hg.clean函数的典型用法代码示例。如果您正苦于以下问题:Python clean函数的具体用法?Python clean怎么用?Python clean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: harvest
def harvest(ui, repo, branch, dest="default", **opts):
"""Close and merge a named branch into the destination branch"""
if branch not in repo.branchtags():
ui.warn("Branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
return
if dest not in repo.branchtags():
ui.warn("Destination branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
return
heads = repo.branchheads(branch)
if len(heads) == 0:
ui.warn("Cannot harvest branch %s because it is currently closed. \nUse 'hg merge' to merge it manually.\n" % branch)
return
if len(heads) > 1:
ui.warn("Branch %s has multiple heads. \nUse 'hg merge' to merge it manually.\n" % branch)
return
rev = repo.branchtip(branch)
newrev = context.memctx(repo, [rev, None], "Closed branch %s" % branch, [], None, opts.get('user'), opts.get('date'), extra={'close':1, 'branch':branch})
newrev.commit()
#don't need to switch if already on destination branch
curr = repo[None].branch()
if dest != curr:
hg.clean(repo, dest, False)
ui.status("Switched to branch %s before merging\n" % dest)
failed = hg.merge(repo, branch, remind = False)
if not failed:
repo.commit("Merged %s" % branch, opts.get('user'), opts.get('date'), None)
ui.status("Completed merge of %s into %s\n" % (branch, dest))
示例2: strip
def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None):
wlock = lock = None
try:
wlock = repo.wlock()
lock = repo.lock()
if update:
checklocalchanges(repo, force=force)
urev, p2 = repo.changelog.parents(revs[0])
if (util.safehasattr(repo, 'mq') and
p2 != nullid
and p2 in [x.node for x in repo.mq.applied]):
urev = p2
hg.clean(repo, urev)
repo.dirstate.write(repo.currenttransaction())
repair.strip(ui, repo, revs, backup)
repomarks = repo._bookmarks
if bookmarks:
with repo.transaction('strip') as tr:
if repo._activebookmark in bookmarks:
bookmarksmod.deactivate(repo)
for bookmark in bookmarks:
del repomarks[bookmark]
repomarks.recordchange(tr)
for bookmark in sorted(bookmarks):
ui.write(_("bookmark '%s' deleted\n") % bookmark)
finally:
release(lock, wlock)
示例3: cleanup
def cleanup(self):
try:
commands.revert(self.repo.ui, self.repo, date=None, rev=None,
all=True, no_backup=True)
hg.clean(self.repo, self.branch, show_stats=False)
except Exception, e:
logger.error(e)
示例4: test_push_executable_file
def test_push_executable_file(self):
self.test_push_to_default(commit=True)
repo = self.repo
def file_callback(repo, memctx, path):
if path == 'gamma':
return context.memfilectx(path=path,
data='foo',
islink=False,
isexec=True,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
ctx = context.memctx(repo,
(repo['tip'].node(), node.nullid),
'message',
['gamma', ],
file_callback,
'author',
'2008-10-29 21:26:00 -0500',
{'branch': 'default', })
new_hash = repo.commitctx(ctx)
hg.clean(repo, repo['tip'].node())
self.pushrevisions()
tip = self.repo['tip']
self.assertNotEqual(tip.node(), new_hash)
self.assert_('@' in self.repo['tip'].user())
self.assertEqual(tip['gamma'].flags(), 'x')
self.assertEqual(tip['gamma'].data(), 'foo')
self.assertEqual([x for x in tip.manifest().keys() if 'x' not in
tip[x].flags()], ['alpha', 'beta', 'adding_file', ])
示例5: strip
def strip(ui, repo, revs, update=True, backup=True, force=None, bookmark=None):
wlock = lock = None
try:
wlock = repo.wlock()
lock = repo.lock()
if update:
checklocalchanges(repo, force=force)
urev, p2 = repo.changelog.parents(revs[0])
if (util.safehasattr(repo, 'mq') and
p2 != nullid
and p2 in [x.node for x in repo.mq.applied]):
urev = p2
hg.clean(repo, urev)
repo.dirstate.write()
repair.strip(ui, repo, revs, backup)
marks = repo._bookmarks
if bookmark:
if bookmark == repo._bookmarkcurrent:
bookmarks.unsetcurrent(repo)
del marks[bookmark]
marks.write()
ui.write(_("bookmark '%s' deleted\n") % bookmark)
finally:
release(lock, wlock)
示例6: switch_branch
def switch_branch(ui, repo, branch, **opts):
"""Switch to the named branch"""
if branch not in repo.branchtags():
ui.warn("Branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
return
curr = repo[None].branch()
if branch == curr:
ui.status("Already on branch %s\n" % branch)
return
hg.clean(repo, branch)
示例7: clean
def clean(self, rev=None):
'''Bring workspace up to REV (or tip) forcefully (discarding in
progress changes)'''
if rev != None:
rev = self.repo.lookup(rev)
else:
rev = self.repo.changelog.tip()
hg.clean(self.repo, rev, show_stats=False)
示例8: cleanup
def cleanup(self, repo, pats=[], opts={}):
'''removes all changes from the working copy and makes it so
there isn't a patch applied'''
node = repo.dirstate.parents()[0]
if not pats and not opts.get('include') and not opts.get('exclude'):
hg.clean(repo, node, False)
else:
opts['date'] = None
opts['all'] = True # Just to trick revert
opts['rev'] = node
commands.revert(self.ui, repo, *pats, **opts)
self.applied = ''
self.persiststate()
示例9: commitchanges
def commitchanges(self, changes, parent='tip', message='automated test'):
"""Commit changes to mercurial directory
'changes' is a sequence of tuples (source, dest, data). It can look
like:
- (source, source, data) to set source content to data
- (source, dest, None) to set dest content to source one, and mark it as
copied from source.
- (source, dest, data) to set dest content to data, and mark it as copied
from source.
- (source, None, None) to remove source.
"""
repo = self.repo
parentctx = repo[parent]
changed, removed = [], []
for source, dest, newdata in changes:
if dest is None:
removed.append(source)
else:
changed.append(dest)
def filectxfn(repo, memctx, path):
if path in removed:
return compathacks.filectxfn_deleted(memctx, path)
entry = [e for e in changes if path == e[1]][0]
source, dest, newdata = entry
if newdata is None:
newdata = parentctx[source].data()
copied = None
if source != dest:
copied = source
return compathacks.makememfilectx(repo,
path=dest,
data=newdata,
islink=False,
isexec=False,
copied=copied)
ctx = context.memctx(repo,
(parentctx.node(), node.nullid),
message,
changed + removed,
filectxfn,
'an_author',
'2008-10-07 20:59:48 -0500')
nodeid = repo.commitctx(ctx)
repo = self.repo
hg.clean(repo, nodeid)
return nodeid
示例10: strip
def strip(self, repo, revs, update=True, backup="all", force=None):
wlock = lock = None
try:
wlock = repo.wlock()
lock = repo.lock()
if update:
self.checklocalchanges(repo, force=force, refresh=False)
urev = self.qparents(repo, revs[0])
hg.clean(repo, urev)
repo.dirstate.write()
repair.strip(self.ui, repo, revs, backup)
finally:
release(lock, wlock)
示例11: process_revision
def process_revision(revision):
# change to revision and create metrics
print 'Processing revision : %s' % revision
# change repository to revision
hg.clean(repo, revision)
# collect files to process
exclude = re.compile('|'.join([translate(ep)
for ep in exclude_pattern]))
files = [os.path.relpath(os.path.join(dp, name), base) for
(dp, dn, fn) in os.walk(base)
for name in fn
if not exclude.match(os.path.relpath(os.path.join(dp, name), base))]
print 'Number of files to process : %d' % len(files)
return create_metrics(files)
示例12: update
def update(ui, args, repo, clean=False, **opts):
"""update to a specified Subversion revision number
"""
assert len(args) == 1
rev = int(args[0])
meta = repo.svnmeta()
answers = []
for k, v in meta.revmap.iteritems():
if k[0] == rev:
answers.append((v, k[1]))
if len(answers) == 1:
if clean:
return hg.clean(repo, answers[0][0])
return hg.update(repo, answers[0][0])
elif len(answers) == 0:
ui.status('revision %s did not produce an hg revision\n' % rev)
return 1
else:
ui.status('ambiguous revision!\n')
revs = ['%s on %s' % (node.hex(a[0]), a[1]) for a in answers] + ['']
ui.status('\n'.join(revs))
return 1
示例13: update
def update(ui, args, repo, clean=False, **opts):
"""update to a specified Subversion revision number
"""
try:
rev = int(args[0])
except IndexError:
raise error.CommandError('svn',
"no revision number specified for 'update'")
except ValueError:
raise error.Abort("'%s' is not a valid Subversion revision number"
% args[0])
meta = repo.svnmeta()
answers = []
for k, v in meta.revmap.iteritems():
if k[0] == rev:
answers.append((v, k[1]))
if len(answers) == 1:
if clean:
return hg.clean(repo, answers[0][0])
return hg.update(repo, answers[0][0])
elif len(answers) == 0:
ui.status('revision %s did not produce an hg revision\n' % rev)
return 1
else:
ui.status('ambiguous revision!\n')
revs = ['%s on %s' % (node.hex(a[0]), a[1]) for a in answers] + ['']
ui.status('\n'.join(revs))
return 1
示例14: strip
def strip(ui, repo, revs, update=True, backup="all", force=None):
wlock = lock = None
try:
wlock = repo.wlock()
lock = repo.lock()
if update:
checklocalchanges(repo, force=force)
urev, p2 = repo.changelog.parents(revs[0])
if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
urev = p2
hg.clean(repo, urev)
repo.dirstate.write()
repair.strip(ui, repo, revs, backup)
finally:
release(lock, wlock)
示例15: postincoming
def postincoming(other, modheads):
if modheads == 0:
return 0
if modheads == 1:
return hg.clean(repo, repo.changelog.tip())
newheads = repo.heads(parent)
newchildren = [n for n in repo.heads(parent) if n != parent]
newparent = parent
if newchildren:
newparent = newchildren[0]
hg.clean(repo, newparent)
newheads = [n for n in repo.heads() if n != newparent]
if len(newheads) > 1:
ui.status(_('not merging with %d other new heads '
'(use "hg heads" and "hg merge" to merge them)') %
(len(newheads) - 1))
return
err = False
if newheads:
# By default, we consider the repository we're pulling
# *from* as authoritative, so we merge our changes into
# theirs.
if opts['switch_parent']:
firstparent, secondparent = newparent, newheads[0]
else:
firstparent, secondparent = newheads[0], newparent
ui.status(_('updating to %d:%s\n') %
(repo.changelog.rev(firstparent),
short(firstparent)))
hg.clean(repo, firstparent)
ui.status(_('merging with %d:%s\n') %
(repo.changelog.rev(secondparent), short(secondparent)))
err = hg.merge(repo, secondparent, remind=False)
if not err:
mod, add, rem = repo.status()[:3]
message = (cmdutil.logmessage(opts) or
(_('Automated merge with %s') %
util.removeauth(other.url())))
force_editor = opts.get('force_editor') or opts.get('edit')
n = repo.commit(mod + add + rem, message,
opts['user'], opts['date'], force=True,
force_editor=force_editor)
ui.status(_('new changeset %d:%s merges remote changes '
'with local\n') % (repo.changelog.rev(n),
short(n)))