@hgcommand
def change(ui, repo, *pats, **opts):
 if codereview_disabled:
  raise hg_util.Abort(codereview_disabled)
 dirty = {}
 if ((len(pats) > 0) and GoodCLName(pats[0])):
  name = pats[0]
  if (len(pats) != 1):
   raise hg_util.Abort('cannot specify CL name and file patterns')
  pats = pats[1:]
  (cl, err) = LoadCL(ui, repo, name, web=True)
  if (err != ''):
   raise hg_util.Abort(err)
  if ((not cl.local) and (opts['stdin'] or (not opts['stdout']))):
   raise hg_util.Abort(('cannot change non-local CL ' + name))
 else:
  name = 'new'
  cl = CL('new')
  if (not workbranch(repo[None].branch())):
   raise hg_util.Abort("cannot create CL outside default branch; switch with 'hg update default'")
  dirty[cl] = True
  files = ChangedFiles(ui, repo, pats, taken=Taken(ui, repo))
 if (opts['delete'] or opts['deletelocal']):
  if (opts['delete'] and opts['deletelocal']):
   raise hg_util.Abort('cannot use -d and -D together')
  flag = '-d'
  if opts['deletelocal']:
   flag = '-D'
  if (name == 'new'):
   raise hg_util.Abort((('cannot use ' + flag) + ' with file patterns'))
  if (opts['stdin'] or opts['stdout']):
   raise hg_util.Abort((('cannot use ' + flag) + ' with -i or -o'))
  if (not cl.local):
   raise hg_util.Abort(('cannot change non-local CL ' + name))
  if opts['delete']:
   if cl.copied_from:
    raise hg_util.Abort('original author must delete CL; hg change -D will remove locally')
   PostMessage(ui, cl.name, '*** Abandoned ***', send_mail=cl.mailed)
   EditDesc(cl.name, closed=True, private=cl.private)
  cl.Delete(ui, repo)
  return
 if opts['stdin']:
  s = sys.stdin.read()
  (clx, line, err) = ParseCL(s, name)
  if (err != ''):
   raise hg_util.Abort(('error parsing change list: line %d: %s' % (line, err)))
  if (clx.desc is not None):
   cl.desc = clx.desc
   dirty[cl] = True
  if (clx.reviewer is not None):
   cl.reviewer = clx.reviewer
   dirty[cl] = True
  if (clx.cc is not None):
   cl.cc = clx.cc
   dirty[cl] = True
  if (clx.files is not None):
   cl.files = clx.files
   dirty[cl] = True
  if (clx.private != cl.private):
   cl.private = clx.private
   dirty[cl] = True
 if ((not opts['stdin']) and (not opts['stdout'])):
  if (name == 'new'):
   cl.files = files
  err = EditCL(ui, repo, cl)
  if (err != ''):
   raise hg_util.Abort(err)
  dirty[cl] = True
 for (d, _) in dirty.items():
  name = d.name
  d.Flush(ui, repo)
  if (name == 'new'):
   d.Upload(ui, repo, quiet=True)
 if opts['stdout']:
  ui.write(cl.EditorText())
 elif opts['pending']:
  ui.write(cl.PendingText())
 elif (name == 'new'):
  if ui.quiet:
   ui.write(cl.name)
  else:
   ui.write((('CL created: ' + cl.url) + '\n'))
 return

@ hgcommand def change ( ui , repo , * pats , ** opts ) : if codereview_disabled : raise hg_util . Abort ( codereview_disabled ) dirty = { } if ( ( len ( pats ) > 0 ) and GoodCLName ( pats [ 0 ] ) ) : name = pats [ 0 ] if ( len ( pats ) != 1 ) : raise hg_util . Abort ( 'cannot specify CL name and file patterns' ) pats = pats [ 1 : ] ( cl , err ) = LoadCL ( ui , repo , name , web = True ) if ( err != '' ) : raise hg_util . Abort ( err ) if ( ( not cl . local ) and ( opts [ 'stdin' ] or ( not opts [ 'stdout' ] ) ) ) : raise hg_util . Abort ( ( 'cannot change non-local CL ' + name ) ) else : name = 'new' cl = CL ( 'new' ) if ( not workbranch ( repo [ None ] . branch ( ) ) ) : raise hg_util . Abort ( "cannot create CL outside default branch; switch with 'hg update default'" ) dirty [ cl ] = True files = ChangedFiles ( ui , repo , pats , taken = Taken ( ui , repo ) ) if ( opts [ 'delete' ] or opts [ 'deletelocal' ] ) : if ( opts [ 'delete' ] and opts [ 'deletelocal' ] ) : raise hg_util . Abort ( 'cannot use -d and -D together' ) flag = '-d' if opts [ 'deletelocal' ] : flag = '-D' if ( name == 'new' ) : raise hg_util . Abort ( ( ( 'cannot use ' + flag ) + ' with file patterns' ) ) if ( opts [ 'stdin' ] or opts [ 'stdout' ] ) : raise hg_util . Abort ( ( ( 'cannot use ' + flag ) + ' with -i or -o' ) ) if ( not cl . local ) : raise hg_util . Abort ( ( 'cannot change non-local CL ' + name ) ) if opts [ 'delete' ] : if cl . copied_from : raise hg_util . Abort ( 'original author must delete CL; hg change -D will remove locally' ) PostMessage ( ui , cl . name , '*** Abandoned ***' , send_mail = cl . mailed ) EditDesc ( cl . name , closed = True , private = cl . private ) cl . Delete ( ui , repo ) return if opts [ 'stdin' ] : s = sys . stdin . read ( ) ( clx , line , err ) = ParseCL ( s , name ) if ( err != '' ) : raise hg_util . Abort ( ( 'error parsing change list: line %d: %s' % ( line , err ) ) ) if ( clx . desc is not None ) : cl . desc = clx . desc dirty [ cl ] = True if ( clx . reviewer is not None ) : cl . reviewer = clx . reviewer dirty [ cl ] = True if ( clx . cc is not None ) : cl . cc = clx . cc dirty [ cl ] = True if ( clx . files is not None ) : cl . files = clx . files dirty [ cl ] = True if ( clx . private != cl . private ) : cl . private = clx . private dirty [ cl ] = True if ( ( not opts [ 'stdin' ] ) and ( not opts [ 'stdout' ] ) ) : if ( name == 'new' ) : cl . files = files err = EditCL ( ui , repo , cl ) if ( err != '' ) : raise hg_util . Abort ( err ) dirty [ cl ] = True for ( d , _ ) in dirty . items ( ) : name = d . name d . Flush ( ui , repo ) if ( name == 'new' ) : d . Upload ( ui , repo , quiet = True ) if opts [ 'stdout' ] : ui . write ( cl . EditorText ( ) ) elif opts [ 'pending' ] : ui . write ( cl . PendingText ( ) ) elif ( name == 'new' ) : if ui . quiet : ui . write ( cl . name ) else : ui . write ( ( ( 'CL created: ' + cl . url ) + '\n' ) ) return
calculate the relative change between a value and a reference point .