本文整理汇总了Python中mercurial.util.parsedate函数的典型用法代码示例。如果您正苦于以下问题:Python parsedate函数的具体用法?Python parsedate怎么用?Python parsedate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parsedate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: fakewrite
def fakewrite(ui, func):
# fake "now" of 'pack_dirstate' only if it is invoked while 'func'
fakenow = ui.config('fakedirstatewritetime', 'fakenow')
if not fakenow:
# Execute original one, if fakenow isn't configured. This is
# useful to prevent subrepos from executing replaced one,
# because replacing 'parsers.pack_dirstate' is also effective
# in subrepos.
return func()
# parsing 'fakenow' in YYYYmmddHHMM format makes comparison between
# 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy
fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0]
orig_pack_dirstate = parsers.pack_dirstate
orig_dirstate_getfsnow = dirstate._getfsnow
wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args)
parsers.pack_dirstate = wrapper
dirstate._getfsnow = lambda *args: fakenow
try:
return func()
finally:
parsers.pack_dirstate = orig_pack_dirstate
dirstate._getfsnow = orig_dirstate_getfsnow
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:26,代码来源:fakedirstatewritetime.py
示例2: makepatch
def makepatch(ui, repo, name=None, pats=[], opts={}):
"""sets up the call for attic.createpatch and makes the call"""
s = repo.attic
force = opts.get('force')
if name and s.exists(name) and name != s.applied and not force:
raise util.Abort(_('attempting to overwrite existing patch'))
if name and s.applied and name != s.applied and not force:
raise util.Abort(_('a different patch is active'))
if not name:
name = s.applied
if not name:
raise util.Abort(_('you need to supply a patch name'))
date, user, message = None, None, ''
if s.applied:
data = patch.extract(ui, open(s.join(s.applied), 'r'))
tmpname, message, user, date, branch, nodeid, p1, p2 = data
os.unlink(tmpname)
msg = cmdutil.logmessage(opts)
if not msg:
msg = message
if opts.get('edit'):
msg = ui.edit(msg, ui.username())
setupheaderopts(ui, opts)
if opts.get('user'):
user=opts['user']
if not user:
user = ui.username()
if opts.get('date'):
date=opts['date']
if not date:
date = util.makedate()
date = util.parsedate(date)
s.createpatch(repo, name, msg, user, date, pats, opts)
开发者ID:axtl,项目名称:dotfiles,代码行数:34,代码来源:attic.py
示例3: chash
def chash(manifest, files, desc, p1, p2, user, date, extra):
"""Compute changeset hash from the changeset pieces."""
user = user.strip()
if "\n" in user:
raise error.RevlogError(_("username %s contains a newline")
% repr(user))
# strip trailing whitespace and leading and trailing empty lines
desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
if date:
parseddate = "%d %d" % util.parsedate(date)
else:
parseddate = "%d %d" % util.makedate()
extra = extra.copy()
if 'signature' in extra:
del extra['signature']
if extra.get("branch") in ("default", ""):
del extra["branch"]
if extra:
extra = changelog.encodeextra(extra)
parseddate = "%s %s" % (parseddate, extra)
l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
text = "\n".join(l)
return revlog.hash(text, p1, p2)
开发者ID:tpoeppke,项目名称:reds,代码行数:27,代码来源:commitsigs.py
示例4: __init__
def __init__(self, patchpath, repo, pf=None, rev=None):
""" Read patch context from file
:param pf: currently ignored
The provided handle is used to read the patch and
the patchpath contains the name of the patch.
The handle is NOT closed.
"""
self._path = patchpath
if rev:
assert isinstance(rev, str)
self._patchname = rev
else:
self._patchname = os.path.basename(patchpath)
self._repo = repo
self._rev = rev or 'patch'
self._status = [[], [], []]
self._fileorder = []
self._user = ''
self._desc = ''
self._branch = ''
self._node = node.nullid
self._mtime = None
self._fsize = 0
self._parseerror = None
self._phase = 'draft'
try:
self._mtime = os.path.getmtime(patchpath)
self._fsize = os.path.getsize(patchpath)
ph = mq.patchheader(self._path)
self._ph = ph
except EnvironmentError:
self._date = util.makedate()
return
try:
self._branch = ph.branch or ''
self._node = binascii.unhexlify(ph.nodeid)
if self._repo.ui.configbool('mq', 'secret'):
self._phase = 'secret'
except TypeError:
pass
except AttributeError:
# hacks to try to deal with older versions of mq.py
self._branch = ''
ph.diffstartline = len(ph.comments)
if ph.message:
ph.diffstartline += 1
except error.ConfigError:
pass
self._user = ph.user or ''
self._desc = ph.message and '\n'.join(ph.message).strip() or ''
try:
self._date = ph.date and util.parsedate(ph.date) or util.makedate()
except error.Abort:
self._date = util.makedate()
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:57,代码来源:patchctx.py
示例5: _getmetadata
def _getmetadata(**opts):
metadata = {}
date = opts.get('date')
user = opts.get('user')
if date:
metadata['date'] = '%i %i' % util.parsedate(date)
if user:
metadata['user'] = user
return metadata
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:9,代码来源:prune.py
示例6: printFile
def printFile(ui, repo, file, disableLastCommit, transport):
date = '0 0'
description = 'n/a'
if not disableLastCommit:
linkrev = repo[file.linkrev()]
date = '%d %d' % util.parsedate(linkrev.date())
description = linkrev.description()
format = '%s %i %s %s\n'
if transport:
format = 'f%s\n%i %s %s\0'
ui.write( format % (file.path(), file.size(), date, description) )
开发者ID:amuniz,项目名称:scm-manager,代码行数:11,代码来源:fileview.py
示例7: validatePage
def validatePage(self):
if self.cmd.core.running():
return False
if len(self.repo.parents()) == 1:
# commit succeeded, repositoryChanged() called wizard().next()
if self.skiplast.isChecked():
self.wizard().close()
return True
user = qtlib.getCurrentUsername(self, self.repo, self.opts)
if not user:
return False
self.setTitle(_('Committing...'))
self.setSubTitle(_('Please wait while committing merged files.'))
message = hglib.fromunicode(self.msgEntry.text())
cmdline = ['commit', '--verbose', '--message', message,
'--repository', self.repo.root, '--user', user]
if self.opts.get('recurseinsubrepos'):
cmdline.append('--subrepos')
try:
date = self.opts.get('date')
if date:
util.parsedate(date)
dcmd = ['--date', date]
else:
dcmd = []
except error.Abort, e:
if e.hint:
err = _('%s (hint: %s)') % (hglib.tounicode(str(e)),
hglib.tounicode(e.hint))
else:
err = hglib.tounicode(str(e))
qtlib.WarningMsgBox(_('TortoiseHg Merge Commit'),
_('Error creating interpreting commit date (%s).\n'
'Using current date instead.'), err)
dcmd = []
开发者ID:velorientc,项目名称:git_test7,代码行数:40,代码来源:merge.py
示例8: internalpatch
def internalpatch(orig, ui, repo, patchobj, strip,
prefix='', files=None,
eolmode='strict', similarity=0):
if files is None:
files = set()
r = orig(ui, repo, patchobj, strip,
prefix=prefix, files=files,
eolmode=eolmode, similarity=similarity)
fakenow = ui.config('fakepatchtime', 'fakenow')
if fakenow:
# parsing 'fakenow' in YYYYmmddHHMM format makes comparison between
# 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy
fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0]
for f in files:
repo.wvfs.utime(f, (fakenow, fakenow))
return r
开发者ID:Distrotech,项目名称:mercurial,代码行数:18,代码来源:fakepatchtime.py
示例9: getdate
def getdate(n):
if n not in dates:
dates[n] = util.parsedate(self.commitcache[n].date)
return dates[n]
开发者ID:c0ns0le,项目名称:cygwin,代码行数:4,代码来源:convcmd.py
示例10: svnutcdate
def svnutcdate(text):
''':svnutcdate: Date. Returns a UTC-date in this format: "2009-08-18
11:00:13Z".
'''
return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ')
开发者ID:leetaizhu,项目名称:Odoo_ENV_MAC_OS,代码行数:5,代码来源:keyword.py
示例11: utcdate
def utcdate(text):
''':utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13".
'''
return util.datestr((util.parsedate(text)[0], 0), '%Y/%m/%d %H:%M:%S')
开发者ID:leetaizhu,项目名称:Odoo_ENV_MAC_OS,代码行数:4,代码来源:keyword.py
示例12: createlog
#.........这里部分代码省略.........
assert not re_32.match(line), _('must have at least '
'some revisions')
elif state == 5:
# expecting revision number and possibly (ignored) lock indication
# we create the logentry here from values stored in states 0 to 4,
# as this state is re-entered for subsequent revisions of a file.
match = re_50.match(line)
assert match, _('expected revision number')
e = logentry(rcs=scache(rcs),
file=scache(filename),
revision=tuple([int(x) for x in
match.group(1).split('.')]),
branches=[],
parent=None,
commitid=None,
mergepoint=None,
branchpoints=set())
state = 6
elif state == 6:
# expecting date, author, state, lines changed
match = re_60.match(line)
assert match, _('revision must be followed by date line')
d = match.group(1)
if d[2] == '/':
# Y2K
d = '19' + d
if len(d.split()) != 3:
# cvs log dates always in GMT
d = d + ' UTC'
e.date = util.parsedate(d, ['%y/%m/%d %H:%M:%S',
'%Y/%m/%d %H:%M:%S',
'%Y-%m-%d %H:%M:%S'])
e.author = scache(match.group(2))
e.dead = match.group(3).lower() == 'dead'
if match.group(5):
if match.group(6):
e.lines = (int(match.group(5)), int(match.group(6)))
else:
e.lines = (int(match.group(5)), 0)
elif match.group(6):
e.lines = (0, int(match.group(6)))
else:
e.lines = None
if match.group(7): # cvs 1.12 commitid
e.commitid = match.group(8)
if match.group(9): # cvsnt mergepoint
myrev = match.group(10).split('.')
if len(myrev) == 2: # head
e.mergepoint = 'HEAD'
else:
myrev = '.'.join(myrev[:-2] + ['0', myrev[-2]])
branches = [b for b in branchmap if branchmap[b] == myrev]
assert len(branches) == 1, ('unknown branch: %s'
% e.mergepoint)
e.mergepoint = branches[0]
e.comment = []
state = 7
开发者ID:Distrotech,项目名称:mercurial,代码行数:66,代码来源:cvsps.py
示例13: fetch
def fetch(ui, repo, source="default", **opts):
"""pull changes from a remote repository, merge new changes if needed.
This finds all changes from the repository at the specified path
or URL and adds them to the local repository.
If the pulled changes add a new branch head, the head is
automatically merged, and the result of the merge is committed.
Otherwise, the working directory is updated to include the new
changes.
When a merge is needed, the working directory is first updated to
the newly pulled changes. Local changes are then merged into the
pulled changes. To switch the merge order, use --switch-parent.
See :hg:`help dates` for a list of formats valid for -d/--date.
Returns 0 on success.
"""
date = opts.get("date")
if date:
opts["date"] = util.parsedate(date)
parent, p2 = repo.dirstate.parents()
branch = repo.dirstate.branch()
try:
branchnode = repo.branchtip(branch)
except error.RepoLookupError:
branchnode = None
if parent != branchnode:
raise util.Abort(_("working dir not at branch tip " '(use "hg update" to check out branch tip)'))
if p2 != nullid:
raise util.Abort(_("outstanding uncommitted merge"))
wlock = lock = None
try:
wlock = repo.wlock()
lock = repo.lock()
mod, add, rem, del_ = repo.status()[:4]
if mod or add or rem:
raise util.Abort(_("outstanding uncommitted changes"))
if del_:
raise util.Abort(_("working directory is missing some files"))
bheads = repo.branchheads(branch)
bheads = [head for head in bheads if len(repo[head].children()) == 0]
if len(bheads) > 1:
raise util.Abort(_("multiple heads in this branch " '(use "hg heads ." and "hg merge" to merge)'))
other = hg.peer(repo, opts, ui.expandpath(source))
ui.status(_("pulling from %s\n") % util.hidepassword(ui.expandpath(source)))
revs = None
if opts["rev"]:
try:
revs = [other.lookup(rev) for rev in opts["rev"]]
except error.CapabilityError:
err = _("other repository doesn't support revision lookup, " "so a rev cannot be specified.")
raise util.Abort(err)
# Are there any changes at all?
modheads = repo.pull(other, heads=revs)
if modheads == 0:
return 0
# Is this a simple fast-forward along the current branch?
newheads = repo.branchheads(branch)
newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
if len(newheads) == 1 and len(newchildren):
if newchildren[0] != parent:
return hg.update(repo, newchildren[0])
else:
return 0
# Are there more than one additional branch heads?
newchildren = [n for n in newchildren if n != parent]
newparent = parent
if newchildren:
newparent = newchildren[0]
hg.clean(repo, newparent)
newheads = [n for n in newheads if n != newparent]
if len(newheads) > 1:
ui.status(
_("not merging with %d other new branch heads " '(use "hg heads ." and "hg merge" to merge them)\n')
% (len(newheads) - 1)
)
return 1
if not newheads:
return 0
# Otherwise, let's merge.
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]
#.........这里部分代码省略.........
开发者ID:influencia0406,项目名称:intellij-community,代码行数:101,代码来源:fetch.py
示例14: _parse
def _parse(self):
if self.changeset is not None:
return
self.changeset = {}
maxrev = 0
cmd = self.cmd
if self.rev:
# TODO: handle tags
try:
# patchset number?
maxrev = int(self.rev)
except ValueError:
try:
# date
util.parsedate(self.rev, ['%Y/%m/%d %H:%M:%S'])
cmd = '%s -d "1970/01/01 00:00:01" -d "%s"' % (cmd, self.rev)
except util.Abort:
raise util.Abort(_('revision %s is not a patchset number or date') % self.rev)
d = os.getcwd()
try:
os.chdir(self.path)
id = None
state = 0
filerevids = {}
if self.builtin:
# builtin cvsps code
self.ui.status(_('using builtin cvsps\n'))
cache = 'update'
if not self.ui.configbool('convert', 'cvsps.cache', True):
cache = None
db = cvsps.createlog(self.ui, cache=cache)
db = cvsps.createchangeset(self.ui, db,
fuzz=int(self.ui.config('convert', 'cvsps.fuzz', 60)),
mergeto=self.ui.config('convert', 'cvsps.mergeto', None),
mergefrom=self.ui.config('convert', 'cvsps.mergefrom', None))
for cs in db:
if maxrev and cs.id>maxrev:
break
id = str(cs.id)
cs.author = self.recode(cs.author)
self.lastbranch[cs.branch] = id
cs.comment = self.recode(cs.comment)
date = util.datestr(cs.date)
self.tags.update(dict.fromkeys(cs.tags, id))
files = {}
for f in cs.entries:
files[f.file] = "%s%s" % ('.'.join([str(x) for x in f.revision]),
['', '(DEAD)'][f.dead])
# add current commit to set
c = commit(author=cs.author, date=date,
parents=[str(p.id) for p in cs.parents],
desc=cs.comment, branch=cs.branch or '')
self.changeset[id] = c
self.files[id] = files
else:
# external cvsps
for l in util.popen(cmd):
if state == 0: # header
if l.startswith("PatchSet"):
id = l[9:-2]
if maxrev and int(id) > maxrev:
# ignore everything
state = 3
elif l.startswith("Date:"):
date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"])
date = util.datestr(date)
elif l.startswith("Branch:"):
branch = l[8:-1]
self.parent[id] = self.lastbranch.get(branch, 'bad')
self.lastbranch[branch] = id
elif l.startswith("Ancestor branch:"):
ancestor = l[17:-1]
# figure out the parent later
self.parent[id] = self.lastbranch[ancestor]
elif l.startswith("Author:"):
author = self.recode(l[8:-1])
elif l.startswith("Tag:") or l.startswith("Tags:"):
t = l[l.index(':')+1:]
t = [ut.strip() for ut in t.split(',')]
if (len(t) > 1) or (t[0] and (t[0] != "(none)")):
self.tags.update(dict.fromkeys(t, id))
elif l.startswith("Log:"):
# switch to gathering log
state = 1
log = ""
elif state == 1: # log
if l == "Members: \n":
# switch to gathering members
files = {}
oldrevs = []
log = self.recode(log[:-1])
state = 2
else:
#.........这里部分代码省略.........
开发者ID:Nurb432,项目名称:plan9front,代码行数:101,代码来源:cvs.py
示例15: new
def new(self, repo, patchfn, *pats, **opts):
"""options:
msg: a string or a no-argument function returning a string
"""
msg = opts.get('msg')
user = opts.get('user')
date = opts.get('date')
if date:
date = util.parsedate(date)
diffopts = self.diffopts({'git': opts.get('git')})
if opts.get('checkname', True):
self.checkpatchname(patchfn)
inclsubs = self.checksubstate(repo)
if inclsubs:
inclsubs.append('.hgsubstate')
substatestate = repo.dirstate['.hgsubstate']
if opts.get('include') or opts.get('exclude') or pats:
if inclsubs:
pats = list(pats or []) + inclsubs
match = scmutil.match(repo[None], pats, opts)
# detect missing files in pats
def badfn(f, msg):
if f != '.hgsubstate': # .hgsubstate is auto-created
raise util.Abort('%s: %s' % (f, msg))
match.bad = badfn
changes = repo.status(match=match)
m, a, r, d = changes[:4]
else:
changes = self.checklocalchanges(repo, force=True)
m, a, r, d = changes
match = scmutil.matchfiles(repo, m + a + r + inclsubs)
if len(repo[None].parents()) > 1:
raise util.Abort(_('cannot manage merge changesets'))
commitfiles = m + a + r
self.checktoppatch(repo)
insert = self.fullseriesend()
wlock = repo.wlock()
try:
try:
# if patch file write fails, abort early
p = self.opener(patchfn, "w")
except IOError, e:
raise util.Abort(_('cannot write patch "%s": %s')
% (patchfn, e.strerror))
try:
if self.plainmode:
if user:
p.write("From: " + user + "\n")
if not date:
p.write("\n")
if date:
p.write("Date: %d %d\n\n" % date)
else:
p.write("# HG changeset patch\n")
p.write("# Parent "
+ hex(repo[None].p1().node()) + "\n")
if user:
p.write("# User " + user + "\n")
if date:
p.write("# Date %s %s\n\n" % date)
if util.safehasattr(msg, '__call__'):
msg = msg()
commitmsg = msg and msg or ("[mq]: %s" % patchfn)
n = newcommit(repo, None, commitmsg, user, date, match=match,
force=True)
if n is None:
raise util.Abort(_("repo commit failed"))
try:
self.fullseries[insert:insert] = [patchfn]
self.applied.append(statusentry(n, patchfn))
self.parseseries()
self.seriesdirty = True
self.applieddirty = True
if msg:
msg = msg + "\n\n"
p.write(msg)
if commitfiles:
parent = self.qparents(repo, n)
if inclsubs:
self.putsubstate2changes(substatestate, changes)
chunks = patchmod.diff(repo, node1=parent, node2=n,
changes=changes, opts=diffopts)
for chunk in chunks:
p.write(chunk)
p.close()
r = self.qrepo()
if r:
r[None].add([patchfn])
except: # re-raises
repo.rollback()
raise
except Exception:
patchpath = self.join(patchfn)
try:
os.unlink(patchpath)
except OSError:
self.ui.warn(_('error unlinking %s\n') % patchpath)
raise
self.removeundo(repo)
开发者ID:peiyaoyao,项目名称:intellij-community,代码行数:99,代码来源:mq.py
示例16: patchbomb
#.........这里部分代码省略.........
if not (opts.get('test') or mbox):
# really sending
mail.validateconfig(ui)
if not (revs or rev or outgoing or bundle or patches):
raise util.Abort(_('specify at least one changeset with -r or -o'))
if outgoing and bundle:
raise util.Abort(_("--outgoing mode always on with --bundle;"
" do not re-specify --outgoing"))
if outgoing or bundle:
if len(revs) > 1:
raise util.Abort(_("too many destinations"))
if revs:
dest = revs[0]
else:
dest = None
revs = []
if rev:
if revs:
raise util.Abort(_('use only one form to specify the revision'))
revs = rev
revs = scmutil.revrange(repo, revs)
if outgoing:
revs = _getoutgoing(repo, dest, revs)
if bundle:
opts['revs'] = [str(r) for r in revs]
# start
if date:
start_time = util.parsedate(date)
else:
start_time = util.makedate()
def genmsgid(id):
return '<%s.%[email protected]%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
sender = (opts.get('from') or ui.config('email', 'from') or
ui.config('patchbomb', 'from') or
prompt(ui, 'From', ui.username()))
if patches:
msgs = _getpatchmsgs(repo, sender, patches, opts.get('patchnames'),
**opts)
elif bundle:
bundledata = _getbundle(repo, dest, **opts)
bundleopts = opts.copy()
bundleopts.pop('bundle', None) # already processed
msgs = _getbundlemsgs(repo, sender, bundledata, **bundleopts)
else:
_patches = list(_getpatches(repo, revs, **opts))
msgs = _getpatchmsgs(repo, sender, _patches, **opts)
showaddrs = []
def getaddrs(header, ask=False, default=None):
configkey = header.lower()
opt = header.replace('-', '_').lower()
addrs = opts.get(opt)
if addrs:
showaddrs.append('%s: %s' % (header, ', '.join(addrs)))
return mail.addrlistencode(ui, addrs, _charsets, opts.get('test'))
开发者ID:RayFerr000,项目名称:PLTL,代码行数:66,代码来源:patchbomb.py
示例17: sign
def sign(ui, repo, *revs, **opts):
"""add a signature for the current or given revision
If no revision is given, the parent of the working directory is used,
or tip if no revision is checked out.
See :hg:`help dates` for a list of formats valid for -d/--date.
"""
mygpg = newgpg(ui, **opts)
sigver = "0"
sigmessage = ""
date = opts.get("date")
if date:
opts["date"] = util.parsedate(date)
if revs:
nodes = [repo.lookup(n) for n in revs]
else:
nodes = [node for node in repo.dirstate.parents() if node != hgnode.nullid]
if len(nodes) > 1:
raise util.Abort(_("uncommitted merge - please provide a " "specific revision"))
if not nodes:
nodes = [repo.changelog.tip()]
for n in nodes:
hexnode = hgnode.hex(n)
ui.write(_("signing %d:%s\n") % (repo.changelog.rev(n), hgnode.short(n)))
# build data
data = node2txt(repo, n, sigver)
sig = mygpg.sign(data)
if not sig:
raise util.Abort(_("error while signing"))
sig = binascii.b2a_base64(sig)
sig = sig.replace("\n", "")
sigmessage += "%s %s %s\n" % (hexnode, sigver, sig)
# write it
if opts["local"]:
repo.vfs.append("localsigs", sigmessage)
return
if not opts["force"]:
msigs = match.exact(repo.root, "", [".hgsigs"])
if util.any(repo.status(match=msigs, unknown=True, ignored=True)):
raise util.Abort(_("working copy of .hgsigs is changed "), hint=_("please commit .hgsigs manually"))
sigsfile = repo.wfile(".hgsigs", "ab")
sigsfile.write(sigmessage)
sigsfile.close()
if ".hgsigs" not in repo.dirstate:
repo[None].add([".hgsigs"])
if opts["no_commit"]:
return
message = opts["message"]
if not message:
# we don't translate commit messages
message = "\n".join(["Added signature for changeset %s" % hgnode.short(n) for n in nodes])
try:
editor = cmdutil.getcommiteditor(editform="gpg.sign", **opts)
repo.commit(message, opts["user"], opts["date"], match=msigs, editor=editor)
except ValueError, inst:
raise util.Abort(str(inst))
开发者ID:nixiValor,项目名称:Waterfox,代码行数:67,代码来源:gpg.py
示例18: patchbomb
#.........这里部分代码省略.........
except:
pass
os.rmdir(tmpdir)
if not (opts.get('test') or mbox):
# really sending
mail.validateconfig(ui)
if not (revs or rev or outgoing or bundle or patches):
raise util.Abort(_('specify at least one changeset with -r or -o'))
if outgoing and bundle:
raise util.Abort(_("--outgoing mode always on with --bundle;"
" do not re-specify --outgoing"))
if outgoing or bundle:
if len(revs) > 1:
raise util.Abort(_("too many destinations"))
dest = revs and revs[0] or None
revs = []
if rev:
if revs:
raise util.Abort(_('use only one form to specify the revision'))
revs = rev
if outgoing:
revs = getoutgoing(dest, rev)
if bundle:
opts['revs'] = revs
# start
if date:
start_time = util.parsedate(date)
else:
start_time = util.makedate()
def genmsgid(id):
return '<%s.%[email protected]%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
def getdescription(body, sender):
if opts.get('desc'):
body = open(opts.get('desc')).read()
else:
ui.write(_('\nWrite the introductory message for the '
'patch series.\n\n'))
body = ui.edit(body, sender)
# Save series description in case sendmail fails
msgfile = repo.opener('last-email.txt', 'wb')
msgfile.write(body)
msgfile.close()
return body
def getpatchmsgs(patches, patchnames=None):
msgs = []
ui.write(_('This patch series consists of %d patches.\n\n')
% len(patches))
# build the intro message, or skip it if the user declines
if introwanted(opts, len(patches)):
msg = makeintro(patches)
if msg:
msgs.append(msg)
# are we going to send more than one message?
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:67,代码来源:patchbomb.py
示例19: fetch
def fetch(ui, repo, source='default', **opts):
'''pull changes from a remote repository, merge new changes if needed.
This finds all changes from the repository at the specified path
or URL and adds them to the local repository.
If the pulled changes add a new branch head, the head is
automatically merged, and the result of the merge is committed.
Otherwise, the working directory is updated to include the new
changes.
When a merge occurs, the newly pulled changes are assumed to be
"authoritative". The head of the new changes is used as the first
parent, with local changes as the second. To switch the merge
order, use --switch-parent.
See 'hg help dates' for a list of formats valid for -d/--date.
'''
date = opts.get('date')
if date:
opts['date'] = util.parsedate(date)
parent, p2 = repo.dirstate.parents()
branch = repo.dirstate.branch()
branchnode = repo.branchtags().get(branch)
if parent != branchnode:
raise util.Abort(_('working dir not at branch tip '
'(use "hg update" to check out branch tip)'))
if p2 != nullid:
raise util.Abort(_('outstanding uncommitted merge'))
wlock = lock = None
try:
wlock = repo.wlock()
lock = repo.lock()
mod, add, rem, del_ = repo.status()[:4]
if mod or add or rem:
raise util.Abort(_('outstanding uncommitted changes'))
if del_:
raise util.Abort(_('working directory is missing some files'))
bheads = repo.branchheads(branch)
bheads = [head for head in bheads if len(repo[head].children()) == 0]
if len(bheads) > 1:
raise util.Abort(_('multiple heads in this branch '
'(use "hg heads ." and "hg merge" to merge)'))
other = hg.repository(cmdutil.remoteui(repo, opts),
ui.expandpath(source))
ui.status(_('pulling from %s\n') %
url.hidepassword(ui.expandpath(source)))
revs = None
if opts['rev']:
try:
revs = [other.lookup(rev) for rev in opts['rev']]
except error.CapabilityError:
err = _("Other repository doesn't support revision lookup, "
"so a rev cannot be specified.")
raise util.Abort(err)
# Are there any changes at all?
modheads = repo.pull(other, heads=revs)
if modheads == 0:
return 0
# Is this a simple fast-forward along the current branch?
newheads = repo.branchheads(branch)
newheads = [head for head in newheads if len(repo[head].children()) == 0]
newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
if len(newheads) == 1:
if newchildren[0] != parent:
return hg.clean(repo, newchildren[0])
else:
return
# Are there more than one additional branch heads?
newchildren = [n for n in newchildren if n != parent]
newparent = parent
if newchildren:
newparent = newchildren[0]
hg.clean(repo, newparent)
newheads = [n for n in newheads if n != newparent]
if len(newheads) > 1:
ui.status(_('not merging with %d other new branch heads '
'(use "hg heads ." and "hg merge" to merge them)\n') %
(len(newheads) - 1))
return
# Otherwise, let's merge.
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
#.........这里部分代码省略.........
开发者ID:Nurb432,项目名称:plan9front,代码行数:101,代码来源:fetch.py
示例20: _dosign
def _dosign(ui, repo, *revs, **opts):
mygpg = newgpg(ui, **opts)
sigver = "0"
sigmessage = ""
date = opts.get('date')
if date:
opts['date'] = util.parsedate(date)
if revs:
nodes = [repo.lookup(n) for n in revs]
else:
nodes = [node for node in repo.dirstate.parents()
if node != hgnode.nullid]
if len(nodes) > 1:
raise error.Abort(_('uncommitted merge - please provide a '
'specific revision'))
if not nodes:
nodes = [repo.changelog.tip()]
for n in nodes:
hexnode = hgnode.hex(n)
ui.write(_("signing %d:%s\n") % (repo.changelog.rev(n),
hgnode.short(n)))
# build data
data = node2txt(repo, n, sigver)
sig = mygpg.sign(data)
if not sig:
raise error.Abort(_("error while signing"))
sig = binascii.b2a_base64(sig)
sig = sig.replace("\n", "")
sigmessage += "%s %s %s\n" % (hexnode, sigver, sig)
# write it
if opts['local']:
repo.vfs.append("localsigs", sigmessage)
return
if not opts["force"]:
msigs = match.exact(repo.root, '', ['.hgsigs'])
if any(repo.status(match=msigs, unknown=True, ignored=True)):
raise error.Abort(_("working copy of .hgsigs is changed "),
hint=_("please commit .hgsigs manually"))
sigsfile = repo.wfile(".hgsigs", "ab")
sigsfile.write(sigmessage)
sigsfile.close()
if '.hgsigs' not in repo.dirstate:
repo[None].add([".hgsigs"
|
请发表评论